babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4312. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Notify all Observers by calling their respective callback with the given data
  4356. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4357. * @param eventData defines the data to send to all observers
  4358. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4359. * @param target defines the original target of the state
  4360. * @param currentTarget defines the current target of the state
  4361. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4362. */
  4363. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4364. /**
  4365. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4366. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4367. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4368. * and it is crucial that all callbacks will be executed.
  4369. * The order of the callbacks is kept, callbacks are not executed parallel.
  4370. *
  4371. * @param eventData The data to be sent to each callback
  4372. * @param mask is used to filter observers defaults to -1
  4373. * @param target defines the callback target (see EventState)
  4374. * @param currentTarget defines he current object in the bubbling phase
  4375. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4376. */
  4377. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4378. /**
  4379. * Notify a specific observer
  4380. * @param observer defines the observer to notify
  4381. * @param eventData defines the data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. */
  4384. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4385. /**
  4386. * Gets a boolean indicating if the observable has at least one observer
  4387. * @returns true is the Observable has at least one Observer registered
  4388. */
  4389. hasObservers(): boolean;
  4390. /**
  4391. * Clear the list of observers
  4392. */
  4393. clear(): void;
  4394. /**
  4395. * Clone the current observable
  4396. * @returns a new observable
  4397. */
  4398. clone(): Observable<T>;
  4399. /**
  4400. * Does this observable handles observer registered with a given mask
  4401. * @param mask defines the mask to be tested
  4402. * @return whether or not one observer registered with the given mask is handeled
  4403. **/
  4404. hasSpecificMask(mask?: number): boolean;
  4405. }
  4406. }
  4407. declare module "babylonjs/Misc/filesInputStore" {
  4408. /**
  4409. * Class used to help managing file picking and drag'n'drop
  4410. * File Storage
  4411. */
  4412. export class FilesInputStore {
  4413. /**
  4414. * List of files ready to be loaded
  4415. */
  4416. static FilesToLoad: {
  4417. [key: string]: File;
  4418. };
  4419. }
  4420. }
  4421. declare module "babylonjs/Engines/constants" {
  4422. /** Defines the cross module used constants to avoid circular dependncies */
  4423. export class Constants {
  4424. /** Defines that alpha blending is disabled */
  4425. static readonly ALPHA_DISABLE: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4427. static readonly ALPHA_ADD: number;
  4428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4429. static readonly ALPHA_COMBINE: number;
  4430. /** Defines that alpha blending to DEST - SRC * DEST */
  4431. static readonly ALPHA_SUBTRACT: number;
  4432. /** Defines that alpha blending to SRC * DEST */
  4433. static readonly ALPHA_MULTIPLY: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4435. static readonly ALPHA_MAXIMIZED: number;
  4436. /** Defines that alpha blending to SRC + DEST */
  4437. static readonly ALPHA_ONEONE: number;
  4438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_PREMULTIPLIED: number;
  4440. /**
  4441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4443. */
  4444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4446. static readonly ALPHA_INTERPOLATE: number;
  4447. /**
  4448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4450. */
  4451. static readonly ALPHA_SCREENMODE: number;
  4452. /** Defines that the ressource is not delayed*/
  4453. static readonly DELAYLOADSTATE_NONE: number;
  4454. /** Defines that the ressource was successfully delay loaded */
  4455. static readonly DELAYLOADSTATE_LOADED: number;
  4456. /** Defines that the ressource is currently delay loading */
  4457. static readonly DELAYLOADSTATE_LOADING: number;
  4458. /** Defines that the ressource is delayed and has not started loading */
  4459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4461. static readonly NEVER: number;
  4462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4463. static readonly ALWAYS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4465. static readonly LESS: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4467. static readonly EQUAL: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4469. static readonly LEQUAL: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4471. static readonly GREATER: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4473. static readonly GEQUAL: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4475. static readonly NOTEQUAL: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be kept */
  4477. static readonly KEEP: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4479. static readonly REPLACE: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4481. static readonly INCR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4483. static readonly DECR: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4485. static readonly INVERT: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4487. static readonly INCR_WRAP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4489. static readonly DECR_WRAP: number;
  4490. /** Texture is not repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4492. /** Texture is repeating outside of 0..1 UVs */
  4493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4494. /** Texture is repeating and mirrored */
  4495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4496. /** ALPHA */
  4497. static readonly TEXTUREFORMAT_ALPHA: number;
  4498. /** LUMINANCE */
  4499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4500. /** LUMINANCE_ALPHA */
  4501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4502. /** RGB */
  4503. static readonly TEXTUREFORMAT_RGB: number;
  4504. /** RGBA */
  4505. static readonly TEXTUREFORMAT_RGBA: number;
  4506. /** RED */
  4507. static readonly TEXTUREFORMAT_RED: number;
  4508. /** RED (2nd reference) */
  4509. static readonly TEXTUREFORMAT_R: number;
  4510. /** RG */
  4511. static readonly TEXTUREFORMAT_RG: number;
  4512. /** RED_INTEGER */
  4513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4514. /** RED_INTEGER (2nd reference) */
  4515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4516. /** RG_INTEGER */
  4517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4518. /** RGB_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4520. /** RGBA_INTEGER */
  4521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4522. /** UNSIGNED_BYTE */
  4523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4524. /** UNSIGNED_BYTE (2nd reference) */
  4525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4526. /** FLOAT */
  4527. static readonly TEXTURETYPE_FLOAT: number;
  4528. /** HALF_FLOAT */
  4529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4530. /** BYTE */
  4531. static readonly TEXTURETYPE_BYTE: number;
  4532. /** SHORT */
  4533. static readonly TEXTURETYPE_SHORT: number;
  4534. /** UNSIGNED_SHORT */
  4535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4536. /** INT */
  4537. static readonly TEXTURETYPE_INT: number;
  4538. /** UNSIGNED_INT */
  4539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4540. /** UNSIGNED_SHORT_4_4_4_4 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4542. /** UNSIGNED_SHORT_5_5_5_1 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4544. /** UNSIGNED_SHORT_5_6_5 */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4546. /** UNSIGNED_INT_2_10_10_10_REV */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4548. /** UNSIGNED_INT_24_8 */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4550. /** UNSIGNED_INT_10F_11F_11F_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4552. /** UNSIGNED_INT_5_9_9_9_REV */
  4553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4556. /** nearest is mag = nearest and min = nearest and mip = linear */
  4557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4560. /** Trilinear is mag = linear and min = linear and mip = linear */
  4561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4562. /** nearest is mag = nearest and min = nearest and mip = linear */
  4563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4566. /** Trilinear is mag = linear and min = linear and mip = linear */
  4567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4568. /** mag = nearest and min = nearest and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = nearest */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4572. /** mag = nearest and min = linear and mip = linear */
  4573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4574. /** mag = nearest and min = linear and mip = none */
  4575. static readonly TEXTURE_NEAREST_LINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = none */
  4577. static readonly TEXTURE_NEAREST_NEAREST: number;
  4578. /** mag = linear and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4580. /** mag = linear and min = nearest and mip = linear */
  4581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4582. /** mag = linear and min = linear and mip = none */
  4583. static readonly TEXTURE_LINEAR_LINEAR: number;
  4584. /** mag = linear and min = nearest and mip = none */
  4585. static readonly TEXTURE_LINEAR_NEAREST: number;
  4586. /** Explicit coordinates mode */
  4587. static readonly TEXTURE_EXPLICIT_MODE: number;
  4588. /** Spherical coordinates mode */
  4589. static readonly TEXTURE_SPHERICAL_MODE: number;
  4590. /** Planar coordinates mode */
  4591. static readonly TEXTURE_PLANAR_MODE: number;
  4592. /** Cubic coordinates mode */
  4593. static readonly TEXTURE_CUBIC_MODE: number;
  4594. /** Projection coordinates mode */
  4595. static readonly TEXTURE_PROJECTION_MODE: number;
  4596. /** Skybox coordinates mode */
  4597. static readonly TEXTURE_SKYBOX_MODE: number;
  4598. /** Inverse Cubic coordinates mode */
  4599. static readonly TEXTURE_INVCUBIC_MODE: number;
  4600. /** Equirectangular coordinates mode */
  4601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4604. /** Equirectangular Fixed Mirrored coordinates mode */
  4605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4607. static readonly SCALEMODE_FLOOR: number;
  4608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4609. static readonly SCALEMODE_NEAREST: number;
  4610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4611. static readonly SCALEMODE_CEILING: number;
  4612. /**
  4613. * The dirty texture flag value
  4614. */
  4615. static readonly MATERIAL_TextureDirtyFlag: number;
  4616. /**
  4617. * The dirty light flag value
  4618. */
  4619. static readonly MATERIAL_LightDirtyFlag: number;
  4620. /**
  4621. * The dirty fresnel flag value
  4622. */
  4623. static readonly MATERIAL_FresnelDirtyFlag: number;
  4624. /**
  4625. * The dirty attribute flag value
  4626. */
  4627. static readonly MATERIAL_AttributesDirtyFlag: number;
  4628. /**
  4629. * The dirty misc flag value
  4630. */
  4631. static readonly MATERIAL_MiscDirtyFlag: number;
  4632. /**
  4633. * The all dirty flag value
  4634. */
  4635. static readonly MATERIAL_AllDirtyFlag: number;
  4636. /**
  4637. * Returns the triangle fill mode
  4638. */
  4639. static readonly MATERIAL_TriangleFillMode: number;
  4640. /**
  4641. * Returns the wireframe mode
  4642. */
  4643. static readonly MATERIAL_WireFrameFillMode: number;
  4644. /**
  4645. * Returns the point fill mode
  4646. */
  4647. static readonly MATERIAL_PointFillMode: number;
  4648. /**
  4649. * Returns the point list draw mode
  4650. */
  4651. static readonly MATERIAL_PointListDrawMode: number;
  4652. /**
  4653. * Returns the line list draw mode
  4654. */
  4655. static readonly MATERIAL_LineListDrawMode: number;
  4656. /**
  4657. * Returns the line loop draw mode
  4658. */
  4659. static readonly MATERIAL_LineLoopDrawMode: number;
  4660. /**
  4661. * Returns the line strip draw mode
  4662. */
  4663. static readonly MATERIAL_LineStripDrawMode: number;
  4664. /**
  4665. * Returns the triangle strip draw mode
  4666. */
  4667. static readonly MATERIAL_TriangleStripDrawMode: number;
  4668. /**
  4669. * Returns the triangle fan draw mode
  4670. */
  4671. static readonly MATERIAL_TriangleFanDrawMode: number;
  4672. /**
  4673. * Stores the clock-wise side orientation
  4674. */
  4675. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4676. /**
  4677. * Stores the counter clock-wise side orientation
  4678. */
  4679. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4680. /**
  4681. * Nothing
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_NothingTrigger: number;
  4685. /**
  4686. * On pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnPickTrigger: number;
  4690. /**
  4691. * On left pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnLeftPickTrigger: number;
  4695. /**
  4696. * On right pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnRightPickTrigger: number;
  4700. /**
  4701. * On center pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnCenterPickTrigger: number;
  4705. /**
  4706. * On pick down
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnPickDownTrigger: number;
  4710. /**
  4711. * On double pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnDoublePickTrigger: number;
  4715. /**
  4716. * On pick up
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickUpTrigger: number;
  4720. /**
  4721. * On pick out.
  4722. * This trigger will only be raised if you also declared a OnPickDown
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnPickOutTrigger: number;
  4726. /**
  4727. * On long press
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnLongPressTrigger: number;
  4731. /**
  4732. * On pointer over
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOverTrigger: number;
  4736. /**
  4737. * On pointer out
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOutTrigger: number;
  4741. /**
  4742. * On every frame
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnEveryFrameTrigger: number;
  4746. /**
  4747. * On intersection enter
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4751. /**
  4752. * On intersection exit
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionExitTrigger: number;
  4756. /**
  4757. * On key down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyDownTrigger: number;
  4761. /**
  4762. * On key up
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyUpTrigger: number;
  4766. /**
  4767. * Billboard mode will only apply to Y axis
  4768. */
  4769. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4770. /**
  4771. * Billboard mode will apply to all axes
  4772. */
  4773. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4774. /**
  4775. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4778. /**
  4779. * Gets or sets base Assets URL
  4780. */
  4781. static readonly PARTICLES_BaseAssetsUrl: string;
  4782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4783. * Test order :
  4784. * Is the bounding sphere outside the frustum ?
  4785. * If not, are the bounding box vertices outside the frustum ?
  4786. * It not, then the cullable object is in the frustum.
  4787. */
  4788. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4789. /** Culling strategy : Bounding Sphere Only.
  4790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4791. * It's also less accurate than the standard because some not visible objects can still be selected.
  4792. * Test : is the bounding sphere outside the frustum ?
  4793. * If not, then the cullable object is in the frustum.
  4794. */
  4795. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4796. /** Culling strategy : Optimistic Inclusion.
  4797. * This in an inclusion test first, then the standard exclusion test.
  4798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4799. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4800. * Anyway, it's as accurate as the standard strategy.
  4801. * Test :
  4802. * Is the cullable object bounding sphere center in the frustum ?
  4803. * If not, apply the default culling strategy.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4809. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4816. /**
  4817. * No logging while loading
  4818. */
  4819. static readonly SCENELOADER_NO_LOGGING: number;
  4820. /**
  4821. * Minimal logging while loading
  4822. */
  4823. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4824. /**
  4825. * Summary logging while loading
  4826. */
  4827. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4828. /**
  4829. * Detailled logging while loading
  4830. */
  4831. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4832. }
  4833. }
  4834. declare module "babylonjs/Misc/domManagement" {
  4835. /**
  4836. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4837. * Babylon.js
  4838. */
  4839. export class DomManagement {
  4840. /**
  4841. * Checks if the window object exists
  4842. * @returns true if the window object exists
  4843. */
  4844. static IsWindowObjectExist(): boolean;
  4845. /**
  4846. * Extracts text content from a DOM element hierarchy
  4847. * @param element defines the root element
  4848. * @returns a string
  4849. */
  4850. static GetDOMTextContent(element: HTMLElement): string;
  4851. }
  4852. }
  4853. declare module "babylonjs/Misc/logger" {
  4854. /**
  4855. * Logger used througouht the application to allow configuration of
  4856. * the log level required for the messages.
  4857. */
  4858. export class Logger {
  4859. /**
  4860. * No log
  4861. */
  4862. static readonly NoneLogLevel: number;
  4863. /**
  4864. * Only message logs
  4865. */
  4866. static readonly MessageLogLevel: number;
  4867. /**
  4868. * Only warning logs
  4869. */
  4870. static readonly WarningLogLevel: number;
  4871. /**
  4872. * Only error logs
  4873. */
  4874. static readonly ErrorLogLevel: number;
  4875. /**
  4876. * All logs
  4877. */
  4878. static readonly AllLogLevel: number;
  4879. private static _LogCache;
  4880. /**
  4881. * Gets a value indicating the number of loading errors
  4882. * @ignorenaming
  4883. */
  4884. static errorsCount: number;
  4885. /**
  4886. * Callback called when a new log is added
  4887. */
  4888. static OnNewCacheEntry: (entry: string) => void;
  4889. private static _AddLogEntry;
  4890. private static _FormatMessage;
  4891. private static _LogDisabled;
  4892. private static _LogEnabled;
  4893. private static _WarnDisabled;
  4894. private static _WarnEnabled;
  4895. private static _ErrorDisabled;
  4896. private static _ErrorEnabled;
  4897. /**
  4898. * Log a message to the console
  4899. */
  4900. static Log: (message: string) => void;
  4901. /**
  4902. * Write a warning message to the console
  4903. */
  4904. static Warn: (message: string) => void;
  4905. /**
  4906. * Write an error message to the console
  4907. */
  4908. static Error: (message: string) => void;
  4909. /**
  4910. * Gets current log cache (list of logs)
  4911. */
  4912. static readonly LogCache: string;
  4913. /**
  4914. * Clears the log cache
  4915. */
  4916. static ClearLogCache(): void;
  4917. /**
  4918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4919. */
  4920. static LogLevels: number;
  4921. }
  4922. }
  4923. declare module "babylonjs/Misc/typeStore" {
  4924. /** @hidden */
  4925. export class _TypeStore {
  4926. /** @hidden */
  4927. static RegisteredTypes: {
  4928. [key: string]: Object;
  4929. };
  4930. /** @hidden */
  4931. static GetClass(fqdn: string): any;
  4932. }
  4933. }
  4934. declare module "babylonjs/Misc/deepCopier" {
  4935. /**
  4936. * Class containing a set of static utilities functions for deep copy.
  4937. */
  4938. export class DeepCopier {
  4939. /**
  4940. * Tries to copy an object by duplicating every property
  4941. * @param source defines the source object
  4942. * @param destination defines the target object
  4943. * @param doNotCopyList defines a list of properties to avoid
  4944. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4945. */
  4946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4947. }
  4948. }
  4949. declare module "babylonjs/Misc/precisionDate" {
  4950. /**
  4951. * Class containing a set of static utilities functions for precision date
  4952. */
  4953. export class PrecisionDate {
  4954. /**
  4955. * Gets either window.performance.now() if supported or Date.now() else
  4956. */
  4957. static readonly Now: number;
  4958. }
  4959. }
  4960. declare module "babylonjs/Misc/devTools" {
  4961. /** @hidden */
  4962. export class _DevTools {
  4963. static WarnImport(name: string): string;
  4964. }
  4965. }
  4966. declare module "babylonjs/Misc/andOrNotEvaluator" {
  4967. /**
  4968. * Class used to evalaute queries containing `and` and `or` operators
  4969. */
  4970. export class AndOrNotEvaluator {
  4971. /**
  4972. * Evaluate a query
  4973. * @param query defines the query to evaluate
  4974. * @param evaluateCallback defines the callback used to filter result
  4975. * @returns true if the query matches
  4976. */
  4977. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4978. private static _HandleParenthesisContent;
  4979. private static _SimplifyNegation;
  4980. }
  4981. }
  4982. declare module "babylonjs/Misc/tags" {
  4983. /**
  4984. * Class used to store custom tags
  4985. */
  4986. export class Tags {
  4987. /**
  4988. * Adds support for tags on the given object
  4989. * @param obj defines the object to use
  4990. */
  4991. static EnableFor(obj: any): void;
  4992. /**
  4993. * Removes tags support
  4994. * @param obj defines the object to use
  4995. */
  4996. static DisableFor(obj: any): void;
  4997. /**
  4998. * Gets a boolean indicating if the given object has tags
  4999. * @param obj defines the object to use
  5000. * @returns a boolean
  5001. */
  5002. static HasTags(obj: any): boolean;
  5003. /**
  5004. * Gets the tags available on a given object
  5005. * @param obj defines the object to use
  5006. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5007. * @returns the tags
  5008. */
  5009. static GetTags(obj: any, asString?: boolean): any;
  5010. /**
  5011. * Adds tags to an object
  5012. * @param obj defines the object to use
  5013. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5014. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5015. */
  5016. static AddTagsTo(obj: any, tagsString: string): void;
  5017. /**
  5018. * @hidden
  5019. */
  5020. static _AddTagTo(obj: any, tag: string): void;
  5021. /**
  5022. * Removes specific tags from a specific object
  5023. * @param obj defines the object to use
  5024. * @param tagsString defines the tags to remove
  5025. */
  5026. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5027. /**
  5028. * @hidden
  5029. */
  5030. static _RemoveTagFrom(obj: any, tag: string): void;
  5031. /**
  5032. * Defines if tags hosted on an object match a given query
  5033. * @param obj defines the object to use
  5034. * @param tagsQuery defines the tag query
  5035. * @returns a boolean
  5036. */
  5037. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5038. }
  5039. }
  5040. declare module "babylonjs/Materials/materialDefines" {
  5041. /**
  5042. * Manages the defines for the Material
  5043. */
  5044. export class MaterialDefines {
  5045. private _keys;
  5046. private _isDirty;
  5047. /** @hidden */
  5048. _renderId: number;
  5049. /** @hidden */
  5050. _areLightsDirty: boolean;
  5051. /** @hidden */
  5052. _areAttributesDirty: boolean;
  5053. /** @hidden */
  5054. _areTexturesDirty: boolean;
  5055. /** @hidden */
  5056. _areFresnelDirty: boolean;
  5057. /** @hidden */
  5058. _areMiscDirty: boolean;
  5059. /** @hidden */
  5060. _areImageProcessingDirty: boolean;
  5061. /** @hidden */
  5062. _normals: boolean;
  5063. /** @hidden */
  5064. _uvs: boolean;
  5065. /** @hidden */
  5066. _needNormals: boolean;
  5067. /** @hidden */
  5068. _needUVs: boolean;
  5069. /**
  5070. * Specifies if the material needs to be re-calculated
  5071. */
  5072. readonly isDirty: boolean;
  5073. /**
  5074. * Marks the material to indicate that it has been re-calculated
  5075. */
  5076. markAsProcessed(): void;
  5077. /**
  5078. * Marks the material to indicate that it needs to be re-calculated
  5079. */
  5080. markAsUnprocessed(): void;
  5081. /**
  5082. * Marks the material to indicate all of its defines need to be re-calculated
  5083. */
  5084. markAllAsDirty(): void;
  5085. /**
  5086. * Marks the material to indicate that image processing needs to be re-calculated
  5087. */
  5088. markAsImageProcessingDirty(): void;
  5089. /**
  5090. * Marks the material to indicate the lights need to be re-calculated
  5091. */
  5092. markAsLightDirty(): void;
  5093. /**
  5094. * Marks the attribute state as changed
  5095. */
  5096. markAsAttributesDirty(): void;
  5097. /**
  5098. * Marks the texture state as changed
  5099. */
  5100. markAsTexturesDirty(): void;
  5101. /**
  5102. * Marks the fresnel state as changed
  5103. */
  5104. markAsFresnelDirty(): void;
  5105. /**
  5106. * Marks the misc state as changed
  5107. */
  5108. markAsMiscDirty(): void;
  5109. /**
  5110. * Rebuilds the material defines
  5111. */
  5112. rebuild(): void;
  5113. /**
  5114. * Specifies if two material defines are equal
  5115. * @param other - A material define instance to compare to
  5116. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5117. */
  5118. isEqual(other: MaterialDefines): boolean;
  5119. /**
  5120. * Clones this instance's defines to another instance
  5121. * @param other - material defines to clone values to
  5122. */
  5123. cloneTo(other: MaterialDefines): void;
  5124. /**
  5125. * Resets the material define values
  5126. */
  5127. reset(): void;
  5128. /**
  5129. * Converts the material define values to a string
  5130. * @returns - String of material define information
  5131. */
  5132. toString(): string;
  5133. }
  5134. }
  5135. declare module "babylonjs/Misc/performanceMonitor" {
  5136. /**
  5137. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5138. */
  5139. export class PerformanceMonitor {
  5140. private _enabled;
  5141. private _rollingFrameTime;
  5142. private _lastFrameTimeMs;
  5143. /**
  5144. * constructor
  5145. * @param frameSampleSize The number of samples required to saturate the sliding window
  5146. */
  5147. constructor(frameSampleSize?: number);
  5148. /**
  5149. * Samples current frame
  5150. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5151. */
  5152. sampleFrame(timeMs?: number): void;
  5153. /**
  5154. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5155. */
  5156. readonly averageFrameTime: number;
  5157. /**
  5158. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5159. */
  5160. readonly averageFrameTimeVariance: number;
  5161. /**
  5162. * Returns the frame time of the most recent frame
  5163. */
  5164. readonly instantaneousFrameTime: number;
  5165. /**
  5166. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5167. */
  5168. readonly averageFPS: number;
  5169. /**
  5170. * Returns the average framerate in frames per second using the most recent frame time
  5171. */
  5172. readonly instantaneousFPS: number;
  5173. /**
  5174. * Returns true if enough samples have been taken to completely fill the sliding window
  5175. */
  5176. readonly isSaturated: boolean;
  5177. /**
  5178. * Enables contributions to the sliding window sample set
  5179. */
  5180. enable(): void;
  5181. /**
  5182. * Disables contributions to the sliding window sample set
  5183. * Samples will not be interpolated over the disabled period
  5184. */
  5185. disable(): void;
  5186. /**
  5187. * Returns true if sampling is enabled
  5188. */
  5189. readonly isEnabled: boolean;
  5190. /**
  5191. * Resets performance monitor
  5192. */
  5193. reset(): void;
  5194. }
  5195. /**
  5196. * RollingAverage
  5197. *
  5198. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5199. */
  5200. export class RollingAverage {
  5201. /**
  5202. * Current average
  5203. */
  5204. average: number;
  5205. /**
  5206. * Current variance
  5207. */
  5208. variance: number;
  5209. protected _samples: Array<number>;
  5210. protected _sampleCount: number;
  5211. protected _pos: number;
  5212. protected _m2: number;
  5213. /**
  5214. * constructor
  5215. * @param length The number of samples required to saturate the sliding window
  5216. */
  5217. constructor(length: number);
  5218. /**
  5219. * Adds a sample to the sample set
  5220. * @param v The sample value
  5221. */
  5222. add(v: number): void;
  5223. /**
  5224. * Returns previously added values or null if outside of history or outside the sliding window domain
  5225. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5226. * @return Value previously recorded with add() or null if outside of range
  5227. */
  5228. history(i: number): number;
  5229. /**
  5230. * Returns true if enough samples have been taken to completely fill the sliding window
  5231. * @return true if sample-set saturated
  5232. */
  5233. isSaturated(): boolean;
  5234. /**
  5235. * Resets the rolling average (equivalent to 0 samples taken so far)
  5236. */
  5237. reset(): void;
  5238. /**
  5239. * Wraps a value around the sample range boundaries
  5240. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5241. * @return Wrapped position in sample range
  5242. */
  5243. protected _wrapPosition(i: number): number;
  5244. }
  5245. }
  5246. declare module "babylonjs/Misc/stringDictionary" {
  5247. import { Nullable } from "babylonjs/types";
  5248. /**
  5249. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5250. * The underlying implementation relies on an associative array to ensure the best performances.
  5251. * The value can be anything including 'null' but except 'undefined'
  5252. */
  5253. export class StringDictionary<T> {
  5254. /**
  5255. * This will clear this dictionary and copy the content from the 'source' one.
  5256. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5257. * @param source the dictionary to take the content from and copy to this dictionary
  5258. */
  5259. copyFrom(source: StringDictionary<T>): void;
  5260. /**
  5261. * Get a value based from its key
  5262. * @param key the given key to get the matching value from
  5263. * @return the value if found, otherwise undefined is returned
  5264. */
  5265. get(key: string): T | undefined;
  5266. /**
  5267. * Get a value from its key or add it if it doesn't exist.
  5268. * This method will ensure you that a given key/data will be present in the dictionary.
  5269. * @param key the given key to get the matching value from
  5270. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5271. * The factory will only be invoked if there's no data for the given key.
  5272. * @return the value corresponding to the key.
  5273. */
  5274. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5275. /**
  5276. * Get a value from its key if present in the dictionary otherwise add it
  5277. * @param key the key to get the value from
  5278. * @param val if there's no such key/value pair in the dictionary add it with this value
  5279. * @return the value corresponding to the key
  5280. */
  5281. getOrAdd(key: string, val: T): T;
  5282. /**
  5283. * Check if there's a given key in the dictionary
  5284. * @param key the key to check for
  5285. * @return true if the key is present, false otherwise
  5286. */
  5287. contains(key: string): boolean;
  5288. /**
  5289. * Add a new key and its corresponding value
  5290. * @param key the key to add
  5291. * @param value the value corresponding to the key
  5292. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5293. */
  5294. add(key: string, value: T): boolean;
  5295. /**
  5296. * Update a specific value associated to a key
  5297. * @param key defines the key to use
  5298. * @param value defines the value to store
  5299. * @returns true if the value was updated (or false if the key was not found)
  5300. */
  5301. set(key: string, value: T): boolean;
  5302. /**
  5303. * Get the element of the given key and remove it from the dictionary
  5304. * @param key defines the key to search
  5305. * @returns the value associated with the key or null if not found
  5306. */
  5307. getAndRemove(key: string): Nullable<T>;
  5308. /**
  5309. * Remove a key/value from the dictionary.
  5310. * @param key the key to remove
  5311. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5312. */
  5313. remove(key: string): boolean;
  5314. /**
  5315. * Clear the whole content of the dictionary
  5316. */
  5317. clear(): void;
  5318. /**
  5319. * Gets the current count
  5320. */
  5321. readonly count: number;
  5322. /**
  5323. * Execute a callback on each key/val of the dictionary.
  5324. * Note that you can remove any element in this dictionary in the callback implementation
  5325. * @param callback the callback to execute on a given key/value pair
  5326. */
  5327. forEach(callback: (key: string, val: T) => void): void;
  5328. /**
  5329. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5330. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5331. * Note that you can remove any element in this dictionary in the callback implementation
  5332. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5333. * @returns the first item
  5334. */
  5335. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5336. private _count;
  5337. private _data;
  5338. }
  5339. }
  5340. declare module "babylonjs/Misc/promise" {
  5341. /**
  5342. * Helper class that provides a small promise polyfill
  5343. */
  5344. export class PromisePolyfill {
  5345. /**
  5346. * Static function used to check if the polyfill is required
  5347. * If this is the case then the function will inject the polyfill to window.Promise
  5348. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5349. */
  5350. static Apply(force?: boolean): void;
  5351. }
  5352. }
  5353. declare module "babylonjs/Meshes/buffer" {
  5354. import { Nullable, DataArray } from "babylonjs/types";
  5355. /**
  5356. * Class used to store data that will be store in GPU memory
  5357. */
  5358. export class Buffer {
  5359. private _engine;
  5360. private _buffer;
  5361. /** @hidden */
  5362. _data: Nullable<DataArray>;
  5363. private _updatable;
  5364. private _instanced;
  5365. /**
  5366. * Gets the byte stride.
  5367. */
  5368. readonly byteStride: number;
  5369. /**
  5370. * Constructor
  5371. * @param engine the engine
  5372. * @param data the data to use for this buffer
  5373. * @param updatable whether the data is updatable
  5374. * @param stride the stride (optional)
  5375. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5376. * @param instanced whether the buffer is instanced (optional)
  5377. * @param useBytes set to true if the stride in in bytes (optional)
  5378. */
  5379. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5380. /**
  5381. * Create a new VertexBuffer based on the current buffer
  5382. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5383. * @param offset defines offset in the buffer (0 by default)
  5384. * @param size defines the size in floats of attributes (position is 3 for instance)
  5385. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5386. * @param instanced defines if the vertex buffer contains indexed data
  5387. * @param useBytes defines if the offset and stride are in bytes
  5388. * @returns the new vertex buffer
  5389. */
  5390. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5391. /**
  5392. * Gets a boolean indicating if the Buffer is updatable?
  5393. * @returns true if the buffer is updatable
  5394. */
  5395. isUpdatable(): boolean;
  5396. /**
  5397. * Gets current buffer's data
  5398. * @returns a DataArray or null
  5399. */
  5400. getData(): Nullable<DataArray>;
  5401. /**
  5402. * Gets underlying native buffer
  5403. * @returns underlying native buffer
  5404. */
  5405. getBuffer(): Nullable<WebGLBuffer>;
  5406. /**
  5407. * Gets the stride in float32 units (i.e. byte stride / 4).
  5408. * May not be an integer if the byte stride is not divisible by 4.
  5409. * DEPRECATED. Use byteStride instead.
  5410. * @returns the stride in float32 units
  5411. */
  5412. getStrideSize(): number;
  5413. /**
  5414. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5415. * @param data defines the data to store
  5416. */
  5417. create(data?: Nullable<DataArray>): void;
  5418. /** @hidden */
  5419. _rebuild(): void;
  5420. /**
  5421. * Update current buffer data
  5422. * @param data defines the data to store
  5423. */
  5424. update(data: DataArray): void;
  5425. /**
  5426. * Updates the data directly.
  5427. * @param data the new data
  5428. * @param offset the new offset
  5429. * @param vertexCount the vertex count (optional)
  5430. * @param useBytes set to true if the offset is in bytes
  5431. */
  5432. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5433. /**
  5434. * Release all resources
  5435. */
  5436. dispose(): void;
  5437. }
  5438. /**
  5439. * Specialized buffer used to store vertex data
  5440. */
  5441. export class VertexBuffer {
  5442. /** @hidden */
  5443. _buffer: Buffer;
  5444. private _kind;
  5445. private _size;
  5446. private _ownsBuffer;
  5447. private _instanced;
  5448. private _instanceDivisor;
  5449. /**
  5450. * The byte type.
  5451. */
  5452. static readonly BYTE: number;
  5453. /**
  5454. * The unsigned byte type.
  5455. */
  5456. static readonly UNSIGNED_BYTE: number;
  5457. /**
  5458. * The short type.
  5459. */
  5460. static readonly SHORT: number;
  5461. /**
  5462. * The unsigned short type.
  5463. */
  5464. static readonly UNSIGNED_SHORT: number;
  5465. /**
  5466. * The integer type.
  5467. */
  5468. static readonly INT: number;
  5469. /**
  5470. * The unsigned integer type.
  5471. */
  5472. static readonly UNSIGNED_INT: number;
  5473. /**
  5474. * The float type.
  5475. */
  5476. static readonly FLOAT: number;
  5477. /**
  5478. * Gets or sets the instance divisor when in instanced mode
  5479. */
  5480. instanceDivisor: number;
  5481. /**
  5482. * Gets the byte stride.
  5483. */
  5484. readonly byteStride: number;
  5485. /**
  5486. * Gets the byte offset.
  5487. */
  5488. readonly byteOffset: number;
  5489. /**
  5490. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5491. */
  5492. readonly normalized: boolean;
  5493. /**
  5494. * Gets the data type of each component in the array.
  5495. */
  5496. readonly type: number;
  5497. /**
  5498. * Constructor
  5499. * @param engine the engine
  5500. * @param data the data to use for this vertex buffer
  5501. * @param kind the vertex buffer kind
  5502. * @param updatable whether the data is updatable
  5503. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5504. * @param stride the stride (optional)
  5505. * @param instanced whether the buffer is instanced (optional)
  5506. * @param offset the offset of the data (optional)
  5507. * @param size the number of components (optional)
  5508. * @param type the type of the component (optional)
  5509. * @param normalized whether the data contains normalized data (optional)
  5510. * @param useBytes set to true if stride and offset are in bytes (optional)
  5511. */
  5512. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5513. /** @hidden */
  5514. _rebuild(): void;
  5515. /**
  5516. * Returns the kind of the VertexBuffer (string)
  5517. * @returns a string
  5518. */
  5519. getKind(): string;
  5520. /**
  5521. * Gets a boolean indicating if the VertexBuffer is updatable?
  5522. * @returns true if the buffer is updatable
  5523. */
  5524. isUpdatable(): boolean;
  5525. /**
  5526. * Gets current buffer's data
  5527. * @returns a DataArray or null
  5528. */
  5529. getData(): Nullable<DataArray>;
  5530. /**
  5531. * Gets underlying native buffer
  5532. * @returns underlying native buffer
  5533. */
  5534. getBuffer(): Nullable<WebGLBuffer>;
  5535. /**
  5536. * Gets the stride in float32 units (i.e. byte stride / 4).
  5537. * May not be an integer if the byte stride is not divisible by 4.
  5538. * DEPRECATED. Use byteStride instead.
  5539. * @returns the stride in float32 units
  5540. */
  5541. getStrideSize(): number;
  5542. /**
  5543. * Returns the offset as a multiple of the type byte length.
  5544. * DEPRECATED. Use byteOffset instead.
  5545. * @returns the offset in bytes
  5546. */
  5547. getOffset(): number;
  5548. /**
  5549. * Returns the number of components per vertex attribute (integer)
  5550. * @returns the size in float
  5551. */
  5552. getSize(): number;
  5553. /**
  5554. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5555. * @returns true if this buffer is instanced
  5556. */
  5557. getIsInstanced(): boolean;
  5558. /**
  5559. * Returns the instancing divisor, zero for non-instanced (integer).
  5560. * @returns a number
  5561. */
  5562. getInstanceDivisor(): number;
  5563. /**
  5564. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5565. * @param data defines the data to store
  5566. */
  5567. create(data?: DataArray): void;
  5568. /**
  5569. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5570. * This function will create a new buffer if the current one is not updatable
  5571. * @param data defines the data to store
  5572. */
  5573. update(data: DataArray): void;
  5574. /**
  5575. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5576. * Returns the directly updated WebGLBuffer.
  5577. * @param data the new data
  5578. * @param offset the new offset
  5579. * @param useBytes set to true if the offset is in bytes
  5580. */
  5581. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5582. /**
  5583. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5584. */
  5585. dispose(): void;
  5586. /**
  5587. * Enumerates each value of this vertex buffer as numbers.
  5588. * @param count the number of values to enumerate
  5589. * @param callback the callback function called for each value
  5590. */
  5591. forEach(count: number, callback: (value: number, index: number) => void): void;
  5592. /**
  5593. * Positions
  5594. */
  5595. static readonly PositionKind: string;
  5596. /**
  5597. * Normals
  5598. */
  5599. static readonly NormalKind: string;
  5600. /**
  5601. * Tangents
  5602. */
  5603. static readonly TangentKind: string;
  5604. /**
  5605. * Texture coordinates
  5606. */
  5607. static readonly UVKind: string;
  5608. /**
  5609. * Texture coordinates 2
  5610. */
  5611. static readonly UV2Kind: string;
  5612. /**
  5613. * Texture coordinates 3
  5614. */
  5615. static readonly UV3Kind: string;
  5616. /**
  5617. * Texture coordinates 4
  5618. */
  5619. static readonly UV4Kind: string;
  5620. /**
  5621. * Texture coordinates 5
  5622. */
  5623. static readonly UV5Kind: string;
  5624. /**
  5625. * Texture coordinates 6
  5626. */
  5627. static readonly UV6Kind: string;
  5628. /**
  5629. * Colors
  5630. */
  5631. static readonly ColorKind: string;
  5632. /**
  5633. * Matrix indices (for bones)
  5634. */
  5635. static readonly MatricesIndicesKind: string;
  5636. /**
  5637. * Matrix weights (for bones)
  5638. */
  5639. static readonly MatricesWeightsKind: string;
  5640. /**
  5641. * Additional matrix indices (for bones)
  5642. */
  5643. static readonly MatricesIndicesExtraKind: string;
  5644. /**
  5645. * Additional matrix weights (for bones)
  5646. */
  5647. static readonly MatricesWeightsExtraKind: string;
  5648. /**
  5649. * Deduces the stride given a kind.
  5650. * @param kind The kind string to deduce
  5651. * @returns The deduced stride
  5652. */
  5653. static DeduceStride(kind: string): number;
  5654. /**
  5655. * Gets the byte length of the given type.
  5656. * @param type the type
  5657. * @returns the number of bytes
  5658. */
  5659. static GetTypeByteLength(type: number): number;
  5660. /**
  5661. * Enumerates each value of the given parameters as numbers.
  5662. * @param data the data to enumerate
  5663. * @param byteOffset the byte offset of the data
  5664. * @param byteStride the byte stride of the data
  5665. * @param componentCount the number of components per element
  5666. * @param componentType the type of the component
  5667. * @param count the total number of components
  5668. * @param normalized whether the data is normalized
  5669. * @param callback the callback function called for each value
  5670. */
  5671. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5672. private static _GetFloatValue;
  5673. }
  5674. }
  5675. declare module "babylonjs/Maths/sphericalPolynomial" {
  5676. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5677. /**
  5678. * Class representing spherical polynomial coefficients to the 3rd degree
  5679. */
  5680. export class SphericalPolynomial {
  5681. /**
  5682. * The x coefficients of the spherical polynomial
  5683. */
  5684. x: Vector3;
  5685. /**
  5686. * The y coefficients of the spherical polynomial
  5687. */
  5688. y: Vector3;
  5689. /**
  5690. * The z coefficients of the spherical polynomial
  5691. */
  5692. z: Vector3;
  5693. /**
  5694. * The xx coefficients of the spherical polynomial
  5695. */
  5696. xx: Vector3;
  5697. /**
  5698. * The yy coefficients of the spherical polynomial
  5699. */
  5700. yy: Vector3;
  5701. /**
  5702. * The zz coefficients of the spherical polynomial
  5703. */
  5704. zz: Vector3;
  5705. /**
  5706. * The xy coefficients of the spherical polynomial
  5707. */
  5708. xy: Vector3;
  5709. /**
  5710. * The yz coefficients of the spherical polynomial
  5711. */
  5712. yz: Vector3;
  5713. /**
  5714. * The zx coefficients of the spherical polynomial
  5715. */
  5716. zx: Vector3;
  5717. /**
  5718. * Adds an ambient color to the spherical polynomial
  5719. * @param color the color to add
  5720. */
  5721. addAmbient(color: Color3): void;
  5722. /**
  5723. * Scales the spherical polynomial by the given amount
  5724. * @param scale the amount to scale
  5725. */
  5726. scale(scale: number): void;
  5727. /**
  5728. * Gets the spherical polynomial from harmonics
  5729. * @param harmonics the spherical harmonics
  5730. * @returns the spherical polynomial
  5731. */
  5732. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5733. /**
  5734. * Constructs a spherical polynomial from an array.
  5735. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5736. * @returns the spherical polynomial
  5737. */
  5738. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5739. }
  5740. /**
  5741. * Class representing spherical harmonics coefficients to the 3rd degree
  5742. */
  5743. export class SphericalHarmonics {
  5744. /**
  5745. * The l0,0 coefficients of the spherical harmonics
  5746. */
  5747. l00: Vector3;
  5748. /**
  5749. * The l1,-1 coefficients of the spherical harmonics
  5750. */
  5751. l1_1: Vector3;
  5752. /**
  5753. * The l1,0 coefficients of the spherical harmonics
  5754. */
  5755. l10: Vector3;
  5756. /**
  5757. * The l1,1 coefficients of the spherical harmonics
  5758. */
  5759. l11: Vector3;
  5760. /**
  5761. * The l2,-2 coefficients of the spherical harmonics
  5762. */
  5763. l2_2: Vector3;
  5764. /**
  5765. * The l2,-1 coefficients of the spherical harmonics
  5766. */
  5767. l2_1: Vector3;
  5768. /**
  5769. * The l2,0 coefficients of the spherical harmonics
  5770. */
  5771. l20: Vector3;
  5772. /**
  5773. * The l2,1 coefficients of the spherical harmonics
  5774. */
  5775. l21: Vector3;
  5776. /**
  5777. * The l2,2 coefficients of the spherical harmonics
  5778. */
  5779. lL22: Vector3;
  5780. /**
  5781. * Adds a light to the spherical harmonics
  5782. * @param direction the direction of the light
  5783. * @param color the color of the light
  5784. * @param deltaSolidAngle the delta solid angle of the light
  5785. */
  5786. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5787. /**
  5788. * Scales the spherical harmonics by the given amount
  5789. * @param scale the amount to scale
  5790. */
  5791. scale(scale: number): void;
  5792. /**
  5793. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5794. *
  5795. * ```
  5796. * E_lm = A_l * L_lm
  5797. * ```
  5798. *
  5799. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5800. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5801. * the scaling factors are given in equation 9.
  5802. */
  5803. convertIncidentRadianceToIrradiance(): void;
  5804. /**
  5805. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5806. *
  5807. * ```
  5808. * L = (1/pi) * E * rho
  5809. * ```
  5810. *
  5811. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5812. */
  5813. convertIrradianceToLambertianRadiance(): void;
  5814. /**
  5815. * Gets the spherical harmonics from polynomial
  5816. * @param polynomial the spherical polynomial
  5817. * @returns the spherical harmonics
  5818. */
  5819. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5820. /**
  5821. * Constructs a spherical harmonics from an array.
  5822. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5823. * @returns the spherical harmonics
  5824. */
  5825. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5826. }
  5827. }
  5828. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5829. import { Nullable } from "babylonjs/types";
  5830. /**
  5831. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5832. */
  5833. export interface CubeMapInfo {
  5834. /**
  5835. * The pixel array for the front face.
  5836. * This is stored in format, left to right, up to down format.
  5837. */
  5838. front: Nullable<ArrayBufferView>;
  5839. /**
  5840. * The pixel array for the back face.
  5841. * This is stored in format, left to right, up to down format.
  5842. */
  5843. back: Nullable<ArrayBufferView>;
  5844. /**
  5845. * The pixel array for the left face.
  5846. * This is stored in format, left to right, up to down format.
  5847. */
  5848. left: Nullable<ArrayBufferView>;
  5849. /**
  5850. * The pixel array for the right face.
  5851. * This is stored in format, left to right, up to down format.
  5852. */
  5853. right: Nullable<ArrayBufferView>;
  5854. /**
  5855. * The pixel array for the up face.
  5856. * This is stored in format, left to right, up to down format.
  5857. */
  5858. up: Nullable<ArrayBufferView>;
  5859. /**
  5860. * The pixel array for the down face.
  5861. * This is stored in format, left to right, up to down format.
  5862. */
  5863. down: Nullable<ArrayBufferView>;
  5864. /**
  5865. * The size of the cubemap stored.
  5866. *
  5867. * Each faces will be size * size pixels.
  5868. */
  5869. size: number;
  5870. /**
  5871. * The format of the texture.
  5872. *
  5873. * RGBA, RGB.
  5874. */
  5875. format: number;
  5876. /**
  5877. * The type of the texture data.
  5878. *
  5879. * UNSIGNED_INT, FLOAT.
  5880. */
  5881. type: number;
  5882. /**
  5883. * Specifies whether the texture is in gamma space.
  5884. */
  5885. gammaSpace: boolean;
  5886. }
  5887. /**
  5888. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5889. */
  5890. export class PanoramaToCubeMapTools {
  5891. private static FACE_FRONT;
  5892. private static FACE_BACK;
  5893. private static FACE_RIGHT;
  5894. private static FACE_LEFT;
  5895. private static FACE_DOWN;
  5896. private static FACE_UP;
  5897. /**
  5898. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5899. *
  5900. * @param float32Array The source data.
  5901. * @param inputWidth The width of the input panorama.
  5902. * @param inputHeight The height of the input panorama.
  5903. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5904. * @return The cubemap data
  5905. */
  5906. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5907. private static CreateCubemapTexture;
  5908. private static CalcProjectionSpherical;
  5909. }
  5910. }
  5911. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5912. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5914. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5915. /**
  5916. * Helper class dealing with the extraction of spherical polynomial dataArray
  5917. * from a cube map.
  5918. */
  5919. export class CubeMapToSphericalPolynomialTools {
  5920. private static FileFaces;
  5921. /**
  5922. * Converts a texture to the according Spherical Polynomial data.
  5923. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5924. *
  5925. * @param texture The texture to extract the information from.
  5926. * @return The Spherical Polynomial data.
  5927. */
  5928. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5929. /**
  5930. * Converts a cubemap to the according Spherical Polynomial data.
  5931. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5932. *
  5933. * @param cubeInfo The Cube map to extract the information from.
  5934. * @return The Spherical Polynomial data.
  5935. */
  5936. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5937. }
  5938. }
  5939. declare module "babylonjs/Engines/engineStore" {
  5940. import { Nullable } from "babylonjs/types";
  5941. import { Engine } from "babylonjs/Engines/engine";
  5942. import { Scene } from "babylonjs/scene";
  5943. /**
  5944. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5945. * during the life time of the application.
  5946. */
  5947. export class EngineStore {
  5948. /** Gets the list of created engines */
  5949. static Instances: import("babylonjs/Engines/engine").Engine[];
  5950. /**
  5951. * Gets the latest created engine
  5952. */
  5953. static readonly LastCreatedEngine: Nullable<Engine>;
  5954. /**
  5955. * Gets the latest created scene
  5956. */
  5957. static readonly LastCreatedScene: Nullable<Scene>;
  5958. }
  5959. }
  5960. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5961. /**
  5962. * Define options used to create a render target texture
  5963. */
  5964. export class RenderTargetCreationOptions {
  5965. /**
  5966. * Specifies is mipmaps must be generated
  5967. */
  5968. generateMipMaps?: boolean;
  5969. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5970. generateDepthBuffer?: boolean;
  5971. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5972. generateStencilBuffer?: boolean;
  5973. /** Defines texture type (int by default) */
  5974. type?: number;
  5975. /** Defines sampling mode (trilinear by default) */
  5976. samplingMode?: number;
  5977. /** Defines format (RGBA by default) */
  5978. format?: number;
  5979. }
  5980. }
  5981. declare module "babylonjs/States/alphaCullingState" {
  5982. /**
  5983. * @hidden
  5984. **/
  5985. export class _AlphaState {
  5986. private _isAlphaBlendDirty;
  5987. private _isBlendFunctionParametersDirty;
  5988. private _isBlendEquationParametersDirty;
  5989. private _isBlendConstantsDirty;
  5990. private _alphaBlend;
  5991. private _blendFunctionParameters;
  5992. private _blendEquationParameters;
  5993. private _blendConstants;
  5994. /**
  5995. * Initializes the state.
  5996. */
  5997. constructor();
  5998. readonly isDirty: boolean;
  5999. alphaBlend: boolean;
  6000. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6001. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6002. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6003. reset(): void;
  6004. apply(gl: WebGLRenderingContext): void;
  6005. }
  6006. }
  6007. declare module "babylonjs/States/depthCullingState" {
  6008. import { Nullable } from "babylonjs/types";
  6009. /**
  6010. * @hidden
  6011. **/
  6012. export class _DepthCullingState {
  6013. private _isDepthTestDirty;
  6014. private _isDepthMaskDirty;
  6015. private _isDepthFuncDirty;
  6016. private _isCullFaceDirty;
  6017. private _isCullDirty;
  6018. private _isZOffsetDirty;
  6019. private _isFrontFaceDirty;
  6020. private _depthTest;
  6021. private _depthMask;
  6022. private _depthFunc;
  6023. private _cull;
  6024. private _cullFace;
  6025. private _zOffset;
  6026. private _frontFace;
  6027. /**
  6028. * Initializes the state.
  6029. */
  6030. constructor();
  6031. readonly isDirty: boolean;
  6032. zOffset: number;
  6033. cullFace: Nullable<number>;
  6034. cull: Nullable<boolean>;
  6035. depthFunc: Nullable<number>;
  6036. depthMask: boolean;
  6037. depthTest: boolean;
  6038. frontFace: Nullable<number>;
  6039. reset(): void;
  6040. apply(gl: WebGLRenderingContext): void;
  6041. }
  6042. }
  6043. declare module "babylonjs/States/stencilState" {
  6044. /**
  6045. * @hidden
  6046. **/
  6047. export class _StencilState {
  6048. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6049. static readonly ALWAYS: number;
  6050. /** Passed to stencilOperation to specify that stencil value must be kept */
  6051. static readonly KEEP: number;
  6052. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6053. static readonly REPLACE: number;
  6054. private _isStencilTestDirty;
  6055. private _isStencilMaskDirty;
  6056. private _isStencilFuncDirty;
  6057. private _isStencilOpDirty;
  6058. private _stencilTest;
  6059. private _stencilMask;
  6060. private _stencilFunc;
  6061. private _stencilFuncRef;
  6062. private _stencilFuncMask;
  6063. private _stencilOpStencilFail;
  6064. private _stencilOpDepthFail;
  6065. private _stencilOpStencilDepthPass;
  6066. readonly isDirty: boolean;
  6067. stencilFunc: number;
  6068. stencilFuncRef: number;
  6069. stencilFuncMask: number;
  6070. stencilOpStencilFail: number;
  6071. stencilOpDepthFail: number;
  6072. stencilOpStencilDepthPass: number;
  6073. stencilMask: number;
  6074. stencilTest: boolean;
  6075. constructor();
  6076. reset(): void;
  6077. apply(gl: WebGLRenderingContext): void;
  6078. }
  6079. }
  6080. declare module "babylonjs/States/index" {
  6081. export * from "babylonjs/States/alphaCullingState";
  6082. export * from "babylonjs/States/depthCullingState";
  6083. export * from "babylonjs/States/stencilState";
  6084. }
  6085. declare module "babylonjs/Instrumentation/timeToken" {
  6086. import { Nullable } from "babylonjs/types";
  6087. /**
  6088. * @hidden
  6089. **/
  6090. export class _TimeToken {
  6091. _startTimeQuery: Nullable<WebGLQuery>;
  6092. _endTimeQuery: Nullable<WebGLQuery>;
  6093. _timeElapsedQuery: Nullable<WebGLQuery>;
  6094. _timeElapsedQueryEnded: boolean;
  6095. }
  6096. }
  6097. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6098. import { Nullable } from "babylonjs/types";
  6099. /**
  6100. * Internal interface used to track InternalTexture already bound to the GL context
  6101. */
  6102. export interface IInternalTextureTracker {
  6103. /**
  6104. * Gets or set the previous tracker in the list
  6105. */
  6106. previous: Nullable<IInternalTextureTracker>;
  6107. /**
  6108. * Gets or set the next tracker in the list
  6109. */
  6110. next: Nullable<IInternalTextureTracker>;
  6111. }
  6112. /**
  6113. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6114. */
  6115. export class DummyInternalTextureTracker {
  6116. /**
  6117. * Gets or set the previous tracker in the list
  6118. */
  6119. previous: Nullable<IInternalTextureTracker>;
  6120. /**
  6121. * Gets or set the next tracker in the list
  6122. */
  6123. next: Nullable<IInternalTextureTracker>;
  6124. }
  6125. }
  6126. declare module "babylonjs/Materials/Textures/internalTexture" {
  6127. import { Observable } from "babylonjs/Misc/observable";
  6128. import { Nullable, int } from "babylonjs/types";
  6129. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6130. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6131. import { Engine } from "babylonjs/Engines/engine";
  6132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6133. /**
  6134. * Class used to store data associated with WebGL texture data for the engine
  6135. * This class should not be used directly
  6136. */
  6137. export class InternalTexture implements IInternalTextureTracker {
  6138. /** hidden */
  6139. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6140. /**
  6141. * The source of the texture data is unknown
  6142. */
  6143. static DATASOURCE_UNKNOWN: number;
  6144. /**
  6145. * Texture data comes from an URL
  6146. */
  6147. static DATASOURCE_URL: number;
  6148. /**
  6149. * Texture data is only used for temporary storage
  6150. */
  6151. static DATASOURCE_TEMP: number;
  6152. /**
  6153. * Texture data comes from raw data (ArrayBuffer)
  6154. */
  6155. static DATASOURCE_RAW: number;
  6156. /**
  6157. * Texture content is dynamic (video or dynamic texture)
  6158. */
  6159. static DATASOURCE_DYNAMIC: number;
  6160. /**
  6161. * Texture content is generated by rendering to it
  6162. */
  6163. static DATASOURCE_RENDERTARGET: number;
  6164. /**
  6165. * Texture content is part of a multi render target process
  6166. */
  6167. static DATASOURCE_MULTIRENDERTARGET: number;
  6168. /**
  6169. * Texture data comes from a cube data file
  6170. */
  6171. static DATASOURCE_CUBE: number;
  6172. /**
  6173. * Texture data comes from a raw cube data
  6174. */
  6175. static DATASOURCE_CUBERAW: number;
  6176. /**
  6177. * Texture data come from a prefiltered cube data file
  6178. */
  6179. static DATASOURCE_CUBEPREFILTERED: number;
  6180. /**
  6181. * Texture content is raw 3D data
  6182. */
  6183. static DATASOURCE_RAW3D: number;
  6184. /**
  6185. * Texture content is a depth texture
  6186. */
  6187. static DATASOURCE_DEPTHTEXTURE: number;
  6188. /**
  6189. * Texture data comes from a raw cube data encoded with RGBD
  6190. */
  6191. static DATASOURCE_CUBERAW_RGBD: number;
  6192. /**
  6193. * Defines if the texture is ready
  6194. */
  6195. isReady: boolean;
  6196. /**
  6197. * Defines if the texture is a cube texture
  6198. */
  6199. isCube: boolean;
  6200. /**
  6201. * Defines if the texture contains 3D data
  6202. */
  6203. is3D: boolean;
  6204. /**
  6205. * Gets the URL used to load this texture
  6206. */
  6207. url: string;
  6208. /**
  6209. * Gets the sampling mode of the texture
  6210. */
  6211. samplingMode: number;
  6212. /**
  6213. * Gets a boolean indicating if the texture needs mipmaps generation
  6214. */
  6215. generateMipMaps: boolean;
  6216. /**
  6217. * Gets the number of samples used by the texture (WebGL2+ only)
  6218. */
  6219. samples: number;
  6220. /**
  6221. * Gets the type of the texture (int, float...)
  6222. */
  6223. type: number;
  6224. /**
  6225. * Gets the format of the texture (RGB, RGBA...)
  6226. */
  6227. format: number;
  6228. /**
  6229. * Observable called when the texture is loaded
  6230. */
  6231. onLoadedObservable: Observable<InternalTexture>;
  6232. /**
  6233. * Gets the width of the texture
  6234. */
  6235. width: number;
  6236. /**
  6237. * Gets the height of the texture
  6238. */
  6239. height: number;
  6240. /**
  6241. * Gets the depth of the texture
  6242. */
  6243. depth: number;
  6244. /**
  6245. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6246. */
  6247. baseWidth: number;
  6248. /**
  6249. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6250. */
  6251. baseHeight: number;
  6252. /**
  6253. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6254. */
  6255. baseDepth: number;
  6256. /**
  6257. * Gets a boolean indicating if the texture is inverted on Y axis
  6258. */
  6259. invertY: boolean;
  6260. /**
  6261. * Gets or set the previous tracker in the list
  6262. */
  6263. previous: Nullable<IInternalTextureTracker>;
  6264. /**
  6265. * Gets or set the next tracker in the list
  6266. */
  6267. next: Nullable<IInternalTextureTracker>;
  6268. /** @hidden */
  6269. _invertVScale: boolean;
  6270. /** @hidden */
  6271. _initialSlot: number;
  6272. /** @hidden */
  6273. _designatedSlot: number;
  6274. /** @hidden */
  6275. _dataSource: number;
  6276. /** @hidden */
  6277. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6278. /** @hidden */
  6279. _bufferView: Nullable<ArrayBufferView>;
  6280. /** @hidden */
  6281. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6282. /** @hidden */
  6283. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6284. /** @hidden */
  6285. _size: number;
  6286. /** @hidden */
  6287. _extension: string;
  6288. /** @hidden */
  6289. _files: Nullable<string[]>;
  6290. /** @hidden */
  6291. _workingCanvas: HTMLCanvasElement;
  6292. /** @hidden */
  6293. _workingContext: CanvasRenderingContext2D;
  6294. /** @hidden */
  6295. _framebuffer: Nullable<WebGLFramebuffer>;
  6296. /** @hidden */
  6297. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6298. /** @hidden */
  6299. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6300. /** @hidden */
  6301. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6302. /** @hidden */
  6303. _attachments: Nullable<number[]>;
  6304. /** @hidden */
  6305. _cachedCoordinatesMode: Nullable<number>;
  6306. /** @hidden */
  6307. _cachedWrapU: Nullable<number>;
  6308. /** @hidden */
  6309. _cachedWrapV: Nullable<number>;
  6310. /** @hidden */
  6311. _cachedWrapR: Nullable<number>;
  6312. /** @hidden */
  6313. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6314. /** @hidden */
  6315. _isDisabled: boolean;
  6316. /** @hidden */
  6317. _compression: Nullable<string>;
  6318. /** @hidden */
  6319. _generateStencilBuffer: boolean;
  6320. /** @hidden */
  6321. _generateDepthBuffer: boolean;
  6322. /** @hidden */
  6323. _comparisonFunction: number;
  6324. /** @hidden */
  6325. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6326. /** @hidden */
  6327. _lodGenerationScale: number;
  6328. /** @hidden */
  6329. _lodGenerationOffset: number;
  6330. /** @hidden */
  6331. _lodTextureHigh: BaseTexture;
  6332. /** @hidden */
  6333. _lodTextureMid: BaseTexture;
  6334. /** @hidden */
  6335. _lodTextureLow: BaseTexture;
  6336. /** @hidden */
  6337. _isRGBD: boolean;
  6338. /** @hidden */
  6339. _webGLTexture: Nullable<WebGLTexture>;
  6340. /** @hidden */
  6341. _references: number;
  6342. private _engine;
  6343. /**
  6344. * Gets the Engine the texture belongs to.
  6345. * @returns The babylon engine
  6346. */
  6347. getEngine(): Engine;
  6348. /**
  6349. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6350. */
  6351. readonly dataSource: number;
  6352. /**
  6353. * Creates a new InternalTexture
  6354. * @param engine defines the engine to use
  6355. * @param dataSource defines the type of data that will be used
  6356. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6357. */
  6358. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6359. /**
  6360. * Increments the number of references (ie. the number of Texture that point to it)
  6361. */
  6362. incrementReferences(): void;
  6363. /**
  6364. * Change the size of the texture (not the size of the content)
  6365. * @param width defines the new width
  6366. * @param height defines the new height
  6367. * @param depth defines the new depth (1 by default)
  6368. */
  6369. updateSize(width: int, height: int, depth?: int): void;
  6370. /** @hidden */
  6371. _rebuild(): void;
  6372. /** @hidden */
  6373. _swapAndDie(target: InternalTexture): void;
  6374. /**
  6375. * Dispose the current allocated resources
  6376. */
  6377. dispose(): void;
  6378. }
  6379. }
  6380. declare module "babylonjs/Animations/easing" {
  6381. /**
  6382. * This represents the main contract an easing function should follow.
  6383. * Easing functions are used throughout the animation system.
  6384. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6385. */
  6386. export interface IEasingFunction {
  6387. /**
  6388. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6389. * of the easing function.
  6390. * The link below provides some of the most common examples of easing functions.
  6391. * @see https://easings.net/
  6392. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6393. * @returns the corresponding value on the curve defined by the easing function
  6394. */
  6395. ease(gradient: number): number;
  6396. }
  6397. /**
  6398. * Base class used for every default easing function.
  6399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6400. */
  6401. export class EasingFunction implements IEasingFunction {
  6402. /**
  6403. * Interpolation follows the mathematical formula associated with the easing function.
  6404. */
  6405. static readonly EASINGMODE_EASEIN: number;
  6406. /**
  6407. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6408. */
  6409. static readonly EASINGMODE_EASEOUT: number;
  6410. /**
  6411. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6412. */
  6413. static readonly EASINGMODE_EASEINOUT: number;
  6414. private _easingMode;
  6415. /**
  6416. * Sets the easing mode of the current function.
  6417. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6418. */
  6419. setEasingMode(easingMode: number): void;
  6420. /**
  6421. * Gets the current easing mode.
  6422. * @returns the easing mode
  6423. */
  6424. getEasingMode(): number;
  6425. /**
  6426. * @hidden
  6427. */
  6428. easeInCore(gradient: number): number;
  6429. /**
  6430. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6431. * of the easing function.
  6432. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6433. * @returns the corresponding value on the curve defined by the easing function
  6434. */
  6435. ease(gradient: number): number;
  6436. }
  6437. /**
  6438. * Easing function with a circle shape (see link below).
  6439. * @see https://easings.net/#easeInCirc
  6440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6441. */
  6442. export class CircleEase extends EasingFunction implements IEasingFunction {
  6443. /** @hidden */
  6444. easeInCore(gradient: number): number;
  6445. }
  6446. /**
  6447. * Easing function with a ease back shape (see link below).
  6448. * @see https://easings.net/#easeInBack
  6449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6450. */
  6451. export class BackEase extends EasingFunction implements IEasingFunction {
  6452. /** Defines the amplitude of the function */
  6453. amplitude: number;
  6454. /**
  6455. * Instantiates a back ease easing
  6456. * @see https://easings.net/#easeInBack
  6457. * @param amplitude Defines the amplitude of the function
  6458. */
  6459. constructor(
  6460. /** Defines the amplitude of the function */
  6461. amplitude?: number);
  6462. /** @hidden */
  6463. easeInCore(gradient: number): number;
  6464. }
  6465. /**
  6466. * Easing function with a bouncing shape (see link below).
  6467. * @see https://easings.net/#easeInBounce
  6468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6469. */
  6470. export class BounceEase extends EasingFunction implements IEasingFunction {
  6471. /** Defines the number of bounces */
  6472. bounces: number;
  6473. /** Defines the amplitude of the bounce */
  6474. bounciness: number;
  6475. /**
  6476. * Instantiates a bounce easing
  6477. * @see https://easings.net/#easeInBounce
  6478. * @param bounces Defines the number of bounces
  6479. * @param bounciness Defines the amplitude of the bounce
  6480. */
  6481. constructor(
  6482. /** Defines the number of bounces */
  6483. bounces?: number,
  6484. /** Defines the amplitude of the bounce */
  6485. bounciness?: number);
  6486. /** @hidden */
  6487. easeInCore(gradient: number): number;
  6488. }
  6489. /**
  6490. * Easing function with a power of 3 shape (see link below).
  6491. * @see https://easings.net/#easeInCubic
  6492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6493. */
  6494. export class CubicEase extends EasingFunction implements IEasingFunction {
  6495. /** @hidden */
  6496. easeInCore(gradient: number): number;
  6497. }
  6498. /**
  6499. * Easing function with an elastic shape (see link below).
  6500. * @see https://easings.net/#easeInElastic
  6501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6502. */
  6503. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6504. /** Defines the number of oscillations*/
  6505. oscillations: number;
  6506. /** Defines the amplitude of the oscillations*/
  6507. springiness: number;
  6508. /**
  6509. * Instantiates an elastic easing function
  6510. * @see https://easings.net/#easeInElastic
  6511. * @param oscillations Defines the number of oscillations
  6512. * @param springiness Defines the amplitude of the oscillations
  6513. */
  6514. constructor(
  6515. /** Defines the number of oscillations*/
  6516. oscillations?: number,
  6517. /** Defines the amplitude of the oscillations*/
  6518. springiness?: number);
  6519. /** @hidden */
  6520. easeInCore(gradient: number): number;
  6521. }
  6522. /**
  6523. * Easing function with an exponential shape (see link below).
  6524. * @see https://easings.net/#easeInExpo
  6525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6526. */
  6527. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6528. /** Defines the exponent of the function */
  6529. exponent: number;
  6530. /**
  6531. * Instantiates an exponential easing function
  6532. * @see https://easings.net/#easeInExpo
  6533. * @param exponent Defines the exponent of the function
  6534. */
  6535. constructor(
  6536. /** Defines the exponent of the function */
  6537. exponent?: number);
  6538. /** @hidden */
  6539. easeInCore(gradient: number): number;
  6540. }
  6541. /**
  6542. * Easing function with a power shape (see link below).
  6543. * @see https://easings.net/#easeInQuad
  6544. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6545. */
  6546. export class PowerEase extends EasingFunction implements IEasingFunction {
  6547. /** Defines the power of the function */
  6548. power: number;
  6549. /**
  6550. * Instantiates an power base easing function
  6551. * @see https://easings.net/#easeInQuad
  6552. * @param power Defines the power of the function
  6553. */
  6554. constructor(
  6555. /** Defines the power of the function */
  6556. power?: number);
  6557. /** @hidden */
  6558. easeInCore(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a power of 2 shape (see link below).
  6562. * @see https://easings.net/#easeInQuad
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with a power of 4 shape (see link below).
  6571. * @see https://easings.net/#easeInQuart
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 5 shape (see link below).
  6580. * @see https://easings.net/#easeInQuint
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a sin shape (see link below).
  6589. * @see https://easings.net/#easeInSine
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class SineEase extends EasingFunction implements IEasingFunction {
  6593. /** @hidden */
  6594. easeInCore(gradient: number): number;
  6595. }
  6596. /**
  6597. * Easing function with a bezier shape (see link below).
  6598. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6600. */
  6601. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6602. /** Defines the x component of the start tangent in the bezier curve */
  6603. x1: number;
  6604. /** Defines the y component of the start tangent in the bezier curve */
  6605. y1: number;
  6606. /** Defines the x component of the end tangent in the bezier curve */
  6607. x2: number;
  6608. /** Defines the y component of the end tangent in the bezier curve */
  6609. y2: number;
  6610. /**
  6611. * Instantiates a bezier function
  6612. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6613. * @param x1 Defines the x component of the start tangent in the bezier curve
  6614. * @param y1 Defines the y component of the start tangent in the bezier curve
  6615. * @param x2 Defines the x component of the end tangent in the bezier curve
  6616. * @param y2 Defines the y component of the end tangent in the bezier curve
  6617. */
  6618. constructor(
  6619. /** Defines the x component of the start tangent in the bezier curve */
  6620. x1?: number,
  6621. /** Defines the y component of the start tangent in the bezier curve */
  6622. y1?: number,
  6623. /** Defines the x component of the end tangent in the bezier curve */
  6624. x2?: number,
  6625. /** Defines the y component of the end tangent in the bezier curve */
  6626. y2?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. }
  6631. declare module "babylonjs/Animations/animationKey" {
  6632. /**
  6633. * Defines an interface which represents an animation key frame
  6634. */
  6635. export interface IAnimationKey {
  6636. /**
  6637. * Frame of the key frame
  6638. */
  6639. frame: number;
  6640. /**
  6641. * Value at the specifies key frame
  6642. */
  6643. value: any;
  6644. /**
  6645. * The input tangent for the cubic hermite spline
  6646. */
  6647. inTangent?: any;
  6648. /**
  6649. * The output tangent for the cubic hermite spline
  6650. */
  6651. outTangent?: any;
  6652. /**
  6653. * The animation interpolation type
  6654. */
  6655. interpolation?: AnimationKeyInterpolation;
  6656. }
  6657. /**
  6658. * Enum for the animation key frame interpolation type
  6659. */
  6660. export enum AnimationKeyInterpolation {
  6661. /**
  6662. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6663. */
  6664. STEP = 1
  6665. }
  6666. }
  6667. declare module "babylonjs/Animations/animationRange" {
  6668. /**
  6669. * Represents the range of an animation
  6670. */
  6671. export class AnimationRange {
  6672. /**The name of the animation range**/
  6673. name: string;
  6674. /**The starting frame of the animation */
  6675. from: number;
  6676. /**The ending frame of the animation*/
  6677. to: number;
  6678. /**
  6679. * Initializes the range of an animation
  6680. * @param name The name of the animation range
  6681. * @param from The starting frame of the animation
  6682. * @param to The ending frame of the animation
  6683. */
  6684. constructor(
  6685. /**The name of the animation range**/
  6686. name: string,
  6687. /**The starting frame of the animation */
  6688. from: number,
  6689. /**The ending frame of the animation*/
  6690. to: number);
  6691. /**
  6692. * Makes a copy of the animation range
  6693. * @returns A copy of the animation range
  6694. */
  6695. clone(): AnimationRange;
  6696. }
  6697. }
  6698. declare module "babylonjs/Animations/animationEvent" {
  6699. /**
  6700. * Composed of a frame, and an action function
  6701. */
  6702. export class AnimationEvent {
  6703. /** The frame for which the event is triggered **/
  6704. frame: number;
  6705. /** The event to perform when triggered **/
  6706. action: (currentFrame: number) => void;
  6707. /** Specifies if the event should be triggered only once**/
  6708. onlyOnce?: boolean | undefined;
  6709. /**
  6710. * Specifies if the animation event is done
  6711. */
  6712. isDone: boolean;
  6713. /**
  6714. * Initializes the animation event
  6715. * @param frame The frame for which the event is triggered
  6716. * @param action The event to perform when triggered
  6717. * @param onlyOnce Specifies if the event should be triggered only once
  6718. */
  6719. constructor(
  6720. /** The frame for which the event is triggered **/
  6721. frame: number,
  6722. /** The event to perform when triggered **/
  6723. action: (currentFrame: number) => void,
  6724. /** Specifies if the event should be triggered only once**/
  6725. onlyOnce?: boolean | undefined);
  6726. /** @hidden */
  6727. _clone(): AnimationEvent;
  6728. }
  6729. }
  6730. declare module "babylonjs/Behaviors/behavior" {
  6731. import { Nullable } from "babylonjs/types";
  6732. /**
  6733. * Interface used to define a behavior
  6734. */
  6735. export interface Behavior<T> {
  6736. /** gets or sets behavior's name */
  6737. name: string;
  6738. /**
  6739. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6740. */
  6741. init(): void;
  6742. /**
  6743. * Called when the behavior is attached to a target
  6744. * @param target defines the target where the behavior is attached to
  6745. */
  6746. attach(target: T): void;
  6747. /**
  6748. * Called when the behavior is detached from its target
  6749. */
  6750. detach(): void;
  6751. }
  6752. /**
  6753. * Interface implemented by classes supporting behaviors
  6754. */
  6755. export interface IBehaviorAware<T> {
  6756. /**
  6757. * Attach a behavior
  6758. * @param behavior defines the behavior to attach
  6759. * @returns the current host
  6760. */
  6761. addBehavior(behavior: Behavior<T>): T;
  6762. /**
  6763. * Remove a behavior from the current object
  6764. * @param behavior defines the behavior to detach
  6765. * @returns the current host
  6766. */
  6767. removeBehavior(behavior: Behavior<T>): T;
  6768. /**
  6769. * Gets a behavior using its name to search
  6770. * @param name defines the name to search
  6771. * @returns the behavior or null if not found
  6772. */
  6773. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6774. }
  6775. }
  6776. declare module "babylonjs/Collisions/intersectionInfo" {
  6777. import { Nullable } from "babylonjs/types";
  6778. /**
  6779. * @hidden
  6780. */
  6781. export class IntersectionInfo {
  6782. bu: Nullable<number>;
  6783. bv: Nullable<number>;
  6784. distance: number;
  6785. faceId: number;
  6786. subMeshId: number;
  6787. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6788. }
  6789. }
  6790. declare module "babylonjs/Culling/boundingSphere" {
  6791. import { DeepImmutable } from "babylonjs/types";
  6792. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6793. /**
  6794. * Class used to store bounding sphere information
  6795. */
  6796. export class BoundingSphere {
  6797. /**
  6798. * Gets the center of the bounding sphere in local space
  6799. */
  6800. readonly center: Vector3;
  6801. /**
  6802. * Radius of the bounding sphere in local space
  6803. */
  6804. radius: number;
  6805. /**
  6806. * Gets the center of the bounding sphere in world space
  6807. */
  6808. readonly centerWorld: Vector3;
  6809. /**
  6810. * Radius of the bounding sphere in world space
  6811. */
  6812. radiusWorld: number;
  6813. /**
  6814. * Gets the minimum vector in local space
  6815. */
  6816. readonly minimum: Vector3;
  6817. /**
  6818. * Gets the maximum vector in local space
  6819. */
  6820. readonly maximum: Vector3;
  6821. private _worldMatrix;
  6822. private static readonly TmpVector3;
  6823. /**
  6824. * Creates a new bounding sphere
  6825. * @param min defines the minimum vector (in local space)
  6826. * @param max defines the maximum vector (in local space)
  6827. * @param worldMatrix defines the new world matrix
  6828. */
  6829. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6830. /**
  6831. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6832. * @param min defines the new minimum vector (in local space)
  6833. * @param max defines the new maximum vector (in local space)
  6834. * @param worldMatrix defines the new world matrix
  6835. */
  6836. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6837. /**
  6838. * Scale the current bounding sphere by applying a scale factor
  6839. * @param factor defines the scale factor to apply
  6840. * @returns the current bounding box
  6841. */
  6842. scale(factor: number): BoundingSphere;
  6843. /**
  6844. * Gets the world matrix of the bounding box
  6845. * @returns a matrix
  6846. */
  6847. getWorldMatrix(): DeepImmutable<Matrix>;
  6848. /** @hidden */
  6849. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6850. /**
  6851. * Tests if the bounding sphere is intersecting the frustum planes
  6852. * @param frustumPlanes defines the frustum planes to test
  6853. * @returns true if there is an intersection
  6854. */
  6855. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6856. /**
  6857. * Tests if the bounding sphere center is in between the frustum planes.
  6858. * Used for optimistic fast inclusion.
  6859. * @param frustumPlanes defines the frustum planes to test
  6860. * @returns true if the sphere center is in between the frustum planes
  6861. */
  6862. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6863. /**
  6864. * Tests if a point is inside the bounding sphere
  6865. * @param point defines the point to test
  6866. * @returns true if the point is inside the bounding sphere
  6867. */
  6868. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6869. /**
  6870. * Checks if two sphere intersct
  6871. * @param sphere0 sphere 0
  6872. * @param sphere1 sphere 1
  6873. * @returns true if the speres intersect
  6874. */
  6875. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6876. }
  6877. }
  6878. declare module "babylonjs/Culling/boundingBox" {
  6879. import { DeepImmutable } from "babylonjs/types";
  6880. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6881. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6882. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6883. /**
  6884. * Class used to store bounding box information
  6885. */
  6886. export class BoundingBox implements ICullable {
  6887. /**
  6888. * Gets the 8 vectors representing the bounding box in local space
  6889. */
  6890. readonly vectors: Vector3[];
  6891. /**
  6892. * Gets the center of the bounding box in local space
  6893. */
  6894. readonly center: Vector3;
  6895. /**
  6896. * Gets the center of the bounding box in world space
  6897. */
  6898. readonly centerWorld: Vector3;
  6899. /**
  6900. * Gets the extend size in local space
  6901. */
  6902. readonly extendSize: Vector3;
  6903. /**
  6904. * Gets the extend size in world space
  6905. */
  6906. readonly extendSizeWorld: Vector3;
  6907. /**
  6908. * Gets the OBB (object bounding box) directions
  6909. */
  6910. readonly directions: Vector3[];
  6911. /**
  6912. * Gets the 8 vectors representing the bounding box in world space
  6913. */
  6914. readonly vectorsWorld: Vector3[];
  6915. /**
  6916. * Gets the minimum vector in world space
  6917. */
  6918. readonly minimumWorld: Vector3;
  6919. /**
  6920. * Gets the maximum vector in world space
  6921. */
  6922. readonly maximumWorld: Vector3;
  6923. /**
  6924. * Gets the minimum vector in local space
  6925. */
  6926. readonly minimum: Vector3;
  6927. /**
  6928. * Gets the maximum vector in local space
  6929. */
  6930. readonly maximum: Vector3;
  6931. private _worldMatrix;
  6932. private static readonly TmpVector3;
  6933. /**
  6934. * @hidden
  6935. */
  6936. _tag: number;
  6937. /**
  6938. * Creates a new bounding box
  6939. * @param min defines the minimum vector (in local space)
  6940. * @param max defines the maximum vector (in local space)
  6941. * @param worldMatrix defines the new world matrix
  6942. */
  6943. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6944. /**
  6945. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6946. * @param min defines the new minimum vector (in local space)
  6947. * @param max defines the new maximum vector (in local space)
  6948. * @param worldMatrix defines the new world matrix
  6949. */
  6950. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6951. /**
  6952. * Scale the current bounding box by applying a scale factor
  6953. * @param factor defines the scale factor to apply
  6954. * @returns the current bounding box
  6955. */
  6956. scale(factor: number): BoundingBox;
  6957. /**
  6958. * Gets the world matrix of the bounding box
  6959. * @returns a matrix
  6960. */
  6961. getWorldMatrix(): DeepImmutable<Matrix>;
  6962. /** @hidden */
  6963. _update(world: DeepImmutable<Matrix>): void;
  6964. /**
  6965. * Tests if the bounding box is intersecting the frustum planes
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if the bounding box is entirely inside the frustum planes
  6972. * @param frustumPlanes defines the frustum planes to test
  6973. * @returns true if there is an inclusion
  6974. */
  6975. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6976. /**
  6977. * Tests if a point is inside the bounding box
  6978. * @param point defines the point to test
  6979. * @returns true if the point is inside the bounding box
  6980. */
  6981. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6982. /**
  6983. * Tests if the bounding box intersects with a bounding sphere
  6984. * @param sphere defines the sphere to test
  6985. * @returns true if there is an intersection
  6986. */
  6987. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6988. /**
  6989. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6990. * @param min defines the min vector to use
  6991. * @param max defines the max vector to use
  6992. * @returns true if there is an intersection
  6993. */
  6994. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6995. /**
  6996. * Tests if two bounding boxes are intersections
  6997. * @param box0 defines the first box to test
  6998. * @param box1 defines the second box to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7002. /**
  7003. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7004. * @param minPoint defines the minimum vector of the bounding box
  7005. * @param maxPoint defines the maximum vector of the bounding box
  7006. * @param sphereCenter defines the sphere center
  7007. * @param sphereRadius defines the sphere radius
  7008. * @returns true if there is an intersection
  7009. */
  7010. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7011. /**
  7012. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7013. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7014. * @param frustumPlanes defines the frustum planes to test
  7015. * @return true if there is an inclusion
  7016. */
  7017. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7018. /**
  7019. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7020. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @return true if there is an intersection
  7023. */
  7024. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. }
  7026. }
  7027. declare module "babylonjs/Collisions/collider" {
  7028. import { Nullable, IndicesArray } from "babylonjs/types";
  7029. import { Vector3, Plane } from "babylonjs/Maths/math";
  7030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7031. /** @hidden */
  7032. export class Collider {
  7033. /** Define if a collision was found */
  7034. collisionFound: boolean;
  7035. /**
  7036. * Define last intersection point in local space
  7037. */
  7038. intersectionPoint: Vector3;
  7039. /**
  7040. * Define last collided mesh
  7041. */
  7042. collidedMesh: Nullable<AbstractMesh>;
  7043. private _collisionPoint;
  7044. private _planeIntersectionPoint;
  7045. private _tempVector;
  7046. private _tempVector2;
  7047. private _tempVector3;
  7048. private _tempVector4;
  7049. private _edge;
  7050. private _baseToVertex;
  7051. private _destinationPoint;
  7052. private _slidePlaneNormal;
  7053. private _displacementVector;
  7054. /** @hidden */
  7055. _radius: Vector3;
  7056. /** @hidden */
  7057. _retry: number;
  7058. private _velocity;
  7059. private _basePoint;
  7060. private _epsilon;
  7061. /** @hidden */
  7062. _velocityWorldLength: number;
  7063. /** @hidden */
  7064. _basePointWorld: Vector3;
  7065. private _velocityWorld;
  7066. private _normalizedVelocity;
  7067. /** @hidden */
  7068. _initialVelocity: Vector3;
  7069. /** @hidden */
  7070. _initialPosition: Vector3;
  7071. private _nearestDistance;
  7072. private _collisionMask;
  7073. collisionMask: number;
  7074. /**
  7075. * Gets the plane normal used to compute the sliding response (in local space)
  7076. */
  7077. readonly slidePlaneNormal: Vector3;
  7078. /** @hidden */
  7079. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7080. /** @hidden */
  7081. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7082. /** @hidden */
  7083. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7084. /** @hidden */
  7085. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7086. /** @hidden */
  7087. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7088. /** @hidden */
  7089. _getResponse(pos: Vector3, vel: Vector3): void;
  7090. }
  7091. }
  7092. declare module "babylonjs/Culling/boundingInfo" {
  7093. import { DeepImmutable } from "babylonjs/types";
  7094. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7095. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7096. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7097. import { Collider } from "babylonjs/Collisions/collider";
  7098. /**
  7099. * Interface for cullable objects
  7100. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7101. */
  7102. export interface ICullable {
  7103. /**
  7104. * Checks if the object or part of the object is in the frustum
  7105. * @param frustumPlanes Camera near/planes
  7106. * @returns true if the object is in frustum otherwise false
  7107. */
  7108. isInFrustum(frustumPlanes: Plane[]): boolean;
  7109. /**
  7110. * Checks if a cullable object (mesh...) is in the camera frustum
  7111. * Unlike isInFrustum this cheks the full bounding box
  7112. * @param frustumPlanes Camera near/planes
  7113. * @returns true if the object is in frustum otherwise false
  7114. */
  7115. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7116. }
  7117. /**
  7118. * Info for a bounding data of a mesh
  7119. */
  7120. export class BoundingInfo implements ICullable {
  7121. /**
  7122. * Bounding box for the mesh
  7123. */
  7124. readonly boundingBox: BoundingBox;
  7125. /**
  7126. * Bounding sphere for the mesh
  7127. */
  7128. readonly boundingSphere: BoundingSphere;
  7129. private _isLocked;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Constructs bounding info
  7133. * @param minimum min vector of the bounding box/sphere
  7134. * @param maximum max vector of the bounding box/sphere
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * min vector of the bounding box/sphere
  7147. */
  7148. readonly minimum: Vector3;
  7149. /**
  7150. * max vector of the bounding box/sphere
  7151. */
  7152. readonly maximum: Vector3;
  7153. /**
  7154. * If the info is locked and won't be updated to avoid perf overhead
  7155. */
  7156. isLocked: boolean;
  7157. /**
  7158. * Updates the bounding sphere and box
  7159. * @param world world matrix to be used to update
  7160. */
  7161. update(world: DeepImmutable<Matrix>): void;
  7162. /**
  7163. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7164. * @param center New center of the bounding info
  7165. * @param extend New extend of the bounding info
  7166. * @returns the current bounding info
  7167. */
  7168. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7169. /**
  7170. * Scale the current bounding info by applying a scale factor
  7171. * @param factor defines the scale factor to apply
  7172. * @returns the current bounding info
  7173. */
  7174. scale(factor: number): BoundingInfo;
  7175. /**
  7176. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7177. * @param frustumPlanes defines the frustum to test
  7178. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7179. * @returns true if the bounding info is in the frustum planes
  7180. */
  7181. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7182. /**
  7183. * Gets the world distance between the min and max points of the bounding box
  7184. */
  7185. readonly diagonalLength: number;
  7186. /**
  7187. * Checks if a cullable object (mesh...) is in the camera frustum
  7188. * Unlike isInFrustum this cheks the full bounding box
  7189. * @param frustumPlanes Camera near/planes
  7190. * @returns true if the object is in frustum otherwise false
  7191. */
  7192. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7193. /** @hidden */
  7194. _checkCollision(collider: Collider): boolean;
  7195. /**
  7196. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7197. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7198. * @param point the point to check intersection with
  7199. * @returns if the point intersects
  7200. */
  7201. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7202. /**
  7203. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param boundingInfo the bounding info to check intersection with
  7206. * @param precise if the intersection should be done using OBB
  7207. * @returns if the bounding info intersects
  7208. */
  7209. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7210. }
  7211. }
  7212. declare module "babylonjs/Misc/smartArray" {
  7213. /**
  7214. * Defines an array and its length.
  7215. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7216. */
  7217. export interface ISmartArrayLike<T> {
  7218. /**
  7219. * The data of the array.
  7220. */
  7221. data: Array<T>;
  7222. /**
  7223. * The active length of the array.
  7224. */
  7225. length: number;
  7226. }
  7227. /**
  7228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7229. */
  7230. export class SmartArray<T> implements ISmartArrayLike<T> {
  7231. /**
  7232. * The full set of data from the array.
  7233. */
  7234. data: Array<T>;
  7235. /**
  7236. * The active length of the array.
  7237. */
  7238. length: number;
  7239. protected _id: number;
  7240. /**
  7241. * Instantiates a Smart Array.
  7242. * @param capacity defines the default capacity of the array.
  7243. */
  7244. constructor(capacity: number);
  7245. /**
  7246. * Pushes a value at the end of the active data.
  7247. * @param value defines the object to push in the array.
  7248. */
  7249. push(value: T): void;
  7250. /**
  7251. * Iterates over the active data and apply the lambda to them.
  7252. * @param func defines the action to apply on each value.
  7253. */
  7254. forEach(func: (content: T) => void): void;
  7255. /**
  7256. * Sorts the full sets of data.
  7257. * @param compareFn defines the comparison function to apply.
  7258. */
  7259. sort(compareFn: (a: T, b: T) => number): void;
  7260. /**
  7261. * Resets the active data to an empty array.
  7262. */
  7263. reset(): void;
  7264. /**
  7265. * Releases all the data from the array as well as the array.
  7266. */
  7267. dispose(): void;
  7268. /**
  7269. * Concats the active data with a given array.
  7270. * @param array defines the data to concatenate with.
  7271. */
  7272. concat(array: any): void;
  7273. /**
  7274. * Returns the position of a value in the active data.
  7275. * @param value defines the value to find the index for
  7276. * @returns the index if found in the active data otherwise -1
  7277. */
  7278. indexOf(value: T): number;
  7279. /**
  7280. * Returns whether an element is part of the active data.
  7281. * @param value defines the value to look for
  7282. * @returns true if found in the active data otherwise false
  7283. */
  7284. contains(value: T): boolean;
  7285. private static _GlobalId;
  7286. }
  7287. /**
  7288. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7289. * The data in this array can only be present once
  7290. */
  7291. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7292. private _duplicateId;
  7293. /**
  7294. * Pushes a value at the end of the active data.
  7295. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7296. * @param value defines the object to push in the array.
  7297. */
  7298. push(value: T): void;
  7299. /**
  7300. * Pushes a value at the end of the active data.
  7301. * If the data is already present, it won t be added again
  7302. * @param value defines the object to push in the array.
  7303. * @returns true if added false if it was already present
  7304. */
  7305. pushNoDuplicate(value: T): boolean;
  7306. /**
  7307. * Resets the active data to an empty array.
  7308. */
  7309. reset(): void;
  7310. /**
  7311. * Concats the active data with a given array.
  7312. * This ensures no dupplicate will be present in the result.
  7313. * @param array defines the data to concatenate with.
  7314. */
  7315. concatWithNoDuplicate(array: any): void;
  7316. }
  7317. }
  7318. declare module "babylonjs/Materials/multiMaterial" {
  7319. import { Nullable } from "babylonjs/types";
  7320. import { Scene } from "babylonjs/scene";
  7321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7322. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7323. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7324. import { Material } from "babylonjs/Materials/material";
  7325. /**
  7326. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7327. * separate meshes. This can be use to improve performances.
  7328. * @see http://doc.babylonjs.com/how_to/multi_materials
  7329. */
  7330. export class MultiMaterial extends Material {
  7331. private _subMaterials;
  7332. /**
  7333. * Gets or Sets the list of Materials used within the multi material.
  7334. * They need to be ordered according to the submeshes order in the associated mesh
  7335. */
  7336. subMaterials: Nullable<Material>[];
  7337. /**
  7338. * Function used to align with Node.getChildren()
  7339. * @returns the list of Materials used within the multi material
  7340. */
  7341. getChildren(): Nullable<Material>[];
  7342. /**
  7343. * Instantiates a new Multi Material
  7344. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7345. * separate meshes. This can be use to improve performances.
  7346. * @see http://doc.babylonjs.com/how_to/multi_materials
  7347. * @param name Define the name in the scene
  7348. * @param scene Define the scene the material belongs to
  7349. */
  7350. constructor(name: string, scene: Scene);
  7351. private _hookArray;
  7352. /**
  7353. * Get one of the submaterial by its index in the submaterials array
  7354. * @param index The index to look the sub material at
  7355. * @returns The Material if the index has been defined
  7356. */
  7357. getSubMaterial(index: number): Nullable<Material>;
  7358. /**
  7359. * Get the list of active textures for the whole sub materials list.
  7360. * @returns All the textures that will be used during the rendering
  7361. */
  7362. getActiveTextures(): BaseTexture[];
  7363. /**
  7364. * Gets the current class name of the material e.g. "MultiMaterial"
  7365. * Mainly use in serialization.
  7366. * @returns the class name
  7367. */
  7368. getClassName(): string;
  7369. /**
  7370. * Checks if the material is ready to render the requested sub mesh
  7371. * @param mesh Define the mesh the submesh belongs to
  7372. * @param subMesh Define the sub mesh to look readyness for
  7373. * @param useInstances Define whether or not the material is used with instances
  7374. * @returns true if ready, otherwise false
  7375. */
  7376. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7377. /**
  7378. * Clones the current material and its related sub materials
  7379. * @param name Define the name of the newly cloned material
  7380. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7381. * @returns the cloned material
  7382. */
  7383. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7384. /**
  7385. * Serializes the materials into a JSON representation.
  7386. * @returns the JSON representation
  7387. */
  7388. serialize(): any;
  7389. /**
  7390. * Dispose the material and release its associated resources
  7391. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  7392. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  7393. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7394. */
  7395. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7396. /**
  7397. * Creates a MultiMaterial from parsed MultiMaterial data.
  7398. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7399. * @param scene defines the hosting scene
  7400. * @returns a new MultiMaterial
  7401. */
  7402. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7403. }
  7404. }
  7405. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7406. /**
  7407. * Class used to represent data loading progression
  7408. */
  7409. export class SceneLoaderFlags {
  7410. private static _ForceFullSceneLoadingForIncremental;
  7411. private static _ShowLoadingScreen;
  7412. private static _CleanBoneMatrixWeights;
  7413. private static _loggingLevel;
  7414. /**
  7415. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7416. */
  7417. static ForceFullSceneLoadingForIncremental: boolean;
  7418. /**
  7419. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7420. */
  7421. static ShowLoadingScreen: boolean;
  7422. /**
  7423. * Defines the current logging level (while loading the scene)
  7424. * @ignorenaming
  7425. */
  7426. static loggingLevel: number;
  7427. /**
  7428. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7429. */
  7430. static CleanBoneMatrixWeights: boolean;
  7431. }
  7432. }
  7433. declare module "babylonjs/Meshes/transformNode" {
  7434. import { DeepImmutable } from "babylonjs/types";
  7435. import { Observable } from "babylonjs/Misc/observable";
  7436. import { Nullable } from "babylonjs/types";
  7437. import { Camera } from "babylonjs/Cameras/camera";
  7438. import { Scene } from "babylonjs/scene";
  7439. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7440. import { Node } from "babylonjs/node";
  7441. import { Bone } from "babylonjs/Bones/bone";
  7442. /**
  7443. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  7444. * @see https://doc.babylonjs.com/how_to/transformnode
  7445. */
  7446. export class TransformNode extends Node {
  7447. /**
  7448. * Object will not rotate to face the camera
  7449. */
  7450. static BILLBOARDMODE_NONE: number;
  7451. /**
  7452. * Object will rotate to face the camera but only on the x axis
  7453. */
  7454. static BILLBOARDMODE_X: number;
  7455. /**
  7456. * Object will rotate to face the camera but only on the y axis
  7457. */
  7458. static BILLBOARDMODE_Y: number;
  7459. /**
  7460. * Object will rotate to face the camera but only on the z axis
  7461. */
  7462. static BILLBOARDMODE_Z: number;
  7463. /**
  7464. * Object will rotate to face the camera
  7465. */
  7466. static BILLBOARDMODE_ALL: number;
  7467. private _forward;
  7468. private _forwardInverted;
  7469. private _up;
  7470. private _right;
  7471. private _rightInverted;
  7472. private _position;
  7473. private _rotation;
  7474. private _rotationQuaternion;
  7475. protected _scaling: Vector3;
  7476. protected _isDirty: boolean;
  7477. private _transformToBoneReferal;
  7478. /**
  7479. * Set the billboard mode. Default is 0.
  7480. *
  7481. * | Value | Type | Description |
  7482. * | --- | --- | --- |
  7483. * | 0 | BILLBOARDMODE_NONE | |
  7484. * | 1 | BILLBOARDMODE_X | |
  7485. * | 2 | BILLBOARDMODE_Y | |
  7486. * | 4 | BILLBOARDMODE_Z | |
  7487. * | 7 | BILLBOARDMODE_ALL | |
  7488. *
  7489. */
  7490. billboardMode: number;
  7491. /**
  7492. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  7493. */
  7494. scalingDeterminant: number;
  7495. /**
  7496. * Sets the distance of the object to max, often used by skybox
  7497. */
  7498. infiniteDistance: boolean;
  7499. /**
  7500. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7501. * By default the system will update normals to compensate
  7502. */
  7503. ignoreNonUniformScaling: boolean;
  7504. /** @hidden */
  7505. _poseMatrix: Matrix;
  7506. /** @hidden */
  7507. _localMatrix: Matrix;
  7508. private _absolutePosition;
  7509. private _pivotMatrix;
  7510. private _pivotMatrixInverse;
  7511. protected _postMultiplyPivotMatrix: boolean;
  7512. protected _isWorldMatrixFrozen: boolean;
  7513. /** @hidden */
  7514. _indexInSceneTransformNodesArray: number;
  7515. /**
  7516. * An event triggered after the world matrix is updated
  7517. */
  7518. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7519. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7520. /**
  7521. * Gets a string identifying the name of the class
  7522. * @returns "TransformNode" string
  7523. */
  7524. getClassName(): string;
  7525. /**
  7526. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7527. */
  7528. position: Vector3;
  7529. /**
  7530. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7531. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7532. */
  7533. rotation: Vector3;
  7534. /**
  7535. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7536. */
  7537. scaling: Vector3;
  7538. /**
  7539. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  7540. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7541. */
  7542. rotationQuaternion: Nullable<Quaternion>;
  7543. /**
  7544. * The forward direction of that transform in world space.
  7545. */
  7546. readonly forward: Vector3;
  7547. /**
  7548. * The up direction of that transform in world space.
  7549. */
  7550. readonly up: Vector3;
  7551. /**
  7552. * The right direction of that transform in world space.
  7553. */
  7554. readonly right: Vector3;
  7555. /**
  7556. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7557. * @param matrix the matrix to copy the pose from
  7558. * @returns this TransformNode.
  7559. */
  7560. updatePoseMatrix(matrix: Matrix): TransformNode;
  7561. /**
  7562. * Returns the mesh Pose matrix.
  7563. * @returns the pose matrix
  7564. */
  7565. getPoseMatrix(): Matrix;
  7566. /** @hidden */
  7567. _isSynchronized(): boolean;
  7568. /** @hidden */
  7569. _initCache(): void;
  7570. /**
  7571. * Flag the transform node as dirty (Forcing it to update everything)
  7572. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7573. * @returns this transform node
  7574. */
  7575. markAsDirty(property: string): TransformNode;
  7576. /**
  7577. * Returns the current mesh absolute position.
  7578. * Returns a Vector3.
  7579. */
  7580. readonly absolutePosition: Vector3;
  7581. /**
  7582. * Sets a new matrix to apply before all other transformation
  7583. * @param matrix defines the transform matrix
  7584. * @returns the current TransformNode
  7585. */
  7586. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7587. /**
  7588. * Sets a new pivot matrix to the current node
  7589. * @param matrix defines the new pivot matrix to use
  7590. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  7591. * @returns the current TransformNode
  7592. */
  7593. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7594. /**
  7595. * Returns the mesh pivot matrix.
  7596. * Default : Identity.
  7597. * @returns the matrix
  7598. */
  7599. getPivotMatrix(): Matrix;
  7600. /**
  7601. * Prevents the World matrix to be computed any longer.
  7602. * @returns the TransformNode.
  7603. */
  7604. freezeWorldMatrix(): TransformNode;
  7605. /**
  7606. * Allows back the World matrix computation.
  7607. * @returns the TransformNode.
  7608. */
  7609. unfreezeWorldMatrix(): this;
  7610. /**
  7611. * True if the World matrix has been frozen.
  7612. */
  7613. readonly isWorldMatrixFrozen: boolean;
  7614. /**
  7615. * Retuns the mesh absolute position in the World.
  7616. * @returns a Vector3.
  7617. */
  7618. getAbsolutePosition(): Vector3;
  7619. /**
  7620. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7621. * @param absolutePosition the absolute position to set
  7622. * @returns the TransformNode.
  7623. */
  7624. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7625. /**
  7626. * Sets the mesh position in its local space.
  7627. * @param vector3 the position to set in localspace
  7628. * @returns the TransformNode.
  7629. */
  7630. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7631. /**
  7632. * Returns the mesh position in the local space from the current World matrix values.
  7633. * @returns a new Vector3.
  7634. */
  7635. getPositionExpressedInLocalSpace(): Vector3;
  7636. /**
  7637. * Translates the mesh along the passed Vector3 in its local space.
  7638. * @param vector3 the distance to translate in localspace
  7639. * @returns the TransformNode.
  7640. */
  7641. locallyTranslate(vector3: Vector3): TransformNode;
  7642. private static _lookAtVectorCache;
  7643. /**
  7644. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7645. * @param targetPoint the position (must be in same space as current mesh) to look at
  7646. * @param yawCor optional yaw (y-axis) correction in radians
  7647. * @param pitchCor optional pitch (x-axis) correction in radians
  7648. * @param rollCor optional roll (z-axis) correction in radians
  7649. * @param space the choosen space of the target
  7650. * @returns the TransformNode.
  7651. */
  7652. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7653. /**
  7654. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7655. * This Vector3 is expressed in the World space.
  7656. * @param localAxis axis to rotate
  7657. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7658. */
  7659. getDirection(localAxis: Vector3): Vector3;
  7660. /**
  7661. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7662. * localAxis is expressed in the mesh local space.
  7663. * result is computed in the Wordl space from the mesh World matrix.
  7664. * @param localAxis axis to rotate
  7665. * @param result the resulting transformnode
  7666. * @returns this TransformNode.
  7667. */
  7668. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7669. /**
  7670. * Sets this transform node rotation to the given local axis.
  7671. * @param localAxis the axis in local space
  7672. * @param yawCor optional yaw (y-axis) correction in radians
  7673. * @param pitchCor optional pitch (x-axis) correction in radians
  7674. * @param rollCor optional roll (z-axis) correction in radians
  7675. * @returns this TransformNode
  7676. */
  7677. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7678. /**
  7679. * Sets a new pivot point to the current node
  7680. * @param point defines the new pivot point to use
  7681. * @param space defines if the point is in world or local space (local by default)
  7682. * @returns the current TransformNode
  7683. */
  7684. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7685. /**
  7686. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7687. * @returns the pivot point
  7688. */
  7689. getPivotPoint(): Vector3;
  7690. /**
  7691. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7692. * @param result the vector3 to store the result
  7693. * @returns this TransformNode.
  7694. */
  7695. getPivotPointToRef(result: Vector3): TransformNode;
  7696. /**
  7697. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7698. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7699. */
  7700. getAbsolutePivotPoint(): Vector3;
  7701. /**
  7702. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7703. * @param result vector3 to store the result
  7704. * @returns this TransformNode.
  7705. */
  7706. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7707. /**
  7708. * Defines the passed node as the parent of the current node.
  7709. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7710. * @param node the node ot set as the parent
  7711. * @returns this TransformNode.
  7712. */
  7713. setParent(node: Nullable<Node>): TransformNode;
  7714. private _nonUniformScaling;
  7715. /**
  7716. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7717. */
  7718. readonly nonUniformScaling: boolean;
  7719. /** @hidden */
  7720. _updateNonUniformScalingState(value: boolean): boolean;
  7721. /**
  7722. * Attach the current TransformNode to another TransformNode associated with a bone
  7723. * @param bone Bone affecting the TransformNode
  7724. * @param affectedTransformNode TransformNode associated with the bone
  7725. * @returns this object
  7726. */
  7727. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7728. /**
  7729. * Detach the transform node if its associated with a bone
  7730. * @returns this object
  7731. */
  7732. detachFromBone(): TransformNode;
  7733. private static _rotationAxisCache;
  7734. /**
  7735. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7736. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7737. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7738. * The passed axis is also normalized.
  7739. * @param axis the axis to rotate around
  7740. * @param amount the amount to rotate in radians
  7741. * @param space Space to rotate in (Default: local)
  7742. * @returns the TransformNode.
  7743. */
  7744. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7745. /**
  7746. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7747. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7748. * The passed axis is also normalized. .
  7749. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7750. * @param point the point to rotate around
  7751. * @param axis the axis to rotate around
  7752. * @param amount the amount to rotate in radians
  7753. * @returns the TransformNode
  7754. */
  7755. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7756. /**
  7757. * Translates the mesh along the axis vector for the passed distance in the given space.
  7758. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7759. * @param axis the axis to translate in
  7760. * @param distance the distance to translate
  7761. * @param space Space to rotate in (Default: local)
  7762. * @returns the TransformNode.
  7763. */
  7764. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7765. /**
  7766. * Adds a rotation step to the mesh current rotation.
  7767. * x, y, z are Euler angles expressed in radians.
  7768. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7769. * This means this rotation is made in the mesh local space only.
  7770. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7771. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7772. * ```javascript
  7773. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7774. * ```
  7775. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7776. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  7777. * @param x Rotation to add
  7778. * @param y Rotation to add
  7779. * @param z Rotation to add
  7780. * @returns the TransformNode.
  7781. */
  7782. addRotation(x: number, y: number, z: number): TransformNode;
  7783. /**
  7784. * Computes the world matrix of the node
  7785. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7786. * @returns the world matrix
  7787. */
  7788. computeWorldMatrix(force?: boolean): Matrix;
  7789. protected _afterComputeWorldMatrix(): void;
  7790. /**
  7791. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7792. * @param func callback function to add
  7793. *
  7794. * @returns the TransformNode.
  7795. */
  7796. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7797. /**
  7798. * Removes a registered callback function.
  7799. * @param func callback function to remove
  7800. * @returns the TransformNode.
  7801. */
  7802. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7803. /**
  7804. * Gets the position of the current mesh in camera space
  7805. * @param camera defines the camera to use
  7806. * @returns a position
  7807. */
  7808. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7809. /**
  7810. * Returns the distance from the mesh to the active camera
  7811. * @param camera defines the camera to use
  7812. * @returns the distance
  7813. */
  7814. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7815. /**
  7816. * Clone the current transform node
  7817. * @param name Name of the new clone
  7818. * @param newParent New parent for the clone
  7819. * @param doNotCloneChildren Do not clone children hierarchy
  7820. * @returns the new transform node
  7821. */
  7822. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7823. /**
  7824. * Serializes the objects information.
  7825. * @param currentSerializationObject defines the object to serialize in
  7826. * @returns the serialized object
  7827. */
  7828. serialize(currentSerializationObject?: any): any;
  7829. /**
  7830. * Returns a new TransformNode object parsed from the source provided.
  7831. * @param parsedTransformNode is the source.
  7832. * @param scene the scne the object belongs to
  7833. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7834. * @returns a new TransformNode object parsed from the source provided.
  7835. */
  7836. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7837. /**
  7838. * Get all child-transformNodes of this node
  7839. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  7840. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  7841. * @returns an array of TransformNode
  7842. */
  7843. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7844. /**
  7845. * Releases resources associated with this transform node.
  7846. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7847. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7848. */
  7849. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7850. }
  7851. }
  7852. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7853. /**
  7854. * Class used to override all child animations of a given target
  7855. */
  7856. export class AnimationPropertiesOverride {
  7857. /**
  7858. * Gets or sets a value indicating if animation blending must be used
  7859. */
  7860. enableBlending: boolean;
  7861. /**
  7862. * Gets or sets the blending speed to use when enableBlending is true
  7863. */
  7864. blendingSpeed: number;
  7865. /**
  7866. * Gets or sets the default loop mode to use
  7867. */
  7868. loopMode: number;
  7869. }
  7870. }
  7871. declare module "babylonjs/Bones/bone" {
  7872. import { Skeleton } from "babylonjs/Bones/skeleton";
  7873. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7874. import { Nullable } from "babylonjs/types";
  7875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7876. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7877. import { Node } from "babylonjs/node";
  7878. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7879. /**
  7880. * Class used to store bone information
  7881. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7882. */
  7883. export class Bone extends Node {
  7884. /**
  7885. * defines the bone name
  7886. */
  7887. name: string;
  7888. private static _tmpVecs;
  7889. private static _tmpQuat;
  7890. private static _tmpMats;
  7891. /**
  7892. * Gets the list of child bones
  7893. */
  7894. children: Bone[];
  7895. /** Gets the animations associated with this bone */
  7896. animations: import("babylonjs/Animations/animation").Animation[];
  7897. /**
  7898. * Gets or sets bone length
  7899. */
  7900. length: number;
  7901. /**
  7902. * @hidden Internal only
  7903. * Set this value to map this bone to a different index in the transform matrices
  7904. * Set this value to -1 to exclude the bone from the transform matrices
  7905. */
  7906. _index: Nullable<number>;
  7907. private _skeleton;
  7908. private _localMatrix;
  7909. private _restPose;
  7910. private _baseMatrix;
  7911. private _absoluteTransform;
  7912. private _invertedAbsoluteTransform;
  7913. private _parent;
  7914. private _scalingDeterminant;
  7915. private _worldTransform;
  7916. private _localScaling;
  7917. private _localRotation;
  7918. private _localPosition;
  7919. private _needToDecompose;
  7920. private _needToCompose;
  7921. /** @hidden */
  7922. _linkedTransformNode: Nullable<TransformNode>;
  7923. /** @hidden */
  7924. /** @hidden */
  7925. _matrix: Matrix;
  7926. /**
  7927. * Create a new bone
  7928. * @param name defines the bone name
  7929. * @param skeleton defines the parent skeleton
  7930. * @param parentBone defines the parent (can be null if the bone is the root)
  7931. * @param localMatrix defines the local matrix
  7932. * @param restPose defines the rest pose matrix
  7933. * @param baseMatrix defines the base matrix
  7934. * @param index defines index of the bone in the hiearchy
  7935. */
  7936. constructor(
  7937. /**
  7938. * defines the bone name
  7939. */
  7940. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7941. /**
  7942. * Gets the current object class name.
  7943. * @return the class name
  7944. */
  7945. getClassName(): string;
  7946. /**
  7947. * Gets the parent skeleton
  7948. * @returns a skeleton
  7949. */
  7950. getSkeleton(): Skeleton;
  7951. /**
  7952. * Gets parent bone
  7953. * @returns a bone or null if the bone is the root of the bone hierarchy
  7954. */
  7955. getParent(): Nullable<Bone>;
  7956. /**
  7957. * Returns an array containing the root bones
  7958. * @returns an array containing the root bones
  7959. */
  7960. getChildren(): Array<Bone>;
  7961. /**
  7962. * Sets the parent bone
  7963. * @param parent defines the parent (can be null if the bone is the root)
  7964. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7965. */
  7966. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7967. /**
  7968. * Gets the local matrix
  7969. * @returns a matrix
  7970. */
  7971. getLocalMatrix(): Matrix;
  7972. /**
  7973. * Gets the base matrix (initial matrix which remains unchanged)
  7974. * @returns a matrix
  7975. */
  7976. getBaseMatrix(): Matrix;
  7977. /**
  7978. * Gets the rest pose matrix
  7979. * @returns a matrix
  7980. */
  7981. getRestPose(): Matrix;
  7982. /**
  7983. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7984. */
  7985. getWorldMatrix(): Matrix;
  7986. /**
  7987. * Sets the local matrix to rest pose matrix
  7988. */
  7989. returnToRest(): void;
  7990. /**
  7991. * Gets the inverse of the absolute transform matrix.
  7992. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7993. * @returns a matrix
  7994. */
  7995. getInvertedAbsoluteTransform(): Matrix;
  7996. /**
  7997. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7998. * @returns a matrix
  7999. */
  8000. getAbsoluteTransform(): Matrix;
  8001. /**
  8002. * Links with the given transform node.
  8003. * The local matrix of this bone is copied from the transform node every frame.
  8004. * @param transformNode defines the transform node to link to
  8005. */
  8006. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8007. /** Gets or sets current position (in local space) */
  8008. position: Vector3;
  8009. /** Gets or sets current rotation (in local space) */
  8010. rotation: Vector3;
  8011. /** Gets or sets current rotation quaternion (in local space) */
  8012. rotationQuaternion: Quaternion;
  8013. /** Gets or sets current scaling (in local space) */
  8014. scaling: Vector3;
  8015. /**
  8016. * Gets the animation properties override
  8017. */
  8018. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8019. private _decompose;
  8020. private _compose;
  8021. /**
  8022. * Update the base and local matrices
  8023. * @param matrix defines the new base or local matrix
  8024. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8025. * @param updateLocalMatrix defines if the local matrix should be updated
  8026. */
  8027. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8028. /** @hidden */
  8029. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8030. /**
  8031. * Flag the bone as dirty (Forcing it to update everything)
  8032. */
  8033. markAsDirty(): void;
  8034. private _markAsDirtyAndCompose;
  8035. private _markAsDirtyAndDecompose;
  8036. /**
  8037. * Translate the bone in local or world space
  8038. * @param vec The amount to translate the bone
  8039. * @param space The space that the translation is in
  8040. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8041. */
  8042. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8043. /**
  8044. * Set the postion of the bone in local or world space
  8045. * @param position The position to set the bone
  8046. * @param space The space that the position is in
  8047. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8048. */
  8049. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8050. /**
  8051. * Set the absolute position of the bone (world space)
  8052. * @param position The position to set the bone
  8053. * @param mesh The mesh that this bone is attached to
  8054. */
  8055. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8056. /**
  8057. * Scale the bone on the x, y and z axes (in local space)
  8058. * @param x The amount to scale the bone on the x axis
  8059. * @param y The amount to scale the bone on the y axis
  8060. * @param z The amount to scale the bone on the z axis
  8061. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8062. */
  8063. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8064. /**
  8065. * Set the bone scaling in local space
  8066. * @param scale defines the scaling vector
  8067. */
  8068. setScale(scale: Vector3): void;
  8069. /**
  8070. * Gets the current scaling in local space
  8071. * @returns the current scaling vector
  8072. */
  8073. getScale(): Vector3;
  8074. /**
  8075. * Gets the current scaling in local space and stores it in a target vector
  8076. * @param result defines the target vector
  8077. */
  8078. getScaleToRef(result: Vector3): void;
  8079. /**
  8080. * Set the yaw, pitch, and roll of the bone in local or world space
  8081. * @param yaw The rotation of the bone on the y axis
  8082. * @param pitch The rotation of the bone on the x axis
  8083. * @param roll The rotation of the bone on the z axis
  8084. * @param space The space that the axes of rotation are in
  8085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8086. */
  8087. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8088. /**
  8089. * Add a rotation to the bone on an axis in local or world space
  8090. * @param axis The axis to rotate the bone on
  8091. * @param amount The amount to rotate the bone
  8092. * @param space The space that the axis is in
  8093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8094. */
  8095. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8096. /**
  8097. * Set the rotation of the bone to a particular axis angle in local or world space
  8098. * @param axis The axis to rotate the bone on
  8099. * @param angle The angle that the bone should be rotated to
  8100. * @param space The space that the axis is in
  8101. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8102. */
  8103. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8104. /**
  8105. * Set the euler rotation of the bone in local of world space
  8106. * @param rotation The euler rotation that the bone should be set to
  8107. * @param space The space that the rotation is in
  8108. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8109. */
  8110. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8111. /**
  8112. * Set the quaternion rotation of the bone in local of world space
  8113. * @param quat The quaternion rotation that the bone should be set to
  8114. * @param space The space that the rotation is in
  8115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8116. */
  8117. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8118. /**
  8119. * Set the rotation matrix of the bone in local of world space
  8120. * @param rotMat The rotation matrix that the bone should be set to
  8121. * @param space The space that the rotation is in
  8122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8123. */
  8124. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8125. private _rotateWithMatrix;
  8126. private _getNegativeRotationToRef;
  8127. /**
  8128. * Get the position of the bone in local or world space
  8129. * @param space The space that the returned position is in
  8130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8131. * @returns The position of the bone
  8132. */
  8133. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8134. /**
  8135. * Copy the position of the bone to a vector3 in local or world space
  8136. * @param space The space that the returned position is in
  8137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8138. * @param result The vector3 to copy the position to
  8139. */
  8140. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8141. /**
  8142. * Get the absolute position of the bone (world space)
  8143. * @param mesh The mesh that this bone is attached to
  8144. * @returns The absolute position of the bone
  8145. */
  8146. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8147. /**
  8148. * Copy the absolute position of the bone (world space) to the result param
  8149. * @param mesh The mesh that this bone is attached to
  8150. * @param result The vector3 to copy the absolute position to
  8151. */
  8152. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8153. /**
  8154. * Compute the absolute transforms of this bone and its children
  8155. */
  8156. computeAbsoluteTransforms(): void;
  8157. /**
  8158. * Get the world direction from an axis that is in the local space of the bone
  8159. * @param localAxis The local direction that is used to compute the world direction
  8160. * @param mesh The mesh that this bone is attached to
  8161. * @returns The world direction
  8162. */
  8163. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8164. /**
  8165. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8166. * @param localAxis The local direction that is used to compute the world direction
  8167. * @param mesh The mesh that this bone is attached to
  8168. * @param result The vector3 that the world direction will be copied to
  8169. */
  8170. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8171. /**
  8172. * Get the euler rotation of the bone in local or world space
  8173. * @param space The space that the rotation should be in
  8174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8175. * @returns The euler rotation
  8176. */
  8177. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8178. /**
  8179. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8180. * @param space The space that the rotation should be in
  8181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8182. * @param result The vector3 that the rotation should be copied to
  8183. */
  8184. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8185. /**
  8186. * Get the quaternion rotation of the bone in either local or world space
  8187. * @param space The space that the rotation should be in
  8188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8189. * @returns The quaternion rotation
  8190. */
  8191. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8192. /**
  8193. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8194. * @param space The space that the rotation should be in
  8195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8196. * @param result The quaternion that the rotation should be copied to
  8197. */
  8198. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8199. /**
  8200. * Get the rotation matrix of the bone in local or world space
  8201. * @param space The space that the rotation should be in
  8202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8203. * @returns The rotation matrix
  8204. */
  8205. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8206. /**
  8207. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8208. * @param space The space that the rotation should be in
  8209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8210. * @param result The quaternion that the rotation should be copied to
  8211. */
  8212. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8213. /**
  8214. * Get the world position of a point that is in the local space of the bone
  8215. * @param position The local position
  8216. * @param mesh The mesh that this bone is attached to
  8217. * @returns The world position
  8218. */
  8219. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8220. /**
  8221. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8222. * @param position The local position
  8223. * @param mesh The mesh that this bone is attached to
  8224. * @param result The vector3 that the world position should be copied to
  8225. */
  8226. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8227. /**
  8228. * Get the local position of a point that is in world space
  8229. * @param position The world position
  8230. * @param mesh The mesh that this bone is attached to
  8231. * @returns The local position
  8232. */
  8233. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8234. /**
  8235. * Get the local position of a point that is in world space and copy it to the result param
  8236. * @param position The world position
  8237. * @param mesh The mesh that this bone is attached to
  8238. * @param result The vector3 that the local position should be copied to
  8239. */
  8240. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8241. }
  8242. }
  8243. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8244. import { Nullable } from "babylonjs/types";
  8245. import { Scene } from "babylonjs/scene";
  8246. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8248. /**
  8249. * Class for creating a cube texture
  8250. */
  8251. export class CubeTexture extends BaseTexture {
  8252. private _delayedOnLoad;
  8253. /**
  8254. * The url of the texture
  8255. */
  8256. url: string;
  8257. /**
  8258. * Gets or sets the center of the bounding box associated with the cube texture.
  8259. * It must define where the camera used to render the texture was set
  8260. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8261. */
  8262. boundingBoxPosition: Vector3;
  8263. private _boundingBoxSize;
  8264. /**
  8265. * Gets or sets the size of the bounding box associated with the cube texture
  8266. * When defined, the cubemap will switch to local mode
  8267. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8268. * @example https://www.babylonjs-playground.com/#RNASML
  8269. */
  8270. /**
  8271. * Returns the bounding box size
  8272. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8273. */
  8274. boundingBoxSize: Vector3;
  8275. protected _rotationY: number;
  8276. /**
  8277. * Sets texture matrix rotation angle around Y axis in radians.
  8278. */
  8279. /**
  8280. * Gets texture matrix rotation angle around Y axis radians.
  8281. */
  8282. rotationY: number;
  8283. /**
  8284. * Are mip maps generated for this texture or not.
  8285. */
  8286. readonly noMipmap: boolean;
  8287. private _noMipmap;
  8288. private _files;
  8289. private _extensions;
  8290. private _textureMatrix;
  8291. private _format;
  8292. private _createPolynomials;
  8293. /** @hidden */
  8294. _prefiltered: boolean;
  8295. /**
  8296. * Creates a cube texture from an array of image urls
  8297. * @param files defines an array of image urls
  8298. * @param scene defines the hosting scene
  8299. * @param noMipmap specifies if mip maps are not used
  8300. * @returns a cube texture
  8301. */
  8302. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8303. /**
  8304. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8305. * @param url defines the url of the prefiltered texture
  8306. * @param scene defines the scene the texture is attached to
  8307. * @param forcedExtension defines the extension of the file if different from the url
  8308. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8309. * @return the prefiltered texture
  8310. */
  8311. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8312. /**
  8313. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8314. * as prefiltered data.
  8315. * @param rootUrl defines the url of the texture or the root name of the six images
  8316. * @param scene defines the scene the texture is attached to
  8317. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8318. * @param noMipmap defines if mipmaps should be created or not
  8319. * @param files defines the six files to load for the different faces
  8320. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8321. * @param onError defines a callback triggered in case of error during load
  8322. * @param format defines the internal format to use for the texture once loaded
  8323. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8324. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8325. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8326. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8327. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8328. * @return the cube texture
  8329. */
  8330. 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);
  8331. /**
  8332. * Get the current class name of the texture useful for serialization or dynamic coding.
  8333. * @returns "CubeTexture"
  8334. */
  8335. getClassName(): string;
  8336. /**
  8337. * Update the url (and optional buffer) of this texture if url was null during construction.
  8338. * @param url the url of the texture
  8339. * @param forcedExtension defines the extension to use
  8340. * @param onLoad callback called when the texture is loaded (defaults to null)
  8341. */
  8342. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8343. /**
  8344. * Delays loading of the cube texture
  8345. * @param forcedExtension defines the extension to use
  8346. */
  8347. delayLoad(forcedExtension?: string): void;
  8348. /**
  8349. * Returns the reflection texture matrix
  8350. * @returns the reflection texture matrix
  8351. */
  8352. getReflectionTextureMatrix(): Matrix;
  8353. /**
  8354. * Sets the reflection texture matrix
  8355. * @param value Reflection texture matrix
  8356. */
  8357. setReflectionTextureMatrix(value: Matrix): void;
  8358. /**
  8359. * Parses text to create a cube texture
  8360. * @param parsedTexture define the serialized text to read from
  8361. * @param scene defines the hosting scene
  8362. * @param rootUrl defines the root url of the cube texture
  8363. * @returns a cube texture
  8364. */
  8365. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8366. /**
  8367. * Makes a clone, or deep copy, of the cube texture
  8368. * @returns a new cube texture
  8369. */
  8370. clone(): CubeTexture;
  8371. }
  8372. }
  8373. declare module "babylonjs/Shaders/postprocess.vertex" {
  8374. /** @hidden */
  8375. export var postprocessVertexShader: {
  8376. name: string;
  8377. shader: string;
  8378. };
  8379. }
  8380. declare module "babylonjs/Cameras/targetCamera" {
  8381. import { Nullable } from "babylonjs/types";
  8382. import { Camera } from "babylonjs/Cameras/camera";
  8383. import { Scene } from "babylonjs/scene";
  8384. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8385. /**
  8386. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8387. * This is the base of the follow, arc rotate cameras and Free camera
  8388. * @see http://doc.babylonjs.com/features/cameras
  8389. */
  8390. export class TargetCamera extends Camera {
  8391. private static _RigCamTransformMatrix;
  8392. private static _TargetTransformMatrix;
  8393. private static _TargetFocalPoint;
  8394. /**
  8395. * Define the current direction the camera is moving to
  8396. */
  8397. cameraDirection: Vector3;
  8398. /**
  8399. * Define the current rotation the camera is rotating to
  8400. */
  8401. cameraRotation: Vector2;
  8402. /**
  8403. * When set, the up vector of the camera will be updated by the rotation of the camera
  8404. */
  8405. updateUpVectorFromRotation: boolean;
  8406. private _tmpQuaternion;
  8407. /**
  8408. * Define the current rotation of the camera
  8409. */
  8410. rotation: Vector3;
  8411. /**
  8412. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8413. */
  8414. rotationQuaternion: Quaternion;
  8415. /**
  8416. * Define the current speed of the camera
  8417. */
  8418. speed: number;
  8419. /**
  8420. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8421. * around all axis.
  8422. */
  8423. noRotationConstraint: boolean;
  8424. /**
  8425. * Define the current target of the camera as an object or a position.
  8426. */
  8427. lockedTarget: any;
  8428. /** @hidden */
  8429. _currentTarget: Vector3;
  8430. /** @hidden */
  8431. _initialFocalDistance: number;
  8432. /** @hidden */
  8433. _viewMatrix: Matrix;
  8434. /** @hidden */
  8435. _camMatrix: Matrix;
  8436. /** @hidden */
  8437. _cameraTransformMatrix: Matrix;
  8438. /** @hidden */
  8439. _cameraRotationMatrix: Matrix;
  8440. /** @hidden */
  8441. _referencePoint: Vector3;
  8442. /** @hidden */
  8443. _transformedReferencePoint: Vector3;
  8444. protected _globalCurrentTarget: Vector3;
  8445. protected _globalCurrentUpVector: Vector3;
  8446. /** @hidden */
  8447. _reset: () => void;
  8448. private _defaultUp;
  8449. /**
  8450. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8451. * This is the base of the follow, arc rotate cameras and Free camera
  8452. * @see http://doc.babylonjs.com/features/cameras
  8453. * @param name Defines the name of the camera in the scene
  8454. * @param position Defines the start position of the camera in the scene
  8455. * @param scene Defines the scene the camera belongs to
  8456. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8457. */
  8458. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8459. /**
  8460. * Gets the position in front of the camera at a given distance.
  8461. * @param distance The distance from the camera we want the position to be
  8462. * @returns the position
  8463. */
  8464. getFrontPosition(distance: number): Vector3;
  8465. /** @hidden */
  8466. _getLockedTargetPosition(): Nullable<Vector3>;
  8467. private _storedPosition;
  8468. private _storedRotation;
  8469. private _storedRotationQuaternion;
  8470. /**
  8471. * Store current camera state of the camera (fov, position, rotation, etc..)
  8472. * @returns the camera
  8473. */
  8474. storeState(): Camera;
  8475. /**
  8476. * Restored camera state. You must call storeState() first
  8477. * @returns whether it was successful or not
  8478. * @hidden
  8479. */
  8480. _restoreStateValues(): boolean;
  8481. /** @hidden */
  8482. _initCache(): void;
  8483. /** @hidden */
  8484. _updateCache(ignoreParentClass?: boolean): void;
  8485. /** @hidden */
  8486. _isSynchronizedViewMatrix(): boolean;
  8487. /** @hidden */
  8488. _computeLocalCameraSpeed(): number;
  8489. /** @hidden */
  8490. setTarget(target: Vector3): void;
  8491. /**
  8492. * Return the current target position of the camera. This value is expressed in local space.
  8493. * @returns the target position
  8494. */
  8495. getTarget(): Vector3;
  8496. /** @hidden */
  8497. _decideIfNeedsToMove(): boolean;
  8498. /** @hidden */
  8499. _updatePosition(): void;
  8500. /** @hidden */
  8501. _checkInputs(): void;
  8502. protected _updateCameraRotationMatrix(): void;
  8503. /**
  8504. * 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)
  8505. * @returns the current camera
  8506. */
  8507. private _rotateUpVectorWithCameraRotationMatrix;
  8508. private _cachedRotationZ;
  8509. private _cachedQuaternionRotationZ;
  8510. /** @hidden */
  8511. _getViewMatrix(): Matrix;
  8512. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8513. /**
  8514. * @hidden
  8515. */
  8516. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8517. /**
  8518. * @hidden
  8519. */
  8520. _updateRigCameras(): void;
  8521. private _getRigCamPositionAndTarget;
  8522. /**
  8523. * Gets the current object class name.
  8524. * @return the class name
  8525. */
  8526. getClassName(): string;
  8527. }
  8528. }
  8529. declare module "babylonjs/Cameras/cameraInputsManager" {
  8530. import { Nullable } from "babylonjs/types";
  8531. import { Camera } from "babylonjs/Cameras/camera";
  8532. /**
  8533. * @ignore
  8534. * This is a list of all the different input types that are available in the application.
  8535. * Fo instance: ArcRotateCameraGamepadInput...
  8536. */
  8537. export var CameraInputTypes: {};
  8538. /**
  8539. * This is the contract to implement in order to create a new input class.
  8540. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8541. */
  8542. export interface ICameraInput<TCamera extends Camera> {
  8543. /**
  8544. * Defines the camera the input is attached to.
  8545. */
  8546. camera: Nullable<TCamera>;
  8547. /**
  8548. * Gets the class name of the current intput.
  8549. * @returns the class name
  8550. */
  8551. getClassName(): string;
  8552. /**
  8553. * Get the friendly name associated with the input class.
  8554. * @returns the input friendly name
  8555. */
  8556. getSimpleName(): string;
  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. /**
  8575. * Represents a map of input types to input instance or input index to input instance.
  8576. */
  8577. export interface CameraInputsMap<TCamera extends Camera> {
  8578. /**
  8579. * Accessor to the input by input type.
  8580. */
  8581. [name: string]: ICameraInput<TCamera>;
  8582. /**
  8583. * Accessor to the input by input index.
  8584. */
  8585. [idx: number]: ICameraInput<TCamera>;
  8586. }
  8587. /**
  8588. * This represents the input manager used within a camera.
  8589. * It helps dealing with all the different kind of input attached to a camera.
  8590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8591. */
  8592. export class CameraInputsManager<TCamera extends Camera> {
  8593. /**
  8594. * Defines the list of inputs attahed to the camera.
  8595. */
  8596. attached: CameraInputsMap<TCamera>;
  8597. /**
  8598. * Defines the dom element the camera is collecting inputs from.
  8599. * This is null if the controls have not been attached.
  8600. */
  8601. attachedElement: Nullable<HTMLElement>;
  8602. /**
  8603. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8604. */
  8605. noPreventDefault: boolean;
  8606. /**
  8607. * Defined the camera the input manager belongs to.
  8608. */
  8609. camera: TCamera;
  8610. /**
  8611. * Update the current camera state depending on the inputs that have been used this frame.
  8612. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8613. */
  8614. checkInputs: () => void;
  8615. /**
  8616. * Instantiate a new Camera Input Manager.
  8617. * @param camera Defines the camera the input manager blongs to
  8618. */
  8619. constructor(camera: TCamera);
  8620. /**
  8621. * Add an input method to a camera
  8622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8623. * @param input camera input method
  8624. */
  8625. add(input: ICameraInput<TCamera>): void;
  8626. /**
  8627. * Remove a specific input method from a camera
  8628. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8629. * @param inputToRemove camera input method
  8630. */
  8631. remove(inputToRemove: ICameraInput<TCamera>): void;
  8632. /**
  8633. * Remove a specific input type from a camera
  8634. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8635. * @param inputType the type of the input to remove
  8636. */
  8637. removeByType(inputType: string): void;
  8638. private _addCheckInputs;
  8639. /**
  8640. * Attach the input controls to the currently attached dom element to listen the events from.
  8641. * @param input Defines the input to attach
  8642. */
  8643. attachInput(input: ICameraInput<TCamera>): void;
  8644. /**
  8645. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8646. * @param element Defines the dom element to collect the events from
  8647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8648. */
  8649. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8650. /**
  8651. * Detach the current manager inputs controls from a specific dom element.
  8652. * @param element Defines the dom element to collect the events from
  8653. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8654. */
  8655. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8656. /**
  8657. * Rebuild the dynamic inputCheck function from the current list of
  8658. * defined inputs in the manager.
  8659. */
  8660. rebuildInputCheck(): void;
  8661. /**
  8662. * Remove all attached input methods from a camera
  8663. */
  8664. clear(): void;
  8665. /**
  8666. * Serialize the current input manager attached to a camera.
  8667. * This ensures than once parsed,
  8668. * the input associated to the camera will be identical to the current ones
  8669. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8670. */
  8671. serialize(serializedCamera: any): void;
  8672. /**
  8673. * Parses an input manager serialized JSON to restore the previous list of inputs
  8674. * and states associated to a camera.
  8675. * @param parsedCamera Defines the JSON to parse
  8676. */
  8677. parse(parsedCamera: any): void;
  8678. }
  8679. }
  8680. declare module "babylonjs/Events/keyboardEvents" {
  8681. /**
  8682. * Gather the list of keyboard event types as constants.
  8683. */
  8684. export class KeyboardEventTypes {
  8685. /**
  8686. * The keydown event is fired when a key becomes active (pressed).
  8687. */
  8688. static readonly KEYDOWN: number;
  8689. /**
  8690. * The keyup event is fired when a key has been released.
  8691. */
  8692. static readonly KEYUP: number;
  8693. }
  8694. /**
  8695. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8696. */
  8697. export class KeyboardInfo {
  8698. /**
  8699. * Defines the type of event (KeyboardEventTypes)
  8700. */
  8701. type: number;
  8702. /**
  8703. * Defines the related dom event
  8704. */
  8705. event: KeyboardEvent;
  8706. /**
  8707. * Instantiates a new keyboard info.
  8708. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8709. * @param type Defines the type of event (KeyboardEventTypes)
  8710. * @param event Defines the related dom event
  8711. */
  8712. constructor(
  8713. /**
  8714. * Defines the type of event (KeyboardEventTypes)
  8715. */
  8716. type: number,
  8717. /**
  8718. * Defines the related dom event
  8719. */
  8720. event: KeyboardEvent);
  8721. }
  8722. /**
  8723. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8724. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8725. */
  8726. export class KeyboardInfoPre extends KeyboardInfo {
  8727. /**
  8728. * Defines the type of event (KeyboardEventTypes)
  8729. */
  8730. type: number;
  8731. /**
  8732. * Defines the related dom event
  8733. */
  8734. event: KeyboardEvent;
  8735. /**
  8736. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8737. */
  8738. skipOnPointerObservable: boolean;
  8739. /**
  8740. * Instantiates a new keyboard pre info.
  8741. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8742. * @param type Defines the type of event (KeyboardEventTypes)
  8743. * @param event Defines the related dom event
  8744. */
  8745. constructor(
  8746. /**
  8747. * Defines the type of event (KeyboardEventTypes)
  8748. */
  8749. type: number,
  8750. /**
  8751. * Defines the related dom event
  8752. */
  8753. event: KeyboardEvent);
  8754. }
  8755. }
  8756. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8757. import { Nullable } from "babylonjs/types";
  8758. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8759. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8760. /**
  8761. * Manage the keyboard inputs to control the movement of a free camera.
  8762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8763. */
  8764. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8765. /**
  8766. * Defines the camera the input is attached to.
  8767. */
  8768. camera: FreeCamera;
  8769. /**
  8770. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8771. */
  8772. keysUp: number[];
  8773. /**
  8774. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8775. */
  8776. keysDown: number[];
  8777. /**
  8778. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8779. */
  8780. keysLeft: number[];
  8781. /**
  8782. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8783. */
  8784. keysRight: number[];
  8785. private _keys;
  8786. private _onCanvasBlurObserver;
  8787. private _onKeyboardObserver;
  8788. private _engine;
  8789. private _scene;
  8790. /**
  8791. * Attach the input controls to a specific dom element to get the input from.
  8792. * @param element Defines the element the controls should be listened from
  8793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8794. */
  8795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8796. /**
  8797. * Detach the current controls from the specified dom element.
  8798. * @param element Defines the element to stop listening the inputs from
  8799. */
  8800. detachControl(element: Nullable<HTMLElement>): void;
  8801. /**
  8802. * Update the current camera state depending on the inputs that have been used this frame.
  8803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8804. */
  8805. checkInputs(): void;
  8806. /**
  8807. * Gets the class name of the current intput.
  8808. * @returns the class name
  8809. */
  8810. getClassName(): string;
  8811. /** @hidden */
  8812. _onLostFocus(): void;
  8813. /**
  8814. * Get the friendly name associated with the input class.
  8815. * @returns the input friendly name
  8816. */
  8817. getSimpleName(): string;
  8818. }
  8819. }
  8820. declare module "babylonjs/Lights/shadowLight" {
  8821. import { Camera } from "babylonjs/Cameras/camera";
  8822. import { Scene } from "babylonjs/scene";
  8823. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8825. import { Light } from "babylonjs/Lights/light";
  8826. /**
  8827. * Interface describing all the common properties and methods a shadow light needs to implement.
  8828. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8829. * as well as binding the different shadow properties to the effects.
  8830. */
  8831. export interface IShadowLight extends Light {
  8832. /**
  8833. * The light id in the scene (used in scene.findLighById for instance)
  8834. */
  8835. id: string;
  8836. /**
  8837. * The position the shdow will be casted from.
  8838. */
  8839. position: Vector3;
  8840. /**
  8841. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8842. */
  8843. direction: Vector3;
  8844. /**
  8845. * The transformed position. Position of the light in world space taking parenting in account.
  8846. */
  8847. transformedPosition: Vector3;
  8848. /**
  8849. * The transformed direction. Direction of the light in world space taking parenting in account.
  8850. */
  8851. transformedDirection: Vector3;
  8852. /**
  8853. * The friendly name of the light in the scene.
  8854. */
  8855. name: string;
  8856. /**
  8857. * Defines the shadow projection clipping minimum z value.
  8858. */
  8859. shadowMinZ: number;
  8860. /**
  8861. * Defines the shadow projection clipping maximum z value.
  8862. */
  8863. shadowMaxZ: number;
  8864. /**
  8865. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8866. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8867. */
  8868. computeTransformedInformation(): boolean;
  8869. /**
  8870. * Gets the scene the light belongs to.
  8871. * @returns The scene
  8872. */
  8873. getScene(): Scene;
  8874. /**
  8875. * Callback defining a custom Projection Matrix Builder.
  8876. * This can be used to override the default projection matrix computation.
  8877. */
  8878. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8879. /**
  8880. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8881. * @param matrix The materix to updated with the projection information
  8882. * @param viewMatrix The transform matrix of the light
  8883. * @param renderList The list of mesh to render in the map
  8884. * @returns The current light
  8885. */
  8886. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8887. /**
  8888. * Gets the current depth scale used in ESM.
  8889. * @returns The scale
  8890. */
  8891. getDepthScale(): number;
  8892. /**
  8893. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8894. * @returns true if a cube texture needs to be use
  8895. */
  8896. needCube(): boolean;
  8897. /**
  8898. * Detects if the projection matrix requires to be recomputed this frame.
  8899. * @returns true if it requires to be recomputed otherwise, false.
  8900. */
  8901. needProjectionMatrixCompute(): boolean;
  8902. /**
  8903. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8904. */
  8905. forceProjectionMatrixCompute(): void;
  8906. /**
  8907. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8908. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8909. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8910. */
  8911. getShadowDirection(faceIndex?: number): Vector3;
  8912. /**
  8913. * Gets the minZ used for shadow according to both the scene and the light.
  8914. * @param activeCamera The camera we are returning the min for
  8915. * @returns the depth min z
  8916. */
  8917. getDepthMinZ(activeCamera: Camera): number;
  8918. /**
  8919. * Gets the maxZ used for shadow according to both the scene and the light.
  8920. * @param activeCamera The camera we are returning the max for
  8921. * @returns the depth max z
  8922. */
  8923. getDepthMaxZ(activeCamera: Camera): number;
  8924. }
  8925. /**
  8926. * Base implementation IShadowLight
  8927. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8928. */
  8929. export abstract class ShadowLight extends Light implements IShadowLight {
  8930. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8931. protected _position: Vector3;
  8932. protected _setPosition(value: Vector3): void;
  8933. /**
  8934. * Sets the position the shadow will be casted from. Also use as the light position for both
  8935. * point and spot lights.
  8936. */
  8937. /**
  8938. * Sets the position the shadow will be casted from. Also use as the light position for both
  8939. * point and spot lights.
  8940. */
  8941. position: Vector3;
  8942. protected _direction: Vector3;
  8943. protected _setDirection(value: Vector3): void;
  8944. /**
  8945. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8946. * Also use as the light direction on spot and directional lights.
  8947. */
  8948. /**
  8949. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8950. * Also use as the light direction on spot and directional lights.
  8951. */
  8952. direction: Vector3;
  8953. private _shadowMinZ;
  8954. /**
  8955. * Gets the shadow projection clipping minimum z value.
  8956. */
  8957. /**
  8958. * Sets the shadow projection clipping minimum z value.
  8959. */
  8960. shadowMinZ: number;
  8961. private _shadowMaxZ;
  8962. /**
  8963. * Sets the shadow projection clipping maximum z value.
  8964. */
  8965. /**
  8966. * Gets the shadow projection clipping maximum z value.
  8967. */
  8968. shadowMaxZ: number;
  8969. /**
  8970. * Callback defining a custom Projection Matrix Builder.
  8971. * This can be used to override the default projection matrix computation.
  8972. */
  8973. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8974. /**
  8975. * The transformed position. Position of the light in world space taking parenting in account.
  8976. */
  8977. transformedPosition: Vector3;
  8978. /**
  8979. * The transformed direction. Direction of the light in world space taking parenting in account.
  8980. */
  8981. transformedDirection: Vector3;
  8982. private _needProjectionMatrixCompute;
  8983. /**
  8984. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8985. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8986. */
  8987. computeTransformedInformation(): boolean;
  8988. /**
  8989. * Return the depth scale used for the shadow map.
  8990. * @returns the depth scale.
  8991. */
  8992. getDepthScale(): number;
  8993. /**
  8994. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8995. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8996. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8997. */
  8998. getShadowDirection(faceIndex?: number): Vector3;
  8999. /**
  9000. * Returns the ShadowLight absolute position in the World.
  9001. * @returns the position vector in world space
  9002. */
  9003. getAbsolutePosition(): Vector3;
  9004. /**
  9005. * Sets the ShadowLight direction toward the passed target.
  9006. * @param target The point to target in local space
  9007. * @returns the updated ShadowLight direction
  9008. */
  9009. setDirectionToTarget(target: Vector3): Vector3;
  9010. /**
  9011. * Returns the light rotation in euler definition.
  9012. * @returns the x y z rotation in local space.
  9013. */
  9014. getRotation(): Vector3;
  9015. /**
  9016. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9017. * @returns true if a cube texture needs to be use
  9018. */
  9019. needCube(): boolean;
  9020. /**
  9021. * Detects if the projection matrix requires to be recomputed this frame.
  9022. * @returns true if it requires to be recomputed otherwise, false.
  9023. */
  9024. needProjectionMatrixCompute(): boolean;
  9025. /**
  9026. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9027. */
  9028. forceProjectionMatrixCompute(): void;
  9029. /** @hidden */
  9030. _initCache(): void;
  9031. /** @hidden */
  9032. _isSynchronized(): boolean;
  9033. /**
  9034. * Computes the world matrix of the node
  9035. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9036. * @returns the world matrix
  9037. */
  9038. computeWorldMatrix(force?: boolean): Matrix;
  9039. /**
  9040. * Gets the minZ used for shadow according to both the scene and the light.
  9041. * @param activeCamera The camera we are returning the min for
  9042. * @returns the depth min z
  9043. */
  9044. getDepthMinZ(activeCamera: Camera): number;
  9045. /**
  9046. * Gets the maxZ used for shadow according to both the scene and the light.
  9047. * @param activeCamera The camera we are returning the max for
  9048. * @returns the depth max z
  9049. */
  9050. getDepthMaxZ(activeCamera: Camera): number;
  9051. /**
  9052. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9053. * @param matrix The materix to updated with the projection information
  9054. * @param viewMatrix The transform matrix of the light
  9055. * @param renderList The list of mesh to render in the map
  9056. * @returns The current light
  9057. */
  9058. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9059. }
  9060. }
  9061. declare module "babylonjs/Materials/materialHelper" {
  9062. import { Nullable } from "babylonjs/types";
  9063. import { Scene } from "babylonjs/scene";
  9064. import { Engine } from "babylonjs/Engines/engine";
  9065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9066. import { Light } from "babylonjs/Lights/light";
  9067. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9068. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9069. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9070. /**
  9071. * "Static Class" containing the most commonly used helper while dealing with material for
  9072. * rendering purpose.
  9073. *
  9074. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9075. *
  9076. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9077. */
  9078. export class MaterialHelper {
  9079. /**
  9080. * Bind the current view position to an effect.
  9081. * @param effect The effect to be bound
  9082. * @param scene The scene the eyes position is used from
  9083. */
  9084. static BindEyePosition(effect: Effect, scene: Scene): void;
  9085. /**
  9086. * Helps preparing the defines values about the UVs in used in the effect.
  9087. * UVs are shared as much as we can accross channels in the shaders.
  9088. * @param texture The texture we are preparing the UVs for
  9089. * @param defines The defines to update
  9090. * @param key The channel key "diffuse", "specular"... used in the shader
  9091. */
  9092. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9093. /**
  9094. * Binds a texture matrix value to its corrsponding uniform
  9095. * @param texture The texture to bind the matrix for
  9096. * @param uniformBuffer The uniform buffer receivin the data
  9097. * @param key The channel key "diffuse", "specular"... used in the shader
  9098. */
  9099. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9100. /**
  9101. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9102. * @param mesh defines the current mesh
  9103. * @param scene defines the current scene
  9104. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9105. * @param pointsCloud defines if point cloud rendering has to be turned on
  9106. * @param fogEnabled defines if fog has to be turned on
  9107. * @param alphaTest defines if alpha testing has to be turned on
  9108. * @param defines defines the current list of defines
  9109. */
  9110. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9111. /**
  9112. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9113. * @param scene defines the current scene
  9114. * @param engine defines the current engine
  9115. * @param defines specifies the list of active defines
  9116. * @param useInstances defines if instances have to be turned on
  9117. * @param useClipPlane defines if clip plane have to be turned on
  9118. */
  9119. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9120. /**
  9121. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9122. * @param mesh The mesh containing the geometry data we will draw
  9123. * @param defines The defines to update
  9124. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9125. * @param useBones Precise whether bones should be used or not (override mesh info)
  9126. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9127. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9128. * @returns false if defines are considered not dirty and have not been checked
  9129. */
  9130. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9131. /**
  9132. * Prepares the defines related to the light information passed in parameter
  9133. * @param scene The scene we are intending to draw
  9134. * @param mesh The mesh the effect is compiling for
  9135. * @param defines The defines to update
  9136. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9137. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9138. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9139. * @returns true if normals will be required for the rest of the effect
  9140. */
  9141. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9142. /**
  9143. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9144. * that won t be acctive due to defines being turned off.
  9145. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9146. * @param samplersList The samplers list
  9147. * @param defines The defines helping in the list generation
  9148. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9149. */
  9150. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9151. /**
  9152. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9153. * @param defines The defines to update while falling back
  9154. * @param fallbacks The authorized effect fallbacks
  9155. * @param maxSimultaneousLights The maximum number of lights allowed
  9156. * @param rank the current rank of the Effect
  9157. * @returns The newly affected rank
  9158. */
  9159. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9160. /**
  9161. * Prepares the list of attributes required for morph targets according to the effect defines.
  9162. * @param attribs The current list of supported attribs
  9163. * @param mesh The mesh to prepare the morph targets attributes for
  9164. * @param defines The current Defines of the effect
  9165. */
  9166. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9167. /**
  9168. * Prepares the list of attributes required for bones according to the effect defines.
  9169. * @param attribs The current list of supported attribs
  9170. * @param mesh The mesh to prepare the bones attributes for
  9171. * @param defines The current Defines of the effect
  9172. * @param fallbacks The current efffect fallback strategy
  9173. */
  9174. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9175. /**
  9176. * Prepares the list of attributes required for instances according to the effect defines.
  9177. * @param attribs The current list of supported attribs
  9178. * @param defines The current Defines of the effect
  9179. */
  9180. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9181. /**
  9182. * Binds the light shadow information to the effect for the given mesh.
  9183. * @param light The light containing the generator
  9184. * @param scene The scene the lights belongs to
  9185. * @param mesh The mesh we are binding the information to render
  9186. * @param lightIndex The light index in the effect used to render the mesh
  9187. * @param effect The effect we are binding the data to
  9188. */
  9189. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9190. /**
  9191. * Binds the light information to the effect.
  9192. * @param light The light containing the generator
  9193. * @param effect The effect we are binding the data to
  9194. * @param lightIndex The light index in the effect used to render
  9195. */
  9196. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9197. /**
  9198. * Binds the lights information from the scene to the effect for the given mesh.
  9199. * @param scene The scene the lights belongs to
  9200. * @param mesh The mesh we are binding the information to render
  9201. * @param effect The effect we are binding the data to
  9202. * @param defines The generated defines for the effect
  9203. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9204. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9205. */
  9206. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9207. private static _tempFogColor;
  9208. /**
  9209. * Binds the fog information from the scene to the effect for the given mesh.
  9210. * @param scene The scene the lights belongs to
  9211. * @param mesh The mesh we are binding the information to render
  9212. * @param effect The effect we are binding the data to
  9213. * @param linearSpace Defines if the fog effect is applied in linear space
  9214. */
  9215. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9216. /**
  9217. * Binds the bones information from the mesh to the effect.
  9218. * @param mesh The mesh we are binding the information to render
  9219. * @param effect The effect we are binding the data to
  9220. */
  9221. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9222. /**
  9223. * Binds the morph targets information from the mesh to the effect.
  9224. * @param abstractMesh The mesh we are binding the information to render
  9225. * @param effect The effect we are binding the data to
  9226. */
  9227. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9228. /**
  9229. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9230. * @param defines The generated defines used in the effect
  9231. * @param effect The effect we are binding the data to
  9232. * @param scene The scene we are willing to render with logarithmic scale for
  9233. */
  9234. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9235. /**
  9236. * Binds the clip plane information from the scene to the effect.
  9237. * @param scene The scene the clip plane information are extracted from
  9238. * @param effect The effect we are binding the data to
  9239. */
  9240. static BindClipPlane(effect: Effect, scene: Scene): void;
  9241. }
  9242. }
  9243. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9244. /** @hidden */
  9245. export var kernelBlurVaryingDeclaration: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9251. /** @hidden */
  9252. export var kernelBlurFragment: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9258. /** @hidden */
  9259. export var kernelBlurFragment2: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9265. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9266. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9267. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9268. /** @hidden */
  9269. export var kernelBlurPixelShader: {
  9270. name: string;
  9271. shader: string;
  9272. };
  9273. }
  9274. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9275. /** @hidden */
  9276. export var kernelBlurVertex: {
  9277. name: string;
  9278. shader: string;
  9279. };
  9280. }
  9281. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9282. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9283. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9284. /** @hidden */
  9285. export var kernelBlurVertexShader: {
  9286. name: string;
  9287. shader: string;
  9288. };
  9289. }
  9290. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9291. import { Vector2 } from "babylonjs/Maths/math";
  9292. import { Nullable } from "babylonjs/types";
  9293. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9294. import { Camera } from "babylonjs/Cameras/camera";
  9295. import { Effect } from "babylonjs/Materials/effect";
  9296. import { Engine } from "babylonjs/Engines/engine";
  9297. import "babylonjs/Shaders/kernelBlur.fragment";
  9298. import "babylonjs/Shaders/kernelBlur.vertex";
  9299. /**
  9300. * The Blur Post Process which blurs an image based on a kernel and direction.
  9301. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9302. */
  9303. export class BlurPostProcess extends PostProcess {
  9304. /** The direction in which to blur the image. */
  9305. direction: Vector2;
  9306. private blockCompilation;
  9307. protected _kernel: number;
  9308. protected _idealKernel: number;
  9309. protected _packedFloat: boolean;
  9310. private _staticDefines;
  9311. /**
  9312. * Sets the length in pixels of the blur sample region
  9313. */
  9314. /**
  9315. * Gets the length in pixels of the blur sample region
  9316. */
  9317. kernel: number;
  9318. /**
  9319. * Sets wether or not the blur needs to unpack/repack floats
  9320. */
  9321. /**
  9322. * Gets wether or not the blur is unpacking/repacking floats
  9323. */
  9324. packedFloat: boolean;
  9325. /**
  9326. * Creates a new instance BlurPostProcess
  9327. * @param name The name of the effect.
  9328. * @param direction The direction in which to blur the image.
  9329. * @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.
  9330. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9331. * @param camera The camera to apply the render pass to.
  9332. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9333. * @param engine The engine which the post process will be applied. (default: current engine)
  9334. * @param reusable If the post process can be reused on the same frame. (default: false)
  9335. * @param textureType Type of textures used when performing the post process. (default: 0)
  9336. * @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)
  9337. */
  9338. constructor(name: string,
  9339. /** The direction in which to blur the image. */
  9340. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9341. /**
  9342. * Updates the effect with the current post process compile time values and recompiles the shader.
  9343. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9344. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9345. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9346. * @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
  9347. * @param onCompiled Called when the shader has been compiled.
  9348. * @param onError Called if there is an error when compiling a shader.
  9349. */
  9350. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9351. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9352. /**
  9353. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9354. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9355. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9356. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9357. * The gaps between physical kernels are compensated for in the weighting of the samples
  9358. * @param idealKernel Ideal blur kernel.
  9359. * @return Nearest best kernel.
  9360. */
  9361. protected _nearestBestKernel(idealKernel: number): number;
  9362. /**
  9363. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9364. * @param x The point on the Gaussian distribution to sample.
  9365. * @return the value of the Gaussian function at x.
  9366. */
  9367. protected _gaussianWeight(x: number): number;
  9368. /**
  9369. * Generates a string that can be used as a floating point number in GLSL.
  9370. * @param x Value to print.
  9371. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9372. * @return GLSL float string.
  9373. */
  9374. protected _glslFloat(x: number, decimalFigures?: number): string;
  9375. }
  9376. }
  9377. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9378. /** @hidden */
  9379. export var shadowMapPixelShader: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9385. /** @hidden */
  9386. export var bonesDeclaration: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9392. /** @hidden */
  9393. export var morphTargetsVertexGlobalDeclaration: {
  9394. name: string;
  9395. shader: string;
  9396. };
  9397. }
  9398. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9399. /** @hidden */
  9400. export var morphTargetsVertexDeclaration: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9406. /** @hidden */
  9407. export var instancesDeclaration: {
  9408. name: string;
  9409. shader: string;
  9410. };
  9411. }
  9412. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9413. /** @hidden */
  9414. export var helperFunctions: {
  9415. name: string;
  9416. shader: string;
  9417. };
  9418. }
  9419. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9420. /** @hidden */
  9421. export var morphTargetsVertex: {
  9422. name: string;
  9423. shader: string;
  9424. };
  9425. }
  9426. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9427. /** @hidden */
  9428. export var instancesVertex: {
  9429. name: string;
  9430. shader: string;
  9431. };
  9432. }
  9433. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9434. /** @hidden */
  9435. export var bonesVertex: {
  9436. name: string;
  9437. shader: string;
  9438. };
  9439. }
  9440. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9441. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9442. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9443. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9444. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9445. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9446. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9447. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9448. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9449. /** @hidden */
  9450. export var shadowMapVertexShader: {
  9451. name: string;
  9452. shader: string;
  9453. };
  9454. }
  9455. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9456. /** @hidden */
  9457. export var depthBoxBlurPixelShader: {
  9458. name: string;
  9459. shader: string;
  9460. };
  9461. }
  9462. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9463. import { Nullable } from "babylonjs/types";
  9464. import { Scene } from "babylonjs/scene";
  9465. import { Matrix } from "babylonjs/Maths/math";
  9466. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9468. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9469. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9470. import { Effect } from "babylonjs/Materials/effect";
  9471. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9472. import "babylonjs/Shaders/shadowMap.fragment";
  9473. import "babylonjs/Shaders/shadowMap.vertex";
  9474. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9475. import { Observable } from "babylonjs/Misc/observable";
  9476. /**
  9477. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9478. */
  9479. export interface ICustomShaderOptions {
  9480. /**
  9481. * Gets or sets the custom shader name to use
  9482. */
  9483. shaderName: string;
  9484. /**
  9485. * The list of attribute names used in the shader
  9486. */
  9487. attributes?: string[];
  9488. /**
  9489. * The list of unifrom names used in the shader
  9490. */
  9491. uniforms?: string[];
  9492. /**
  9493. * The list of sampler names used in the shader
  9494. */
  9495. samplers?: string[];
  9496. /**
  9497. * The list of defines used in the shader
  9498. */
  9499. defines?: string[];
  9500. }
  9501. /**
  9502. * Interface to implement to create a shadow generator compatible with BJS.
  9503. */
  9504. export interface IShadowGenerator {
  9505. /**
  9506. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9507. * @returns The render target texture if present otherwise, null
  9508. */
  9509. getShadowMap(): Nullable<RenderTargetTexture>;
  9510. /**
  9511. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9512. * @returns The render target texture if the shadow map is present otherwise, null
  9513. */
  9514. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9515. /**
  9516. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9517. * @param subMesh The submesh we want to render in the shadow map
  9518. * @param useInstances Defines wether will draw in the map using instances
  9519. * @returns true if ready otherwise, false
  9520. */
  9521. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9522. /**
  9523. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9524. * @param defines Defines of the material we want to update
  9525. * @param lightIndex Index of the light in the enabled light list of the material
  9526. */
  9527. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9528. /**
  9529. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9530. * defined in the generator but impacting the effect).
  9531. * It implies the unifroms available on the materials are the standard BJS ones.
  9532. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9533. * @param effect The effect we are binfing the information for
  9534. */
  9535. bindShadowLight(lightIndex: string, effect: Effect): void;
  9536. /**
  9537. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9538. * (eq to shadow prjection matrix * light transform matrix)
  9539. * @returns The transform matrix used to create the shadow map
  9540. */
  9541. getTransformMatrix(): Matrix;
  9542. /**
  9543. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9544. * Cube and 2D textures for instance.
  9545. */
  9546. recreateShadowMap(): void;
  9547. /**
  9548. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9549. * @param onCompiled Callback triggered at the and of the effects compilation
  9550. * @param options Sets of optional options forcing the compilation with different modes
  9551. */
  9552. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9553. useInstances: boolean;
  9554. }>): void;
  9555. /**
  9556. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9557. * @param options Sets of optional options forcing the compilation with different modes
  9558. * @returns A promise that resolves when the compilation completes
  9559. */
  9560. forceCompilationAsync(options?: Partial<{
  9561. useInstances: boolean;
  9562. }>): Promise<void>;
  9563. /**
  9564. * Serializes the shadow generator setup to a json object.
  9565. * @returns The serialized JSON object
  9566. */
  9567. serialize(): any;
  9568. /**
  9569. * Disposes the Shadow map and related Textures and effects.
  9570. */
  9571. dispose(): void;
  9572. }
  9573. /**
  9574. * Default implementation IShadowGenerator.
  9575. * This is the main object responsible of generating shadows in the framework.
  9576. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9577. */
  9578. export class ShadowGenerator implements IShadowGenerator {
  9579. /**
  9580. * Shadow generator mode None: no filtering applied.
  9581. */
  9582. static readonly FILTER_NONE: number;
  9583. /**
  9584. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9585. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9586. */
  9587. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9588. /**
  9589. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9590. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9591. */
  9592. static readonly FILTER_POISSONSAMPLING: number;
  9593. /**
  9594. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9595. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9596. */
  9597. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9598. /**
  9599. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9600. * edge artifacts on steep falloff.
  9601. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9602. */
  9603. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9604. /**
  9605. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9606. * edge artifacts on steep falloff.
  9607. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9608. */
  9609. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9610. /**
  9611. * Shadow generator mode PCF: Percentage Closer Filtering
  9612. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9613. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9614. */
  9615. static readonly FILTER_PCF: number;
  9616. /**
  9617. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9618. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9619. * Contact Hardening
  9620. */
  9621. static readonly FILTER_PCSS: number;
  9622. /**
  9623. * Reserved for PCF and PCSS
  9624. * Highest Quality.
  9625. *
  9626. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9627. *
  9628. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9629. */
  9630. static readonly QUALITY_HIGH: number;
  9631. /**
  9632. * Reserved for PCF and PCSS
  9633. * Good tradeoff for quality/perf cross devices
  9634. *
  9635. * Execute PCF on a 3*3 kernel.
  9636. *
  9637. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9638. */
  9639. static readonly QUALITY_MEDIUM: number;
  9640. /**
  9641. * Reserved for PCF and PCSS
  9642. * The lowest quality but the fastest.
  9643. *
  9644. * Execute PCF on a 1*1 kernel.
  9645. *
  9646. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9647. */
  9648. static readonly QUALITY_LOW: number;
  9649. /** Gets or sets the custom shader name to use */
  9650. customShaderOptions: ICustomShaderOptions;
  9651. /**
  9652. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9653. */
  9654. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9655. private _bias;
  9656. /**
  9657. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9658. */
  9659. /**
  9660. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9661. */
  9662. bias: number;
  9663. private _normalBias;
  9664. /**
  9665. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9666. */
  9667. /**
  9668. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9669. */
  9670. normalBias: number;
  9671. private _blurBoxOffset;
  9672. /**
  9673. * Gets the blur box offset: offset applied during the blur pass.
  9674. * Only useful if useKernelBlur = false
  9675. */
  9676. /**
  9677. * Sets the blur box offset: offset applied during the blur pass.
  9678. * Only useful if useKernelBlur = false
  9679. */
  9680. blurBoxOffset: number;
  9681. private _blurScale;
  9682. /**
  9683. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9684. * 2 means half of the size.
  9685. */
  9686. /**
  9687. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9688. * 2 means half of the size.
  9689. */
  9690. blurScale: number;
  9691. private _blurKernel;
  9692. /**
  9693. * Gets the blur kernel: kernel size of the blur pass.
  9694. * Only useful if useKernelBlur = true
  9695. */
  9696. /**
  9697. * Sets the blur kernel: kernel size of the blur pass.
  9698. * Only useful if useKernelBlur = true
  9699. */
  9700. blurKernel: number;
  9701. private _useKernelBlur;
  9702. /**
  9703. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9704. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9705. */
  9706. /**
  9707. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9708. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9709. */
  9710. useKernelBlur: boolean;
  9711. private _depthScale;
  9712. /**
  9713. * Gets the depth scale used in ESM mode.
  9714. */
  9715. /**
  9716. * Sets the depth scale used in ESM mode.
  9717. * This can override the scale stored on the light.
  9718. */
  9719. depthScale: number;
  9720. private _filter;
  9721. /**
  9722. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9723. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9724. */
  9725. /**
  9726. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9727. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9728. */
  9729. filter: number;
  9730. /**
  9731. * Gets if the current filter is set to Poisson Sampling.
  9732. */
  9733. /**
  9734. * Sets the current filter to Poisson Sampling.
  9735. */
  9736. usePoissonSampling: boolean;
  9737. /**
  9738. * Gets if the current filter is set to ESM.
  9739. */
  9740. /**
  9741. * Sets the current filter is to ESM.
  9742. */
  9743. useExponentialShadowMap: boolean;
  9744. /**
  9745. * Gets if the current filter is set to filtered ESM.
  9746. */
  9747. /**
  9748. * Gets if the current filter is set to filtered ESM.
  9749. */
  9750. useBlurExponentialShadowMap: boolean;
  9751. /**
  9752. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9753. * exponential to prevent steep falloff artifacts).
  9754. */
  9755. /**
  9756. * Sets the current filter to "close ESM" (using the inverse of the
  9757. * exponential to prevent steep falloff artifacts).
  9758. */
  9759. useCloseExponentialShadowMap: boolean;
  9760. /**
  9761. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9762. * exponential to prevent steep falloff artifacts).
  9763. */
  9764. /**
  9765. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9766. * exponential to prevent steep falloff artifacts).
  9767. */
  9768. useBlurCloseExponentialShadowMap: boolean;
  9769. /**
  9770. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9771. */
  9772. /**
  9773. * Sets the current filter to "PCF" (percentage closer filtering).
  9774. */
  9775. usePercentageCloserFiltering: boolean;
  9776. private _filteringQuality;
  9777. /**
  9778. * Gets the PCF or PCSS Quality.
  9779. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9780. */
  9781. /**
  9782. * Sets the PCF or PCSS Quality.
  9783. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9784. */
  9785. filteringQuality: number;
  9786. /**
  9787. * Gets if the current filter is set to "PCSS" (contact hardening).
  9788. */
  9789. /**
  9790. * Sets the current filter to "PCSS" (contact hardening).
  9791. */
  9792. useContactHardeningShadow: boolean;
  9793. private _contactHardeningLightSizeUVRatio;
  9794. /**
  9795. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9796. * Using a ratio helps keeping shape stability independently of the map size.
  9797. *
  9798. * It does not account for the light projection as it was having too much
  9799. * instability during the light setup or during light position changes.
  9800. *
  9801. * Only valid if useContactHardeningShadow is true.
  9802. */
  9803. /**
  9804. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9805. * Using a ratio helps keeping shape stability independently of the map size.
  9806. *
  9807. * It does not account for the light projection as it was having too much
  9808. * instability during the light setup or during light position changes.
  9809. *
  9810. * Only valid if useContactHardeningShadow is true.
  9811. */
  9812. contactHardeningLightSizeUVRatio: number;
  9813. private _darkness;
  9814. /**
  9815. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9816. * 0 means strongest and 1 would means no shadow.
  9817. * @returns the darkness.
  9818. */
  9819. getDarkness(): number;
  9820. /**
  9821. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9822. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9823. * @returns the shadow generator allowing fluent coding.
  9824. */
  9825. setDarkness(darkness: number): ShadowGenerator;
  9826. private _transparencyShadow;
  9827. /**
  9828. * Sets the ability to have transparent shadow (boolean).
  9829. * @param transparent True if transparent else False
  9830. * @returns the shadow generator allowing fluent coding
  9831. */
  9832. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9833. private _shadowMap;
  9834. private _shadowMap2;
  9835. /**
  9836. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9837. * @returns The render target texture if present otherwise, null
  9838. */
  9839. getShadowMap(): Nullable<RenderTargetTexture>;
  9840. /**
  9841. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9842. * @returns The render target texture if the shadow map is present otherwise, null
  9843. */
  9844. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9845. /**
  9846. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9847. * @param mesh Mesh to add
  9848. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9849. * @returns the Shadow Generator itself
  9850. */
  9851. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9852. /**
  9853. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9854. * @param mesh Mesh to remove
  9855. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9856. * @returns the Shadow Generator itself
  9857. */
  9858. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9859. /**
  9860. * Controls the extent to which the shadows fade out at the edge of the frustum
  9861. * Used only by directionals and spots
  9862. */
  9863. frustumEdgeFalloff: number;
  9864. private _light;
  9865. /**
  9866. * Returns the associated light object.
  9867. * @returns the light generating the shadow
  9868. */
  9869. getLight(): IShadowLight;
  9870. /**
  9871. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9872. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9873. * It might on the other hand introduce peter panning.
  9874. */
  9875. forceBackFacesOnly: boolean;
  9876. private _scene;
  9877. private _lightDirection;
  9878. private _effect;
  9879. private _viewMatrix;
  9880. private _projectionMatrix;
  9881. private _transformMatrix;
  9882. private _cachedPosition;
  9883. private _cachedDirection;
  9884. private _cachedDefines;
  9885. private _currentRenderID;
  9886. private _boxBlurPostprocess;
  9887. private _kernelBlurXPostprocess;
  9888. private _kernelBlurYPostprocess;
  9889. private _blurPostProcesses;
  9890. private _mapSize;
  9891. private _currentFaceIndex;
  9892. private _currentFaceIndexCache;
  9893. private _textureType;
  9894. private _defaultTextureMatrix;
  9895. /** @hidden */
  9896. static _SceneComponentInitialization: (scene: Scene) => void;
  9897. /**
  9898. * Creates a ShadowGenerator object.
  9899. * A ShadowGenerator is the required tool to use the shadows.
  9900. * Each light casting shadows needs to use its own ShadowGenerator.
  9901. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9902. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9903. * @param light The light object generating the shadows.
  9904. * @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.
  9905. */
  9906. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9907. private _initializeGenerator;
  9908. private _initializeShadowMap;
  9909. private _initializeBlurRTTAndPostProcesses;
  9910. private _renderForShadowMap;
  9911. private _renderSubMeshForShadowMap;
  9912. private _applyFilterValues;
  9913. /**
  9914. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9915. * @param onCompiled Callback triggered at the and of the effects compilation
  9916. * @param options Sets of optional options forcing the compilation with different modes
  9917. */
  9918. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9919. useInstances: boolean;
  9920. }>): void;
  9921. /**
  9922. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9923. * @param options Sets of optional options forcing the compilation with different modes
  9924. * @returns A promise that resolves when the compilation completes
  9925. */
  9926. forceCompilationAsync(options?: Partial<{
  9927. useInstances: boolean;
  9928. }>): Promise<void>;
  9929. /**
  9930. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9931. * @param subMesh The submesh we want to render in the shadow map
  9932. * @param useInstances Defines wether will draw in the map using instances
  9933. * @returns true if ready otherwise, false
  9934. */
  9935. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9936. /**
  9937. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9938. * @param defines Defines of the material we want to update
  9939. * @param lightIndex Index of the light in the enabled light list of the material
  9940. */
  9941. prepareDefines(defines: any, lightIndex: number): void;
  9942. /**
  9943. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9944. * defined in the generator but impacting the effect).
  9945. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9946. * @param effect The effect we are binfing the information for
  9947. */
  9948. bindShadowLight(lightIndex: string, effect: Effect): void;
  9949. /**
  9950. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9951. * (eq to shadow prjection matrix * light transform matrix)
  9952. * @returns The transform matrix used to create the shadow map
  9953. */
  9954. getTransformMatrix(): Matrix;
  9955. /**
  9956. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9957. * Cube and 2D textures for instance.
  9958. */
  9959. recreateShadowMap(): void;
  9960. private _disposeBlurPostProcesses;
  9961. private _disposeRTTandPostProcesses;
  9962. /**
  9963. * Disposes the ShadowGenerator.
  9964. * Returns nothing.
  9965. */
  9966. dispose(): void;
  9967. /**
  9968. * Serializes the shadow generator setup to a json object.
  9969. * @returns The serialized JSON object
  9970. */
  9971. serialize(): any;
  9972. /**
  9973. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9974. * @param parsedShadowGenerator The JSON object to parse
  9975. * @param scene The scene to create the shadow map for
  9976. * @returns The parsed shadow generator
  9977. */
  9978. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9979. }
  9980. }
  9981. declare module "babylonjs/Lights/light" {
  9982. import { Nullable } from "babylonjs/types";
  9983. import { Scene } from "babylonjs/scene";
  9984. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9985. import { Node } from "babylonjs/node";
  9986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9987. import { Effect } from "babylonjs/Materials/effect";
  9988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9989. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9990. /**
  9991. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9992. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9993. * 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.
  9994. */
  9995. export abstract class Light extends Node {
  9996. /**
  9997. * Falloff Default: light is falling off following the material specification:
  9998. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9999. */
  10000. static readonly FALLOFF_DEFAULT: number;
  10001. /**
  10002. * Falloff Physical: light is falling off following the inverse squared distance law.
  10003. */
  10004. static readonly FALLOFF_PHYSICAL: number;
  10005. /**
  10006. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10007. * to enhance interoperability with other engines.
  10008. */
  10009. static readonly FALLOFF_GLTF: number;
  10010. /**
  10011. * Falloff Standard: light is falling off like in the standard material
  10012. * to enhance interoperability with other materials.
  10013. */
  10014. static readonly FALLOFF_STANDARD: number;
  10015. /**
  10016. * If every light affecting the material is in this lightmapMode,
  10017. * material.lightmapTexture adds or multiplies
  10018. * (depends on material.useLightmapAsShadowmap)
  10019. * after every other light calculations.
  10020. */
  10021. static readonly LIGHTMAP_DEFAULT: number;
  10022. /**
  10023. * material.lightmapTexture as only diffuse lighting from this light
  10024. * adds only specular lighting from this light
  10025. * adds dynamic shadows
  10026. */
  10027. static readonly LIGHTMAP_SPECULAR: number;
  10028. /**
  10029. * material.lightmapTexture as only lighting
  10030. * no light calculation from this light
  10031. * only adds dynamic shadows from this light
  10032. */
  10033. static readonly LIGHTMAP_SHADOWSONLY: number;
  10034. /**
  10035. * Each light type uses the default quantity according to its type:
  10036. * point/spot lights use luminous intensity
  10037. * directional lights use illuminance
  10038. */
  10039. static readonly INTENSITYMODE_AUTOMATIC: number;
  10040. /**
  10041. * lumen (lm)
  10042. */
  10043. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10044. /**
  10045. * candela (lm/sr)
  10046. */
  10047. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10048. /**
  10049. * lux (lm/m^2)
  10050. */
  10051. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10052. /**
  10053. * nit (cd/m^2)
  10054. */
  10055. static readonly INTENSITYMODE_LUMINANCE: number;
  10056. /**
  10057. * Light type const id of the point light.
  10058. */
  10059. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10060. /**
  10061. * Light type const id of the directional light.
  10062. */
  10063. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10064. /**
  10065. * Light type const id of the spot light.
  10066. */
  10067. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10068. /**
  10069. * Light type const id of the hemispheric light.
  10070. */
  10071. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10072. /**
  10073. * Diffuse gives the basic color to an object.
  10074. */
  10075. diffuse: Color3;
  10076. /**
  10077. * Specular produces a highlight color on an object.
  10078. * Note: This is note affecting PBR materials.
  10079. */
  10080. specular: Color3;
  10081. /**
  10082. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10083. * falling off base on range or angle.
  10084. * This can be set to any values in Light.FALLOFF_x.
  10085. *
  10086. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10087. * other types of materials.
  10088. */
  10089. falloffType: number;
  10090. /**
  10091. * Strength of the light.
  10092. * Note: By default it is define in the framework own unit.
  10093. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10094. */
  10095. intensity: number;
  10096. private _range;
  10097. protected _inverseSquaredRange: number;
  10098. /**
  10099. * Defines how far from the source the light is impacting in scene units.
  10100. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10101. */
  10102. /**
  10103. * Defines how far from the source the light is impacting in scene units.
  10104. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10105. */
  10106. range: number;
  10107. /**
  10108. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10109. * of light.
  10110. */
  10111. private _photometricScale;
  10112. private _intensityMode;
  10113. /**
  10114. * Gets the photometric scale used to interpret the intensity.
  10115. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10116. */
  10117. /**
  10118. * Sets the photometric scale used to interpret the intensity.
  10119. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10120. */
  10121. intensityMode: number;
  10122. private _radius;
  10123. /**
  10124. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10125. */
  10126. /**
  10127. * sets the light radius used by PBR Materials to simulate soft area lights.
  10128. */
  10129. radius: number;
  10130. private _renderPriority;
  10131. /**
  10132. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10133. * exceeding the number allowed of the materials.
  10134. */
  10135. renderPriority: number;
  10136. private _shadowEnabled;
  10137. /**
  10138. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10139. * the current shadow generator.
  10140. */
  10141. /**
  10142. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10143. * the current shadow generator.
  10144. */
  10145. shadowEnabled: boolean;
  10146. private _includedOnlyMeshes;
  10147. /**
  10148. * Gets the only meshes impacted by this light.
  10149. */
  10150. /**
  10151. * Sets the only meshes impacted by this light.
  10152. */
  10153. includedOnlyMeshes: AbstractMesh[];
  10154. private _excludedMeshes;
  10155. /**
  10156. * Gets the meshes not impacted by this light.
  10157. */
  10158. /**
  10159. * Sets the meshes not impacted by this light.
  10160. */
  10161. excludedMeshes: AbstractMesh[];
  10162. private _excludeWithLayerMask;
  10163. /**
  10164. * Gets the layer id use to find what meshes are not impacted by the light.
  10165. * Inactive if 0
  10166. */
  10167. /**
  10168. * Sets the layer id use to find what meshes are not impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. excludeWithLayerMask: number;
  10172. private _includeOnlyWithLayerMask;
  10173. /**
  10174. * Gets the layer id use to find what meshes are impacted by the light.
  10175. * Inactive if 0
  10176. */
  10177. /**
  10178. * Sets the layer id use to find what meshes are impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. includeOnlyWithLayerMask: number;
  10182. private _lightmapMode;
  10183. /**
  10184. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10185. */
  10186. /**
  10187. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10188. */
  10189. lightmapMode: number;
  10190. /**
  10191. * Shadow generator associted to the light.
  10192. * @hidden Internal use only.
  10193. */
  10194. _shadowGenerator: Nullable<IShadowGenerator>;
  10195. /**
  10196. * @hidden Internal use only.
  10197. */
  10198. _excludedMeshesIds: string[];
  10199. /**
  10200. * @hidden Internal use only.
  10201. */
  10202. _includedOnlyMeshesIds: string[];
  10203. /**
  10204. * The current light unifom buffer.
  10205. * @hidden Internal use only.
  10206. */
  10207. _uniformBuffer: UniformBuffer;
  10208. /**
  10209. * Creates a Light object in the scene.
  10210. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10211. * @param name The firendly name of the light
  10212. * @param scene The scene the light belongs too
  10213. */
  10214. constructor(name: string, scene: Scene);
  10215. protected abstract _buildUniformLayout(): void;
  10216. /**
  10217. * Sets the passed Effect "effect" with the Light information.
  10218. * @param effect The effect to update
  10219. * @param lightIndex The index of the light in the effect to update
  10220. * @returns The light
  10221. */
  10222. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10223. /**
  10224. * Returns the string "Light".
  10225. * @returns the class name
  10226. */
  10227. getClassName(): string;
  10228. /** @hidden */
  10229. readonly _isLight: boolean;
  10230. /**
  10231. * Converts the light information to a readable string for debug purpose.
  10232. * @param fullDetails Supports for multiple levels of logging within scene loading
  10233. * @returns the human readable light info
  10234. */
  10235. toString(fullDetails?: boolean): string;
  10236. /** @hidden */
  10237. protected _syncParentEnabledState(): void;
  10238. /**
  10239. * Set the enabled state of this node.
  10240. * @param value - the new enabled state
  10241. */
  10242. setEnabled(value: boolean): void;
  10243. /**
  10244. * Returns the Light associated shadow generator if any.
  10245. * @return the associated shadow generator.
  10246. */
  10247. getShadowGenerator(): Nullable<IShadowGenerator>;
  10248. /**
  10249. * Returns a Vector3, the absolute light position in the World.
  10250. * @returns the world space position of the light
  10251. */
  10252. getAbsolutePosition(): Vector3;
  10253. /**
  10254. * Specifies if the light will affect the passed mesh.
  10255. * @param mesh The mesh to test against the light
  10256. * @return true the mesh is affected otherwise, false.
  10257. */
  10258. canAffectMesh(mesh: AbstractMesh): boolean;
  10259. /**
  10260. * Sort function to order lights for rendering.
  10261. * @param a First Light object to compare to second.
  10262. * @param b Second Light object to compare first.
  10263. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10264. */
  10265. static CompareLightsPriority(a: Light, b: Light): number;
  10266. /**
  10267. * Releases resources associated with this node.
  10268. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10269. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10270. */
  10271. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10272. /**
  10273. * Returns the light type ID (integer).
  10274. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10275. */
  10276. getTypeID(): number;
  10277. /**
  10278. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10279. * @returns the scaled intensity in intensity mode unit
  10280. */
  10281. getScaledIntensity(): number;
  10282. /**
  10283. * Returns a new Light object, named "name", from the current one.
  10284. * @param name The name of the cloned light
  10285. * @returns the new created light
  10286. */
  10287. clone(name: string): Nullable<Light>;
  10288. /**
  10289. * Serializes the current light into a Serialization object.
  10290. * @returns the serialized object.
  10291. */
  10292. serialize(): any;
  10293. /**
  10294. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10295. * This new light is named "name" and added to the passed scene.
  10296. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10297. * @param name The friendly name of the light
  10298. * @param scene The scene the new light will belong to
  10299. * @returns the constructor function
  10300. */
  10301. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10302. /**
  10303. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10304. * @param parsedLight The JSON representation of the light
  10305. * @param scene The scene to create the parsed light in
  10306. * @returns the created light after parsing
  10307. */
  10308. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10309. private _hookArrayForExcluded;
  10310. private _hookArrayForIncludedOnly;
  10311. private _resyncMeshes;
  10312. /**
  10313. * Forces the meshes to update their light related information in their rendering used effects
  10314. * @hidden Internal Use Only
  10315. */
  10316. _markMeshesAsLightDirty(): void;
  10317. /**
  10318. * Recomputes the cached photometric scale if needed.
  10319. */
  10320. private _computePhotometricScale;
  10321. /**
  10322. * Returns the Photometric Scale according to the light type and intensity mode.
  10323. */
  10324. private _getPhotometricScale;
  10325. /**
  10326. * Reorder the light in the scene according to their defined priority.
  10327. * @hidden Internal Use Only
  10328. */
  10329. _reorderLightsInScene(): void;
  10330. /**
  10331. * Prepares the list of defines specific to the light type.
  10332. * @param defines the list of defines
  10333. * @param lightIndex defines the index of the light for the effect
  10334. */
  10335. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10336. }
  10337. }
  10338. declare module "babylonjs/Actions/action" {
  10339. import { Observable } from "babylonjs/Misc/observable";
  10340. import { Condition } from "babylonjs/Actions/condition";
  10341. import { ActionManager } from "babylonjs/Actions/actionManager";
  10342. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10343. /**
  10344. * Interface used to define Action
  10345. */
  10346. export interface IAction {
  10347. /**
  10348. * Trigger for the action
  10349. */
  10350. trigger: number;
  10351. /** Options of the trigger */
  10352. triggerOptions: any;
  10353. /**
  10354. * Gets the trigger parameters
  10355. * @returns the trigger parameters
  10356. */
  10357. getTriggerParameter(): any;
  10358. /**
  10359. * Internal only - executes current action event
  10360. * @hidden
  10361. */
  10362. _executeCurrent(evt?: ActionEvent): void;
  10363. /**
  10364. * Serialize placeholder for child classes
  10365. * @param parent of child
  10366. * @returns the serialized object
  10367. */
  10368. serialize(parent: any): any;
  10369. }
  10370. /**
  10371. * The action to be carried out following a trigger
  10372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10373. */
  10374. export class Action implements IAction {
  10375. /** the trigger, with or without parameters, for the action */
  10376. triggerOptions: any;
  10377. /**
  10378. * Trigger for the action
  10379. */
  10380. trigger: number;
  10381. /**
  10382. * Internal only - manager for action
  10383. * @hidden
  10384. */
  10385. _actionManager: ActionManager;
  10386. private _nextActiveAction;
  10387. private _child;
  10388. private _condition?;
  10389. private _triggerParameter;
  10390. /**
  10391. * An event triggered prior to action being executed.
  10392. */
  10393. onBeforeExecuteObservable: Observable<Action>;
  10394. /**
  10395. * Creates a new Action
  10396. * @param triggerOptions the trigger, with or without parameters, for the action
  10397. * @param condition an optional determinant of action
  10398. */
  10399. constructor(
  10400. /** the trigger, with or without parameters, for the action */
  10401. triggerOptions: any, condition?: Condition);
  10402. /**
  10403. * Internal only
  10404. * @hidden
  10405. */
  10406. _prepare(): void;
  10407. /**
  10408. * Gets the trigger parameters
  10409. * @returns the trigger parameters
  10410. */
  10411. getTriggerParameter(): any;
  10412. /**
  10413. * Internal only - executes current action event
  10414. * @hidden
  10415. */
  10416. _executeCurrent(evt?: ActionEvent): void;
  10417. /**
  10418. * Execute placeholder for child classes
  10419. * @param evt optional action event
  10420. */
  10421. execute(evt?: ActionEvent): void;
  10422. /**
  10423. * Skips to next active action
  10424. */
  10425. skipToNextActiveAction(): void;
  10426. /**
  10427. * Adds action to chain of actions, may be a DoNothingAction
  10428. * @param action defines the next action to execute
  10429. * @returns The action passed in
  10430. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10431. */
  10432. then(action: Action): Action;
  10433. /**
  10434. * Internal only
  10435. * @hidden
  10436. */
  10437. _getProperty(propertyPath: string): string;
  10438. /**
  10439. * Internal only
  10440. * @hidden
  10441. */
  10442. _getEffectiveTarget(target: any, propertyPath: string): any;
  10443. /**
  10444. * Serialize placeholder for child classes
  10445. * @param parent of child
  10446. * @returns the serialized object
  10447. */
  10448. serialize(parent: any): any;
  10449. /**
  10450. * Internal only called by serialize
  10451. * @hidden
  10452. */
  10453. protected _serialize(serializedAction: any, parent?: any): any;
  10454. /**
  10455. * Internal only
  10456. * @hidden
  10457. */
  10458. static _SerializeValueAsString: (value: any) => string;
  10459. /**
  10460. * Internal only
  10461. * @hidden
  10462. */
  10463. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10464. name: string;
  10465. targetType: string;
  10466. value: string;
  10467. };
  10468. }
  10469. }
  10470. declare module "babylonjs/Actions/condition" {
  10471. import { ActionManager } from "babylonjs/Actions/actionManager";
  10472. /**
  10473. * A Condition applied to an Action
  10474. */
  10475. export class Condition {
  10476. /**
  10477. * Internal only - manager for action
  10478. * @hidden
  10479. */
  10480. _actionManager: ActionManager;
  10481. /**
  10482. * Internal only
  10483. * @hidden
  10484. */
  10485. _evaluationId: number;
  10486. /**
  10487. * Internal only
  10488. * @hidden
  10489. */
  10490. _currentResult: boolean;
  10491. /**
  10492. * Creates a new Condition
  10493. * @param actionManager the manager of the action the condition is applied to
  10494. */
  10495. constructor(actionManager: ActionManager);
  10496. /**
  10497. * Check if the current condition is valid
  10498. * @returns a boolean
  10499. */
  10500. isValid(): boolean;
  10501. /**
  10502. * Internal only
  10503. * @hidden
  10504. */
  10505. _getProperty(propertyPath: string): string;
  10506. /**
  10507. * Internal only
  10508. * @hidden
  10509. */
  10510. _getEffectiveTarget(target: any, propertyPath: string): any;
  10511. /**
  10512. * Serialize placeholder for child classes
  10513. * @returns the serialized object
  10514. */
  10515. serialize(): any;
  10516. /**
  10517. * Internal only
  10518. * @hidden
  10519. */
  10520. protected _serialize(serializedCondition: any): any;
  10521. }
  10522. /**
  10523. * Defines specific conditional operators as extensions of Condition
  10524. */
  10525. export class ValueCondition extends Condition {
  10526. /** path to specify the property of the target the conditional operator uses */
  10527. propertyPath: string;
  10528. /** the value compared by the conditional operator against the current value of the property */
  10529. value: any;
  10530. /** the conditional operator, default ValueCondition.IsEqual */
  10531. operator: number;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. private static _IsEqual;
  10537. /**
  10538. * Internal only
  10539. * @hidden
  10540. */
  10541. private static _IsDifferent;
  10542. /**
  10543. * Internal only
  10544. * @hidden
  10545. */
  10546. private static _IsGreater;
  10547. /**
  10548. * Internal only
  10549. * @hidden
  10550. */
  10551. private static _IsLesser;
  10552. /**
  10553. * returns the number for IsEqual
  10554. */
  10555. static readonly IsEqual: number;
  10556. /**
  10557. * Returns the number for IsDifferent
  10558. */
  10559. static readonly IsDifferent: number;
  10560. /**
  10561. * Returns the number for IsGreater
  10562. */
  10563. static readonly IsGreater: number;
  10564. /**
  10565. * Returns the number for IsLesser
  10566. */
  10567. static readonly IsLesser: number;
  10568. /**
  10569. * Internal only The action manager for the condition
  10570. * @hidden
  10571. */
  10572. _actionManager: ActionManager;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. private _target;
  10578. /**
  10579. * Internal only
  10580. * @hidden
  10581. */
  10582. private _effectiveTarget;
  10583. /**
  10584. * Internal only
  10585. * @hidden
  10586. */
  10587. private _property;
  10588. /**
  10589. * Creates a new ValueCondition
  10590. * @param actionManager manager for the action the condition applies to
  10591. * @param target for the action
  10592. * @param propertyPath path to specify the property of the target the conditional operator uses
  10593. * @param value the value compared by the conditional operator against the current value of the property
  10594. * @param operator the conditional operator, default ValueCondition.IsEqual
  10595. */
  10596. constructor(actionManager: ActionManager, target: any,
  10597. /** path to specify the property of the target the conditional operator uses */
  10598. propertyPath: string,
  10599. /** the value compared by the conditional operator against the current value of the property */
  10600. value: any,
  10601. /** the conditional operator, default ValueCondition.IsEqual */
  10602. operator?: number);
  10603. /**
  10604. * Compares the given value with the property value for the specified conditional operator
  10605. * @returns the result of the comparison
  10606. */
  10607. isValid(): boolean;
  10608. /**
  10609. * Serialize the ValueCondition into a JSON compatible object
  10610. * @returns serialization object
  10611. */
  10612. serialize(): any;
  10613. /**
  10614. * Gets the name of the conditional operator for the ValueCondition
  10615. * @param operator the conditional operator
  10616. * @returns the name
  10617. */
  10618. static GetOperatorName(operator: number): string;
  10619. }
  10620. /**
  10621. * Defines a predicate condition as an extension of Condition
  10622. */
  10623. export class PredicateCondition extends Condition {
  10624. /** defines the predicate function used to validate the condition */
  10625. predicate: () => boolean;
  10626. /**
  10627. * Internal only - manager for action
  10628. * @hidden
  10629. */
  10630. _actionManager: ActionManager;
  10631. /**
  10632. * Creates a new PredicateCondition
  10633. * @param actionManager manager for the action the condition applies to
  10634. * @param predicate defines the predicate function used to validate the condition
  10635. */
  10636. constructor(actionManager: ActionManager,
  10637. /** defines the predicate function used to validate the condition */
  10638. predicate: () => boolean);
  10639. /**
  10640. * @returns the validity of the predicate condition
  10641. */
  10642. isValid(): boolean;
  10643. }
  10644. /**
  10645. * Defines a state condition as an extension of Condition
  10646. */
  10647. export class StateCondition extends Condition {
  10648. /** Value to compare with target state */
  10649. value: string;
  10650. /**
  10651. * Internal only - manager for action
  10652. * @hidden
  10653. */
  10654. _actionManager: ActionManager;
  10655. /**
  10656. * Internal only
  10657. * @hidden
  10658. */
  10659. private _target;
  10660. /**
  10661. * Creates a new StateCondition
  10662. * @param actionManager manager for the action the condition applies to
  10663. * @param target of the condition
  10664. * @param value to compare with target state
  10665. */
  10666. constructor(actionManager: ActionManager, target: any,
  10667. /** Value to compare with target state */
  10668. value: string);
  10669. /**
  10670. * Gets a boolean indicating if the current condition is met
  10671. * @returns the validity of the state
  10672. */
  10673. isValid(): boolean;
  10674. /**
  10675. * Serialize the StateCondition into a JSON compatible object
  10676. * @returns serialization object
  10677. */
  10678. serialize(): any;
  10679. }
  10680. }
  10681. declare module "babylonjs/Actions/directActions" {
  10682. import { Action } from "babylonjs/Actions/action";
  10683. import { Condition } from "babylonjs/Actions/condition";
  10684. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10685. /**
  10686. * This defines an action responsible to toggle a boolean once triggered.
  10687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10688. */
  10689. export class SwitchBooleanAction extends Action {
  10690. /**
  10691. * The path to the boolean property in the target object
  10692. */
  10693. propertyPath: string;
  10694. private _target;
  10695. private _effectiveTarget;
  10696. private _property;
  10697. /**
  10698. * Instantiate the action
  10699. * @param triggerOptions defines the trigger options
  10700. * @param target defines the object containing the boolean
  10701. * @param propertyPath defines the path to the boolean property in the target object
  10702. * @param condition defines the trigger related conditions
  10703. */
  10704. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10705. /** @hidden */
  10706. _prepare(): void;
  10707. /**
  10708. * Execute the action toggle the boolean value.
  10709. */
  10710. execute(): void;
  10711. /**
  10712. * Serializes the actions and its related information.
  10713. * @param parent defines the object to serialize in
  10714. * @returns the serialized object
  10715. */
  10716. serialize(parent: any): any;
  10717. }
  10718. /**
  10719. * This defines an action responsible to set a the state field of the target
  10720. * to a desired value once triggered.
  10721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10722. */
  10723. export class SetStateAction extends Action {
  10724. /**
  10725. * The value to store in the state field.
  10726. */
  10727. value: string;
  10728. private _target;
  10729. /**
  10730. * Instantiate the action
  10731. * @param triggerOptions defines the trigger options
  10732. * @param target defines the object containing the state property
  10733. * @param value defines the value to store in the state field
  10734. * @param condition defines the trigger related conditions
  10735. */
  10736. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10737. /**
  10738. * Execute the action and store the value on the target state property.
  10739. */
  10740. execute(): void;
  10741. /**
  10742. * Serializes the actions and its related information.
  10743. * @param parent defines the object to serialize in
  10744. * @returns the serialized object
  10745. */
  10746. serialize(parent: any): any;
  10747. }
  10748. /**
  10749. * This defines an action responsible to set a property of the target
  10750. * to a desired value once triggered.
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10752. */
  10753. export class SetValueAction extends Action {
  10754. /**
  10755. * The path of the property to set in the target.
  10756. */
  10757. propertyPath: string;
  10758. /**
  10759. * The value to set in the property
  10760. */
  10761. value: any;
  10762. private _target;
  10763. private _effectiveTarget;
  10764. private _property;
  10765. /**
  10766. * Instantiate the action
  10767. * @param triggerOptions defines the trigger options
  10768. * @param target defines the object containing the property
  10769. * @param propertyPath defines the path of the property to set in the target
  10770. * @param value defines the value to set in the property
  10771. * @param condition defines the trigger related conditions
  10772. */
  10773. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10774. /** @hidden */
  10775. _prepare(): void;
  10776. /**
  10777. * Execute the action and set the targetted property to the desired value.
  10778. */
  10779. execute(): void;
  10780. /**
  10781. * Serializes the actions and its related information.
  10782. * @param parent defines the object to serialize in
  10783. * @returns the serialized object
  10784. */
  10785. serialize(parent: any): any;
  10786. }
  10787. /**
  10788. * This defines an action responsible to increment the target value
  10789. * to a desired value once triggered.
  10790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10791. */
  10792. export class IncrementValueAction extends Action {
  10793. /**
  10794. * The path of the property to increment in the target.
  10795. */
  10796. propertyPath: string;
  10797. /**
  10798. * The value we should increment the property by.
  10799. */
  10800. value: any;
  10801. private _target;
  10802. private _effectiveTarget;
  10803. private _property;
  10804. /**
  10805. * Instantiate the action
  10806. * @param triggerOptions defines the trigger options
  10807. * @param target defines the object containing the property
  10808. * @param propertyPath defines the path of the property to increment in the target
  10809. * @param value defines the value value we should increment the property by
  10810. * @param condition defines the trigger related conditions
  10811. */
  10812. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10813. /** @hidden */
  10814. _prepare(): void;
  10815. /**
  10816. * Execute the action and increment the target of the value amount.
  10817. */
  10818. execute(): void;
  10819. /**
  10820. * Serializes the actions and its related information.
  10821. * @param parent defines the object to serialize in
  10822. * @returns the serialized object
  10823. */
  10824. serialize(parent: any): any;
  10825. }
  10826. /**
  10827. * This defines an action responsible to start an animation once triggered.
  10828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10829. */
  10830. export class PlayAnimationAction extends Action {
  10831. /**
  10832. * Where the animation should start (animation frame)
  10833. */
  10834. from: number;
  10835. /**
  10836. * Where the animation should stop (animation frame)
  10837. */
  10838. to: number;
  10839. /**
  10840. * Define if the animation should loop or stop after the first play.
  10841. */
  10842. loop?: boolean;
  10843. private _target;
  10844. /**
  10845. * Instantiate the action
  10846. * @param triggerOptions defines the trigger options
  10847. * @param target defines the target animation or animation name
  10848. * @param from defines from where the animation should start (animation frame)
  10849. * @param end defines where the animation should stop (animation frame)
  10850. * @param loop defines if the animation should loop or stop after the first play
  10851. * @param condition defines the trigger related conditions
  10852. */
  10853. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10854. /** @hidden */
  10855. _prepare(): void;
  10856. /**
  10857. * Execute the action and play the animation.
  10858. */
  10859. execute(): void;
  10860. /**
  10861. * Serializes the actions and its related information.
  10862. * @param parent defines the object to serialize in
  10863. * @returns the serialized object
  10864. */
  10865. serialize(parent: any): any;
  10866. }
  10867. /**
  10868. * This defines an action responsible to stop an animation once triggered.
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10870. */
  10871. export class StopAnimationAction extends Action {
  10872. private _target;
  10873. /**
  10874. * Instantiate the action
  10875. * @param triggerOptions defines the trigger options
  10876. * @param target defines the target animation or animation name
  10877. * @param condition defines the trigger related conditions
  10878. */
  10879. constructor(triggerOptions: any, target: any, condition?: Condition);
  10880. /** @hidden */
  10881. _prepare(): void;
  10882. /**
  10883. * Execute the action and stop the animation.
  10884. */
  10885. execute(): void;
  10886. /**
  10887. * Serializes the actions and its related information.
  10888. * @param parent defines the object to serialize in
  10889. * @returns the serialized object
  10890. */
  10891. serialize(parent: any): any;
  10892. }
  10893. /**
  10894. * This defines an action responsible that does nothing once triggered.
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10896. */
  10897. export class DoNothingAction extends Action {
  10898. /**
  10899. * Instantiate the action
  10900. * @param triggerOptions defines the trigger options
  10901. * @param condition defines the trigger related conditions
  10902. */
  10903. constructor(triggerOptions?: any, condition?: Condition);
  10904. /**
  10905. * Execute the action and do nothing.
  10906. */
  10907. execute(): void;
  10908. /**
  10909. * Serializes the actions and its related information.
  10910. * @param parent defines the object to serialize in
  10911. * @returns the serialized object
  10912. */
  10913. serialize(parent: any): any;
  10914. }
  10915. /**
  10916. * This defines an action responsible to trigger several actions once triggered.
  10917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10918. */
  10919. export class CombineAction extends Action {
  10920. /**
  10921. * The list of aggregated animations to run.
  10922. */
  10923. children: Action[];
  10924. /**
  10925. * Instantiate the action
  10926. * @param triggerOptions defines the trigger options
  10927. * @param children defines the list of aggregated animations to run
  10928. * @param condition defines the trigger related conditions
  10929. */
  10930. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10931. /** @hidden */
  10932. _prepare(): void;
  10933. /**
  10934. * Execute the action and executes all the aggregated actions.
  10935. */
  10936. execute(evt: ActionEvent): void;
  10937. /**
  10938. * Serializes the actions and its related information.
  10939. * @param parent defines the object to serialize in
  10940. * @returns the serialized object
  10941. */
  10942. serialize(parent: any): any;
  10943. }
  10944. /**
  10945. * This defines an action responsible to run code (external event) once triggered.
  10946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10947. */
  10948. export class ExecuteCodeAction extends Action {
  10949. /**
  10950. * The callback function to run.
  10951. */
  10952. func: (evt: ActionEvent) => void;
  10953. /**
  10954. * Instantiate the action
  10955. * @param triggerOptions defines the trigger options
  10956. * @param func defines the callback function to run
  10957. * @param condition defines the trigger related conditions
  10958. */
  10959. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10960. /**
  10961. * Execute the action and run the attached code.
  10962. */
  10963. execute(evt: ActionEvent): void;
  10964. }
  10965. /**
  10966. * This defines an action responsible to set the parent property of the target once triggered.
  10967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10968. */
  10969. export class SetParentAction extends Action {
  10970. private _parent;
  10971. private _target;
  10972. /**
  10973. * Instantiate the action
  10974. * @param triggerOptions defines the trigger options
  10975. * @param target defines the target containing the parent property
  10976. * @param parent defines from where the animation should start (animation frame)
  10977. * @param condition defines the trigger related conditions
  10978. */
  10979. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10980. /** @hidden */
  10981. _prepare(): void;
  10982. /**
  10983. * Execute the action and set the parent property.
  10984. */
  10985. execute(): void;
  10986. /**
  10987. * Serializes the actions and its related information.
  10988. * @param parent defines the object to serialize in
  10989. * @returns the serialized object
  10990. */
  10991. serialize(parent: any): any;
  10992. }
  10993. }
  10994. declare module "babylonjs/Actions/actionManager" {
  10995. import { Nullable } from "babylonjs/types";
  10996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10997. import { Scene } from "babylonjs/scene";
  10998. import { Action } from "babylonjs/Actions/action";
  10999. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11000. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11001. /**
  11002. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11003. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11005. */
  11006. export class ActionManager extends AbstractActionManager {
  11007. /**
  11008. * Nothing
  11009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11010. */
  11011. static readonly NothingTrigger: number;
  11012. /**
  11013. * On pick
  11014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11015. */
  11016. static readonly OnPickTrigger: number;
  11017. /**
  11018. * On left pick
  11019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11020. */
  11021. static readonly OnLeftPickTrigger: number;
  11022. /**
  11023. * On right pick
  11024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11025. */
  11026. static readonly OnRightPickTrigger: number;
  11027. /**
  11028. * On center pick
  11029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11030. */
  11031. static readonly OnCenterPickTrigger: number;
  11032. /**
  11033. * On pick down
  11034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11035. */
  11036. static readonly OnPickDownTrigger: number;
  11037. /**
  11038. * On double pick
  11039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11040. */
  11041. static readonly OnDoublePickTrigger: number;
  11042. /**
  11043. * On pick up
  11044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11045. */
  11046. static readonly OnPickUpTrigger: number;
  11047. /**
  11048. * On pick out.
  11049. * This trigger will only be raised if you also declared a OnPickDown
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11051. */
  11052. static readonly OnPickOutTrigger: number;
  11053. /**
  11054. * On long press
  11055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11056. */
  11057. static readonly OnLongPressTrigger: number;
  11058. /**
  11059. * On pointer over
  11060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11061. */
  11062. static readonly OnPointerOverTrigger: number;
  11063. /**
  11064. * On pointer out
  11065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11066. */
  11067. static readonly OnPointerOutTrigger: number;
  11068. /**
  11069. * On every frame
  11070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11071. */
  11072. static readonly OnEveryFrameTrigger: number;
  11073. /**
  11074. * On intersection enter
  11075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11076. */
  11077. static readonly OnIntersectionEnterTrigger: number;
  11078. /**
  11079. * On intersection exit
  11080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11081. */
  11082. static readonly OnIntersectionExitTrigger: number;
  11083. /**
  11084. * On key down
  11085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11086. */
  11087. static readonly OnKeyDownTrigger: number;
  11088. /**
  11089. * On key up
  11090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11091. */
  11092. static readonly OnKeyUpTrigger: number;
  11093. private _scene;
  11094. /**
  11095. * Creates a new action manager
  11096. * @param scene defines the hosting scene
  11097. */
  11098. constructor(scene: Scene);
  11099. /**
  11100. * Releases all associated resources
  11101. */
  11102. dispose(): void;
  11103. /**
  11104. * Gets hosting scene
  11105. * @returns the hosting scene
  11106. */
  11107. getScene(): Scene;
  11108. /**
  11109. * Does this action manager handles actions of any of the given triggers
  11110. * @param triggers defines the triggers to be tested
  11111. * @return a boolean indicating whether one (or more) of the triggers is handled
  11112. */
  11113. hasSpecificTriggers(triggers: number[]): boolean;
  11114. /**
  11115. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11116. * speed.
  11117. * @param triggerA defines the trigger to be tested
  11118. * @param triggerB defines the trigger to be tested
  11119. * @return a boolean indicating whether one (or more) of the triggers is handled
  11120. */
  11121. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11122. /**
  11123. * Does this action manager handles actions of a given trigger
  11124. * @param trigger defines the trigger to be tested
  11125. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11126. * @return whether the trigger is handled
  11127. */
  11128. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11129. /**
  11130. * Does this action manager has pointer triggers
  11131. */
  11132. readonly hasPointerTriggers: boolean;
  11133. /**
  11134. * Does this action manager has pick triggers
  11135. */
  11136. readonly hasPickTriggers: boolean;
  11137. /**
  11138. * Registers an action to this action manager
  11139. * @param action defines the action to be registered
  11140. * @return the action amended (prepared) after registration
  11141. */
  11142. registerAction(action: Action): Nullable<Action>;
  11143. /**
  11144. * Unregisters an action to this action manager
  11145. * @param action defines the action to be unregistered
  11146. * @return a boolean indicating whether the action has been unregistered
  11147. */
  11148. unregisterAction(action: Action): Boolean;
  11149. /**
  11150. * Process a specific trigger
  11151. * @param trigger defines the trigger to process
  11152. * @param evt defines the event details to be processed
  11153. */
  11154. processTrigger(trigger: number, evt?: IActionEvent): void;
  11155. /** @hidden */
  11156. _getEffectiveTarget(target: any, propertyPath: string): any;
  11157. /** @hidden */
  11158. _getProperty(propertyPath: string): string;
  11159. /**
  11160. * Serialize this manager to a JSON object
  11161. * @param name defines the property name to store this manager
  11162. * @returns a JSON representation of this manager
  11163. */
  11164. serialize(name: string): any;
  11165. /**
  11166. * Creates a new ActionManager from a JSON data
  11167. * @param parsedActions defines the JSON data to read from
  11168. * @param object defines the hosting mesh
  11169. * @param scene defines the hosting scene
  11170. */
  11171. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11172. /**
  11173. * Get a trigger name by index
  11174. * @param trigger defines the trigger index
  11175. * @returns a trigger name
  11176. */
  11177. static GetTriggerName(trigger: number): string;
  11178. }
  11179. }
  11180. declare module "babylonjs/Culling/ray" {
  11181. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11182. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11184. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11185. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11186. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11187. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11188. /**
  11189. * Class representing a ray with position and direction
  11190. */
  11191. export class Ray {
  11192. /** origin point */
  11193. origin: Vector3;
  11194. /** direction */
  11195. direction: Vector3;
  11196. /** length of the ray */
  11197. length: number;
  11198. private static readonly TmpVector3;
  11199. private _tmpRay;
  11200. /**
  11201. * Creates a new ray
  11202. * @param origin origin point
  11203. * @param direction direction
  11204. * @param length length of the ray
  11205. */
  11206. constructor(
  11207. /** origin point */
  11208. origin: Vector3,
  11209. /** direction */
  11210. direction: Vector3,
  11211. /** length of the ray */
  11212. length?: number);
  11213. /**
  11214. * Checks if the ray intersects a box
  11215. * @param minimum bound of the box
  11216. * @param maximum bound of the box
  11217. * @param intersectionTreshold extra extend to be added to the box in all direction
  11218. * @returns if the box was hit
  11219. */
  11220. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11221. /**
  11222. * Checks if the ray intersects a box
  11223. * @param box the bounding box to check
  11224. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11225. * @returns if the box was hit
  11226. */
  11227. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11228. /**
  11229. * If the ray hits a sphere
  11230. * @param sphere the bounding sphere to check
  11231. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11232. * @returns true if it hits the sphere
  11233. */
  11234. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11235. /**
  11236. * If the ray hits a triange
  11237. * @param vertex0 triangle vertex
  11238. * @param vertex1 triangle vertex
  11239. * @param vertex2 triangle vertex
  11240. * @returns intersection information if hit
  11241. */
  11242. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11243. /**
  11244. * Checks if ray intersects a plane
  11245. * @param plane the plane to check
  11246. * @returns the distance away it was hit
  11247. */
  11248. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11249. /**
  11250. * Checks if ray intersects a mesh
  11251. * @param mesh the mesh to check
  11252. * @param fastCheck if only the bounding box should checked
  11253. * @returns picking info of the intersecton
  11254. */
  11255. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11256. /**
  11257. * Checks if ray intersects a mesh
  11258. * @param meshes the meshes to check
  11259. * @param fastCheck if only the bounding box should checked
  11260. * @param results array to store result in
  11261. * @returns Array of picking infos
  11262. */
  11263. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11264. private _comparePickingInfo;
  11265. private static smallnum;
  11266. private static rayl;
  11267. /**
  11268. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11269. * @param sega the first point of the segment to test the intersection against
  11270. * @param segb the second point of the segment to test the intersection against
  11271. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11272. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11273. */
  11274. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11275. /**
  11276. * Update the ray from viewport position
  11277. * @param x position
  11278. * @param y y position
  11279. * @param viewportWidth viewport width
  11280. * @param viewportHeight viewport height
  11281. * @param world world matrix
  11282. * @param view view matrix
  11283. * @param projection projection matrix
  11284. * @returns this ray updated
  11285. */
  11286. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11287. /**
  11288. * Creates a ray with origin and direction of 0,0,0
  11289. * @returns the new ray
  11290. */
  11291. static Zero(): Ray;
  11292. /**
  11293. * Creates a new ray from screen space and viewport
  11294. * @param x position
  11295. * @param y y position
  11296. * @param viewportWidth viewport width
  11297. * @param viewportHeight viewport height
  11298. * @param world world matrix
  11299. * @param view view matrix
  11300. * @param projection projection matrix
  11301. * @returns new ray
  11302. */
  11303. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11304. /**
  11305. * 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
  11306. * transformed to the given world matrix.
  11307. * @param origin The origin point
  11308. * @param end The end point
  11309. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11310. * @returns the new ray
  11311. */
  11312. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11313. /**
  11314. * Transforms a ray by a matrix
  11315. * @param ray ray to transform
  11316. * @param matrix matrix to apply
  11317. * @returns the resulting new ray
  11318. */
  11319. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11320. /**
  11321. * Transforms a ray by a matrix
  11322. * @param ray ray to transform
  11323. * @param matrix matrix to apply
  11324. * @param result ray to store result in
  11325. */
  11326. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11327. /**
  11328. * Unproject a ray from screen space to object space
  11329. * @param sourceX defines the screen space x coordinate to use
  11330. * @param sourceY defines the screen space y coordinate to use
  11331. * @param viewportWidth defines the current width of the viewport
  11332. * @param viewportHeight defines the current height of the viewport
  11333. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11334. * @param view defines the view matrix to use
  11335. * @param projection defines the projection matrix to use
  11336. */
  11337. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11338. }
  11339. /**
  11340. * Type used to define predicate used to select faces when a mesh intersection is detected
  11341. */
  11342. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11343. module "babylonjs/scene" {
  11344. interface Scene {
  11345. /** @hidden */
  11346. _tempPickingRay: Nullable<Ray>;
  11347. /** @hidden */
  11348. _cachedRayForTransform: Ray;
  11349. /** @hidden */
  11350. _pickWithRayInverseMatrix: Matrix;
  11351. /** @hidden */
  11352. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11353. /** @hidden */
  11354. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11355. }
  11356. }
  11357. }
  11358. declare module "babylonjs/sceneComponent" {
  11359. import { Scene } from "babylonjs/scene";
  11360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11361. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11362. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11363. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11364. import { Nullable } from "babylonjs/types";
  11365. import { Camera } from "babylonjs/Cameras/camera";
  11366. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11367. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11368. import { AbstractScene } from "babylonjs/abstractScene";
  11369. /**
  11370. * Groups all the scene component constants in one place to ease maintenance.
  11371. * @hidden
  11372. */
  11373. export class SceneComponentConstants {
  11374. static readonly NAME_EFFECTLAYER: string;
  11375. static readonly NAME_LAYER: string;
  11376. static readonly NAME_LENSFLARESYSTEM: string;
  11377. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11378. static readonly NAME_PARTICLESYSTEM: string;
  11379. static readonly NAME_GAMEPAD: string;
  11380. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11381. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11382. static readonly NAME_DEPTHRENDERER: string;
  11383. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11384. static readonly NAME_SPRITE: string;
  11385. static readonly NAME_OUTLINERENDERER: string;
  11386. static readonly NAME_PROCEDURALTEXTURE: string;
  11387. static readonly NAME_SHADOWGENERATOR: string;
  11388. static readonly NAME_OCTREE: string;
  11389. static readonly NAME_PHYSICSENGINE: string;
  11390. static readonly NAME_AUDIO: string;
  11391. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11392. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11393. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11394. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11395. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11396. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11397. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11398. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11399. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11400. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11401. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11402. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11403. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11404. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11405. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11406. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11407. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11408. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11409. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11410. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11411. static readonly STEP_AFTERRENDER_AUDIO: number;
  11412. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11413. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11414. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11415. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11416. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11417. static readonly STEP_POINTERMOVE_SPRITE: number;
  11418. static readonly STEP_POINTERDOWN_SPRITE: number;
  11419. static readonly STEP_POINTERUP_SPRITE: number;
  11420. }
  11421. /**
  11422. * This represents a scene component.
  11423. *
  11424. * This is used to decouple the dependency the scene is having on the different workloads like
  11425. * layers, post processes...
  11426. */
  11427. export interface ISceneComponent {
  11428. /**
  11429. * The name of the component. Each component must have a unique name.
  11430. */
  11431. name: string;
  11432. /**
  11433. * The scene the component belongs to.
  11434. */
  11435. scene: Scene;
  11436. /**
  11437. * Register the component to one instance of a scene.
  11438. */
  11439. register(): void;
  11440. /**
  11441. * Rebuilds the elements related to this component in case of
  11442. * context lost for instance.
  11443. */
  11444. rebuild(): void;
  11445. /**
  11446. * Disposes the component and the associated ressources.
  11447. */
  11448. dispose(): void;
  11449. }
  11450. /**
  11451. * This represents a SERIALIZABLE scene component.
  11452. *
  11453. * This extends Scene Component to add Serialization methods on top.
  11454. */
  11455. export interface ISceneSerializableComponent extends ISceneComponent {
  11456. /**
  11457. * Adds all the element from the container to the scene
  11458. * @param container the container holding the elements
  11459. */
  11460. addFromContainer(container: AbstractScene): void;
  11461. /**
  11462. * Removes all the elements in the container from the scene
  11463. * @param container contains the elements to remove
  11464. */
  11465. removeFromContainer(container: AbstractScene): void;
  11466. /**
  11467. * Serializes the component data to the specified json object
  11468. * @param serializationObject The object to serialize to
  11469. */
  11470. serialize(serializationObject: any): void;
  11471. }
  11472. /**
  11473. * Strong typing of a Mesh related stage step action
  11474. */
  11475. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11476. /**
  11477. * Strong typing of a Evaluate Sub Mesh related stage step action
  11478. */
  11479. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11480. /**
  11481. * Strong typing of a Active Mesh related stage step action
  11482. */
  11483. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11484. /**
  11485. * Strong typing of a Camera related stage step action
  11486. */
  11487. export type CameraStageAction = (camera: Camera) => void;
  11488. /**
  11489. * Strong typing of a Render Target related stage step action
  11490. */
  11491. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11492. /**
  11493. * Strong typing of a RenderingGroup related stage step action
  11494. */
  11495. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11496. /**
  11497. * Strong typing of a Mesh Render related stage step action
  11498. */
  11499. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11500. /**
  11501. * Strong typing of a simple stage step action
  11502. */
  11503. export type SimpleStageAction = () => void;
  11504. /**
  11505. * Strong typing of a render target action.
  11506. */
  11507. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11508. /**
  11509. * Strong typing of a pointer move action.
  11510. */
  11511. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11512. /**
  11513. * Strong typing of a pointer up/down action.
  11514. */
  11515. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11516. /**
  11517. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11518. * @hidden
  11519. */
  11520. export class Stage<T extends Function> extends Array<{
  11521. index: number;
  11522. component: ISceneComponent;
  11523. action: T;
  11524. }> {
  11525. /**
  11526. * Hide ctor from the rest of the world.
  11527. * @param items The items to add.
  11528. */
  11529. private constructor();
  11530. /**
  11531. * Creates a new Stage.
  11532. * @returns A new instance of a Stage
  11533. */
  11534. static Create<T extends Function>(): Stage<T>;
  11535. /**
  11536. * Registers a step in an ordered way in the targeted stage.
  11537. * @param index Defines the position to register the step in
  11538. * @param component Defines the component attached to the step
  11539. * @param action Defines the action to launch during the step
  11540. */
  11541. registerStep(index: number, component: ISceneComponent, action: T): void;
  11542. /**
  11543. * Clears all the steps from the stage.
  11544. */
  11545. clear(): void;
  11546. }
  11547. }
  11548. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11549. import { Nullable } from "babylonjs/types";
  11550. import { Observable } from "babylonjs/Misc/observable";
  11551. import { Scene } from "babylonjs/scene";
  11552. import { Sprite } from "babylonjs/Sprites/sprite";
  11553. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11554. import { Ray } from "babylonjs/Culling/ray";
  11555. import { Camera } from "babylonjs/Cameras/camera";
  11556. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11557. import { ISceneComponent } from "babylonjs/sceneComponent";
  11558. module "babylonjs/scene" {
  11559. interface Scene {
  11560. /** @hidden */
  11561. _pointerOverSprite: Nullable<Sprite>;
  11562. /** @hidden */
  11563. _pickedDownSprite: Nullable<Sprite>;
  11564. /** @hidden */
  11565. _tempSpritePickingRay: Nullable<Ray>;
  11566. /**
  11567. * All of the sprite managers added to this scene
  11568. * @see http://doc.babylonjs.com/babylon101/sprites
  11569. */
  11570. spriteManagers: Array<ISpriteManager>;
  11571. /**
  11572. * An event triggered when sprites rendering is about to start
  11573. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11574. */
  11575. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11576. /**
  11577. * An event triggered when sprites rendering is done
  11578. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11579. */
  11580. onAfterSpritesRenderingObservable: Observable<Scene>;
  11581. /** @hidden */
  11582. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11583. /** Launch a ray to try to pick a sprite in the scene
  11584. * @param x position on screen
  11585. * @param y position on screen
  11586. * @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
  11587. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11588. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11589. * @returns a PickingInfo
  11590. */
  11591. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11592. /** Use the given ray to pick a sprite in the scene
  11593. * @param ray The ray (in world space) to use to pick meshes
  11594. * @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
  11595. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11596. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11597. * @returns a PickingInfo
  11598. */
  11599. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11600. /**
  11601. * Force the sprite under the pointer
  11602. * @param sprite defines the sprite to use
  11603. */
  11604. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11605. /**
  11606. * Gets the sprite under the pointer
  11607. * @returns a Sprite or null if no sprite is under the pointer
  11608. */
  11609. getPointerOverSprite(): Nullable<Sprite>;
  11610. }
  11611. }
  11612. /**
  11613. * Defines the sprite scene component responsible to manage sprites
  11614. * in a given scene.
  11615. */
  11616. export class SpriteSceneComponent implements ISceneComponent {
  11617. /**
  11618. * The component name helpfull to identify the component in the list of scene components.
  11619. */
  11620. readonly name: string;
  11621. /**
  11622. * The scene the component belongs to.
  11623. */
  11624. scene: Scene;
  11625. /** @hidden */
  11626. private _spritePredicate;
  11627. /**
  11628. * Creates a new instance of the component for the given scene
  11629. * @param scene Defines the scene to register the component in
  11630. */
  11631. constructor(scene: Scene);
  11632. /**
  11633. * Registers the component in a given scene
  11634. */
  11635. register(): void;
  11636. /**
  11637. * Rebuilds the elements related to this component in case of
  11638. * context lost for instance.
  11639. */
  11640. rebuild(): void;
  11641. /**
  11642. * Disposes the component and the associated ressources.
  11643. */
  11644. dispose(): void;
  11645. private _pickSpriteButKeepRay;
  11646. private _pointerMove;
  11647. private _pointerDown;
  11648. private _pointerUp;
  11649. }
  11650. }
  11651. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11652. /** @hidden */
  11653. export var fogFragmentDeclaration: {
  11654. name: string;
  11655. shader: string;
  11656. };
  11657. }
  11658. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11659. /** @hidden */
  11660. export var fogFragment: {
  11661. name: string;
  11662. shader: string;
  11663. };
  11664. }
  11665. declare module "babylonjs/Shaders/sprites.fragment" {
  11666. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11667. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11668. /** @hidden */
  11669. export var spritesPixelShader: {
  11670. name: string;
  11671. shader: string;
  11672. };
  11673. }
  11674. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11675. /** @hidden */
  11676. export var fogVertexDeclaration: {
  11677. name: string;
  11678. shader: string;
  11679. };
  11680. }
  11681. declare module "babylonjs/Shaders/sprites.vertex" {
  11682. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11683. /** @hidden */
  11684. export var spritesVertexShader: {
  11685. name: string;
  11686. shader: string;
  11687. };
  11688. }
  11689. declare module "babylonjs/Sprites/spriteManager" {
  11690. import { IDisposable, Scene } from "babylonjs/scene";
  11691. import { Nullable } from "babylonjs/types";
  11692. import { Observable } from "babylonjs/Misc/observable";
  11693. import { Sprite } from "babylonjs/Sprites/sprite";
  11694. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11695. import { Camera } from "babylonjs/Cameras/camera";
  11696. import { Texture } from "babylonjs/Materials/Textures/texture";
  11697. import "babylonjs/Shaders/sprites.fragment";
  11698. import "babylonjs/Shaders/sprites.vertex";
  11699. import { Ray } from "babylonjs/Culling/ray";
  11700. /**
  11701. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11702. */
  11703. export interface ISpriteManager extends IDisposable {
  11704. /**
  11705. * Restricts the camera to viewing objects with the same layerMask.
  11706. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11707. */
  11708. layerMask: number;
  11709. /**
  11710. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11711. */
  11712. isPickable: boolean;
  11713. /**
  11714. * Specifies the rendering group id for this mesh (0 by default)
  11715. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11716. */
  11717. renderingGroupId: number;
  11718. /**
  11719. * Defines the list of sprites managed by the manager.
  11720. */
  11721. sprites: Array<Sprite>;
  11722. /**
  11723. * Tests the intersection of a sprite with a specific ray.
  11724. * @param ray The ray we are sending to test the collision
  11725. * @param camera The camera space we are sending rays in
  11726. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11727. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11728. * @returns picking info or null.
  11729. */
  11730. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11731. /**
  11732. * Renders the list of sprites on screen.
  11733. */
  11734. render(): void;
  11735. }
  11736. /**
  11737. * Class used to manage multiple sprites on the same spritesheet
  11738. * @see http://doc.babylonjs.com/babylon101/sprites
  11739. */
  11740. export class SpriteManager implements ISpriteManager {
  11741. /** defines the manager's name */
  11742. name: string;
  11743. /** Gets the list of sprites */
  11744. sprites: Sprite[];
  11745. /** Gets or sets the rendering group id (0 by default) */
  11746. renderingGroupId: number;
  11747. /** Gets or sets camera layer mask */
  11748. layerMask: number;
  11749. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11750. fogEnabled: boolean;
  11751. /** Gets or sets a boolean indicating if the sprites are pickable */
  11752. isPickable: boolean;
  11753. /** Defines the default width of a cell in the spritesheet */
  11754. cellWidth: number;
  11755. /** Defines the default height of a cell in the spritesheet */
  11756. cellHeight: number;
  11757. /**
  11758. * An event triggered when the manager is disposed.
  11759. */
  11760. onDisposeObservable: Observable<SpriteManager>;
  11761. private _onDisposeObserver;
  11762. /**
  11763. * Callback called when the manager is disposed
  11764. */
  11765. onDispose: () => void;
  11766. private _capacity;
  11767. private _spriteTexture;
  11768. private _epsilon;
  11769. private _scene;
  11770. private _vertexData;
  11771. private _buffer;
  11772. private _vertexBuffers;
  11773. private _indexBuffer;
  11774. private _effectBase;
  11775. private _effectFog;
  11776. /**
  11777. * Gets or sets the spritesheet texture
  11778. */
  11779. texture: Texture;
  11780. /**
  11781. * Creates a new sprite manager
  11782. * @param name defines the manager's name
  11783. * @param imgUrl defines the sprite sheet url
  11784. * @param capacity defines the maximum allowed number of sprites
  11785. * @param cellSize defines the size of a sprite cell
  11786. * @param scene defines the hosting scene
  11787. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11788. * @param samplingMode defines the smapling mode to use with spritesheet
  11789. */
  11790. constructor(
  11791. /** defines the manager's name */
  11792. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11793. private _appendSpriteVertex;
  11794. /**
  11795. * Intersects the sprites with a ray
  11796. * @param ray defines the ray to intersect with
  11797. * @param camera defines the current active camera
  11798. * @param predicate defines a predicate used to select candidate sprites
  11799. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11800. * @returns null if no hit or a PickingInfo
  11801. */
  11802. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11803. /**
  11804. * Render all child sprites
  11805. */
  11806. render(): void;
  11807. /**
  11808. * Release associated resources
  11809. */
  11810. dispose(): void;
  11811. }
  11812. }
  11813. declare module "babylonjs/Sprites/sprite" {
  11814. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11815. import { Nullable } from "babylonjs/types";
  11816. import { ActionManager } from "babylonjs/Actions/actionManager";
  11817. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11818. /**
  11819. * Class used to represent a sprite
  11820. * @see http://doc.babylonjs.com/babylon101/sprites
  11821. */
  11822. export class Sprite {
  11823. /** defines the name */
  11824. name: string;
  11825. /** Gets or sets the current world position */
  11826. position: Vector3;
  11827. /** Gets or sets the main color */
  11828. color: Color4;
  11829. /** Gets or sets the width */
  11830. width: number;
  11831. /** Gets or sets the height */
  11832. height: number;
  11833. /** Gets or sets rotation angle */
  11834. angle: number;
  11835. /** Gets or sets the cell index in the sprite sheet */
  11836. cellIndex: number;
  11837. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11838. invertU: number;
  11839. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11840. invertV: number;
  11841. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11842. disposeWhenFinishedAnimating: boolean;
  11843. /** Gets the list of attached animations */
  11844. animations: Animation[];
  11845. /** Gets or sets a boolean indicating if the sprite can be picked */
  11846. isPickable: boolean;
  11847. /**
  11848. * Gets or sets the associated action manager
  11849. */
  11850. actionManager: Nullable<ActionManager>;
  11851. private _animationStarted;
  11852. private _loopAnimation;
  11853. private _fromIndex;
  11854. private _toIndex;
  11855. private _delay;
  11856. private _direction;
  11857. private _manager;
  11858. private _time;
  11859. private _onAnimationEnd;
  11860. /**
  11861. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11862. */
  11863. isVisible: boolean;
  11864. /**
  11865. * Gets or sets the sprite size
  11866. */
  11867. size: number;
  11868. /**
  11869. * Creates a new Sprite
  11870. * @param name defines the name
  11871. * @param manager defines the manager
  11872. */
  11873. constructor(
  11874. /** defines the name */
  11875. name: string, manager: ISpriteManager);
  11876. /**
  11877. * Starts an animation
  11878. * @param from defines the initial key
  11879. * @param to defines the end key
  11880. * @param loop defines if the animation must loop
  11881. * @param delay defines the start delay (in ms)
  11882. * @param onAnimationEnd defines a callback to call when animation ends
  11883. */
  11884. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11885. /** Stops current animation (if any) */
  11886. stopAnimation(): void;
  11887. /** @hidden */
  11888. _animate(deltaTime: number): void;
  11889. /** Release associated resources */
  11890. dispose(): void;
  11891. }
  11892. }
  11893. declare module "babylonjs/Collisions/pickingInfo" {
  11894. import { Nullable } from "babylonjs/types";
  11895. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11897. import { Sprite } from "babylonjs/Sprites/sprite";
  11898. import { Ray } from "babylonjs/Culling/ray";
  11899. /**
  11900. * Information about the result of picking within a scene
  11901. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11902. */
  11903. export class PickingInfo {
  11904. /** @hidden */
  11905. _pickingUnavailable: boolean;
  11906. /**
  11907. * If the pick collided with an object
  11908. */
  11909. hit: boolean;
  11910. /**
  11911. * Distance away where the pick collided
  11912. */
  11913. distance: number;
  11914. /**
  11915. * The location of pick collision
  11916. */
  11917. pickedPoint: Nullable<Vector3>;
  11918. /**
  11919. * The mesh corresponding the the pick collision
  11920. */
  11921. pickedMesh: Nullable<AbstractMesh>;
  11922. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11923. bu: number;
  11924. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11925. bv: number;
  11926. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11927. faceId: number;
  11928. /** Id of the the submesh that was picked */
  11929. subMeshId: number;
  11930. /** If a sprite was picked, this will be the sprite the pick collided with */
  11931. pickedSprite: Nullable<Sprite>;
  11932. /**
  11933. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11934. */
  11935. originMesh: Nullable<AbstractMesh>;
  11936. /**
  11937. * The ray that was used to perform the picking.
  11938. */
  11939. ray: Nullable<Ray>;
  11940. /**
  11941. * Gets the normal correspodning to the face the pick collided with
  11942. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11943. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11944. * @returns The normal correspodning to the face the pick collided with
  11945. */
  11946. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11947. /**
  11948. * Gets the texture coordinates of where the pick occured
  11949. * @returns the vector containing the coordnates of the texture
  11950. */
  11951. getTextureCoordinates(): Nullable<Vector2>;
  11952. }
  11953. }
  11954. declare module "babylonjs/Events/pointerEvents" {
  11955. import { Nullable } from "babylonjs/types";
  11956. import { Vector2 } from "babylonjs/Maths/math";
  11957. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11958. import { Ray } from "babylonjs/Culling/ray";
  11959. /**
  11960. * Gather the list of pointer event types as constants.
  11961. */
  11962. export class PointerEventTypes {
  11963. /**
  11964. * 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.
  11965. */
  11966. static readonly POINTERDOWN: number;
  11967. /**
  11968. * The pointerup event is fired when a pointer is no longer active.
  11969. */
  11970. static readonly POINTERUP: number;
  11971. /**
  11972. * The pointermove event is fired when a pointer changes coordinates.
  11973. */
  11974. static readonly POINTERMOVE: number;
  11975. /**
  11976. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11977. */
  11978. static readonly POINTERWHEEL: number;
  11979. /**
  11980. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11981. */
  11982. static readonly POINTERPICK: number;
  11983. /**
  11984. * The pointertap event is fired when a the object has been touched and released without drag.
  11985. */
  11986. static readonly POINTERTAP: number;
  11987. /**
  11988. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11989. */
  11990. static readonly POINTERDOUBLETAP: number;
  11991. }
  11992. /**
  11993. * Base class of pointer info types.
  11994. */
  11995. export class PointerInfoBase {
  11996. /**
  11997. * Defines the type of event (PointerEventTypes)
  11998. */
  11999. type: number;
  12000. /**
  12001. * Defines the related dom event
  12002. */
  12003. event: PointerEvent | MouseWheelEvent;
  12004. /**
  12005. * Instantiates the base class of pointers info.
  12006. * @param type Defines the type of event (PointerEventTypes)
  12007. * @param event Defines the related dom event
  12008. */
  12009. constructor(
  12010. /**
  12011. * Defines the type of event (PointerEventTypes)
  12012. */
  12013. type: number,
  12014. /**
  12015. * Defines the related dom event
  12016. */
  12017. event: PointerEvent | MouseWheelEvent);
  12018. }
  12019. /**
  12020. * This class is used to store pointer related info for the onPrePointerObservable event.
  12021. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12022. */
  12023. export class PointerInfoPre extends PointerInfoBase {
  12024. /**
  12025. * Ray from a pointer if availible (eg. 6dof controller)
  12026. */
  12027. ray: Nullable<Ray>;
  12028. /**
  12029. * Defines the local position of the pointer on the canvas.
  12030. */
  12031. localPosition: Vector2;
  12032. /**
  12033. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12034. */
  12035. skipOnPointerObservable: boolean;
  12036. /**
  12037. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12038. * @param type Defines the type of event (PointerEventTypes)
  12039. * @param event Defines the related dom event
  12040. * @param localX Defines the local x coordinates of the pointer when the event occured
  12041. * @param localY Defines the local y coordinates of the pointer when the event occured
  12042. */
  12043. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12044. }
  12045. /**
  12046. * This type contains all the data related to a pointer event in Babylon.js.
  12047. * 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.
  12048. */
  12049. export class PointerInfo extends PointerInfoBase {
  12050. /**
  12051. * Defines the picking info associated to the info (if any)\
  12052. */
  12053. pickInfo: Nullable<PickingInfo>;
  12054. /**
  12055. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12056. * @param type Defines the type of event (PointerEventTypes)
  12057. * @param event Defines the related dom event
  12058. * @param pickInfo Defines the picking info associated to the info (if any)\
  12059. */
  12060. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12061. /**
  12062. * Defines the picking info associated to the info (if any)\
  12063. */
  12064. pickInfo: Nullable<PickingInfo>);
  12065. }
  12066. /**
  12067. * Data relating to a touch event on the screen.
  12068. */
  12069. export interface PointerTouch {
  12070. /**
  12071. * X coordinate of touch.
  12072. */
  12073. x: number;
  12074. /**
  12075. * Y coordinate of touch.
  12076. */
  12077. y: number;
  12078. /**
  12079. * Id of touch. Unique for each finger.
  12080. */
  12081. pointerId: number;
  12082. /**
  12083. * Event type passed from DOM.
  12084. */
  12085. type: any;
  12086. }
  12087. }
  12088. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12089. import { Nullable } from "babylonjs/types";
  12090. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12091. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12092. /**
  12093. * Manage the mouse inputs to control the movement of a free camera.
  12094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12095. */
  12096. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12097. /**
  12098. * Define if touch is enabled in the mouse input
  12099. */
  12100. touchEnabled: boolean;
  12101. /**
  12102. * Defines the camera the input is attached to.
  12103. */
  12104. camera: FreeCamera;
  12105. /**
  12106. * Defines the buttons associated with the input to handle camera move.
  12107. */
  12108. buttons: number[];
  12109. /**
  12110. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12111. */
  12112. angularSensibility: number;
  12113. private _pointerInput;
  12114. private _onMouseMove;
  12115. private _observer;
  12116. private previousPosition;
  12117. /**
  12118. * Manage the mouse inputs to control the movement of a free camera.
  12119. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12120. * @param touchEnabled Defines if touch is enabled or not
  12121. */
  12122. constructor(
  12123. /**
  12124. * Define if touch is enabled in the mouse input
  12125. */
  12126. touchEnabled?: boolean);
  12127. /**
  12128. * Attach the input controls to a specific dom element to get the input from.
  12129. * @param element Defines the element the controls should be listened from
  12130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12131. */
  12132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12133. /**
  12134. * Detach the current controls from the specified dom element.
  12135. * @param element Defines the element to stop listening the inputs from
  12136. */
  12137. detachControl(element: Nullable<HTMLElement>): void;
  12138. /**
  12139. * Gets the class name of the current intput.
  12140. * @returns the class name
  12141. */
  12142. getClassName(): string;
  12143. /**
  12144. * Get the friendly name associated with the input class.
  12145. * @returns the input friendly name
  12146. */
  12147. getSimpleName(): string;
  12148. }
  12149. }
  12150. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12151. import { Nullable } from "babylonjs/types";
  12152. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12153. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12154. /**
  12155. * Manage the touch inputs to control the movement of a free camera.
  12156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12157. */
  12158. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12159. /**
  12160. * Defines the camera the input is attached to.
  12161. */
  12162. camera: FreeCamera;
  12163. /**
  12164. * Defines the touch sensibility for rotation.
  12165. * The higher the faster.
  12166. */
  12167. touchAngularSensibility: number;
  12168. /**
  12169. * Defines the touch sensibility for move.
  12170. * The higher the faster.
  12171. */
  12172. touchMoveSensibility: number;
  12173. private _offsetX;
  12174. private _offsetY;
  12175. private _pointerPressed;
  12176. private _pointerInput;
  12177. private _observer;
  12178. private _onLostFocus;
  12179. /**
  12180. * Attach the input controls to a specific dom element to get the input from.
  12181. * @param element Defines the element the controls should be listened from
  12182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12183. */
  12184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12185. /**
  12186. * Detach the current controls from the specified dom element.
  12187. * @param element Defines the element to stop listening the inputs from
  12188. */
  12189. detachControl(element: Nullable<HTMLElement>): void;
  12190. /**
  12191. * Update the current camera state depending on the inputs that have been used this frame.
  12192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12193. */
  12194. checkInputs(): void;
  12195. /**
  12196. * Gets the class name of the current intput.
  12197. * @returns the class name
  12198. */
  12199. getClassName(): string;
  12200. /**
  12201. * Get the friendly name associated with the input class.
  12202. * @returns the input friendly name
  12203. */
  12204. getSimpleName(): string;
  12205. }
  12206. }
  12207. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12208. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12209. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12210. /**
  12211. * Default Inputs manager for the FreeCamera.
  12212. * It groups all the default supported inputs for ease of use.
  12213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12214. */
  12215. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12216. /**
  12217. * Instantiates a new FreeCameraInputsManager.
  12218. * @param camera Defines the camera the inputs belong to
  12219. */
  12220. constructor(camera: FreeCamera);
  12221. /**
  12222. * Add keyboard input support to the input manager.
  12223. * @returns the current input manager
  12224. */
  12225. addKeyboard(): FreeCameraInputsManager;
  12226. /**
  12227. * Add mouse input support to the input manager.
  12228. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12229. * @returns the current input manager
  12230. */
  12231. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12232. /**
  12233. * Add touch input support to the input manager.
  12234. * @returns the current input manager
  12235. */
  12236. addTouch(): FreeCameraInputsManager;
  12237. }
  12238. }
  12239. declare module "babylonjs/Cameras/freeCamera" {
  12240. import { Vector3 } from "babylonjs/Maths/math";
  12241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12242. import { Scene } from "babylonjs/scene";
  12243. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12244. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12245. /**
  12246. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12247. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12248. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12249. */
  12250. export class FreeCamera extends TargetCamera {
  12251. /**
  12252. * Define the collision ellipsoid of the camera.
  12253. * This is helpful to simulate a camera body like the player body around the camera
  12254. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12255. */
  12256. ellipsoid: Vector3;
  12257. /**
  12258. * Define an offset for the position of the ellipsoid around the camera.
  12259. * This can be helpful to determine the center of the body near the gravity center of the body
  12260. * instead of its head.
  12261. */
  12262. ellipsoidOffset: Vector3;
  12263. /**
  12264. * Enable or disable collisions of the camera with the rest of the scene objects.
  12265. */
  12266. checkCollisions: boolean;
  12267. /**
  12268. * Enable or disable gravity on the camera.
  12269. */
  12270. applyGravity: boolean;
  12271. /**
  12272. * Define the input manager associated to the camera.
  12273. */
  12274. inputs: FreeCameraInputsManager;
  12275. /**
  12276. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12277. * Higher values reduce sensitivity.
  12278. */
  12279. /**
  12280. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12281. * Higher values reduce sensitivity.
  12282. */
  12283. angularSensibility: number;
  12284. /**
  12285. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12286. */
  12287. keysUp: number[];
  12288. /**
  12289. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12290. */
  12291. keysDown: number[];
  12292. /**
  12293. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12294. */
  12295. keysLeft: number[];
  12296. /**
  12297. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12298. */
  12299. keysRight: number[];
  12300. /**
  12301. * Event raised when the camera collide with a mesh in the scene.
  12302. */
  12303. onCollide: (collidedMesh: AbstractMesh) => void;
  12304. private _collider;
  12305. private _needMoveForGravity;
  12306. private _oldPosition;
  12307. private _diffPosition;
  12308. private _newPosition;
  12309. /** @hidden */
  12310. _localDirection: Vector3;
  12311. /** @hidden */
  12312. _transformedDirection: Vector3;
  12313. /**
  12314. * Instantiates a Free Camera.
  12315. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12316. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12317. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12318. * @param name Define the name of the camera in the scene
  12319. * @param position Define the start position of the camera in the scene
  12320. * @param scene Define the scene the camera belongs to
  12321. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12322. */
  12323. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12324. /**
  12325. * Attached controls to the current camera.
  12326. * @param element Defines the element the controls should be listened from
  12327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12328. */
  12329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12330. /**
  12331. * Detach the current controls from the camera.
  12332. * The camera will stop reacting to inputs.
  12333. * @param element Defines the element to stop listening the inputs from
  12334. */
  12335. detachControl(element: HTMLElement): void;
  12336. private _collisionMask;
  12337. /**
  12338. * Define a collision mask to limit the list of object the camera can collide with
  12339. */
  12340. collisionMask: number;
  12341. /** @hidden */
  12342. _collideWithWorld(displacement: Vector3): void;
  12343. private _onCollisionPositionChange;
  12344. /** @hidden */
  12345. _checkInputs(): void;
  12346. /** @hidden */
  12347. _decideIfNeedsToMove(): boolean;
  12348. /** @hidden */
  12349. _updatePosition(): void;
  12350. /**
  12351. * Destroy the camera and release the current resources hold by it.
  12352. */
  12353. dispose(): void;
  12354. /**
  12355. * Gets the current object class name.
  12356. * @return the class name
  12357. */
  12358. getClassName(): string;
  12359. }
  12360. }
  12361. declare module "babylonjs/Gamepads/gamepad" {
  12362. import { Observable } from "babylonjs/Misc/observable";
  12363. /**
  12364. * Represents a gamepad control stick position
  12365. */
  12366. export class StickValues {
  12367. /**
  12368. * The x component of the control stick
  12369. */
  12370. x: number;
  12371. /**
  12372. * The y component of the control stick
  12373. */
  12374. y: number;
  12375. /**
  12376. * Initializes the gamepad x and y control stick values
  12377. * @param x The x component of the gamepad control stick value
  12378. * @param y The y component of the gamepad control stick value
  12379. */
  12380. constructor(
  12381. /**
  12382. * The x component of the control stick
  12383. */
  12384. x: number,
  12385. /**
  12386. * The y component of the control stick
  12387. */
  12388. y: number);
  12389. }
  12390. /**
  12391. * An interface which manages callbacks for gamepad button changes
  12392. */
  12393. export interface GamepadButtonChanges {
  12394. /**
  12395. * Called when a gamepad has been changed
  12396. */
  12397. changed: boolean;
  12398. /**
  12399. * Called when a gamepad press event has been triggered
  12400. */
  12401. pressChanged: boolean;
  12402. /**
  12403. * Called when a touch event has been triggered
  12404. */
  12405. touchChanged: boolean;
  12406. /**
  12407. * Called when a value has changed
  12408. */
  12409. valueChanged: boolean;
  12410. }
  12411. /**
  12412. * Represents a gamepad
  12413. */
  12414. export class Gamepad {
  12415. /**
  12416. * The id of the gamepad
  12417. */
  12418. id: string;
  12419. /**
  12420. * The index of the gamepad
  12421. */
  12422. index: number;
  12423. /**
  12424. * The browser gamepad
  12425. */
  12426. browserGamepad: any;
  12427. /**
  12428. * Specifies what type of gamepad this represents
  12429. */
  12430. type: number;
  12431. private _leftStick;
  12432. private _rightStick;
  12433. /** @hidden */
  12434. _isConnected: boolean;
  12435. private _leftStickAxisX;
  12436. private _leftStickAxisY;
  12437. private _rightStickAxisX;
  12438. private _rightStickAxisY;
  12439. /**
  12440. * Triggered when the left control stick has been changed
  12441. */
  12442. private _onleftstickchanged;
  12443. /**
  12444. * Triggered when the right control stick has been changed
  12445. */
  12446. private _onrightstickchanged;
  12447. /**
  12448. * Represents a gamepad controller
  12449. */
  12450. static GAMEPAD: number;
  12451. /**
  12452. * Represents a generic controller
  12453. */
  12454. static GENERIC: number;
  12455. /**
  12456. * Represents an XBox controller
  12457. */
  12458. static XBOX: number;
  12459. /**
  12460. * Represents a pose-enabled controller
  12461. */
  12462. static POSE_ENABLED: number;
  12463. /**
  12464. * Specifies whether the left control stick should be Y-inverted
  12465. */
  12466. protected _invertLeftStickY: boolean;
  12467. /**
  12468. * Specifies if the gamepad has been connected
  12469. */
  12470. readonly isConnected: boolean;
  12471. /**
  12472. * Initializes the gamepad
  12473. * @param id The id of the gamepad
  12474. * @param index The index of the gamepad
  12475. * @param browserGamepad The browser gamepad
  12476. * @param leftStickX The x component of the left joystick
  12477. * @param leftStickY The y component of the left joystick
  12478. * @param rightStickX The x component of the right joystick
  12479. * @param rightStickY The y component of the right joystick
  12480. */
  12481. constructor(
  12482. /**
  12483. * The id of the gamepad
  12484. */
  12485. id: string,
  12486. /**
  12487. * The index of the gamepad
  12488. */
  12489. index: number,
  12490. /**
  12491. * The browser gamepad
  12492. */
  12493. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12494. /**
  12495. * Callback triggered when the left joystick has changed
  12496. * @param callback
  12497. */
  12498. onleftstickchanged(callback: (values: StickValues) => void): void;
  12499. /**
  12500. * Callback triggered when the right joystick has changed
  12501. * @param callback
  12502. */
  12503. onrightstickchanged(callback: (values: StickValues) => void): void;
  12504. /**
  12505. * Gets the left joystick
  12506. */
  12507. /**
  12508. * Sets the left joystick values
  12509. */
  12510. leftStick: StickValues;
  12511. /**
  12512. * Gets the right joystick
  12513. */
  12514. /**
  12515. * Sets the right joystick value
  12516. */
  12517. rightStick: StickValues;
  12518. /**
  12519. * Updates the gamepad joystick positions
  12520. */
  12521. update(): void;
  12522. /**
  12523. * Disposes the gamepad
  12524. */
  12525. dispose(): void;
  12526. }
  12527. /**
  12528. * Represents a generic gamepad
  12529. */
  12530. export class GenericPad extends Gamepad {
  12531. private _buttons;
  12532. private _onbuttondown;
  12533. private _onbuttonup;
  12534. /**
  12535. * Observable triggered when a button has been pressed
  12536. */
  12537. onButtonDownObservable: Observable<number>;
  12538. /**
  12539. * Observable triggered when a button has been released
  12540. */
  12541. onButtonUpObservable: Observable<number>;
  12542. /**
  12543. * Callback triggered when a button has been pressed
  12544. * @param callback Called when a button has been pressed
  12545. */
  12546. onbuttondown(callback: (buttonPressed: number) => void): void;
  12547. /**
  12548. * Callback triggered when a button has been released
  12549. * @param callback Called when a button has been released
  12550. */
  12551. onbuttonup(callback: (buttonReleased: number) => void): void;
  12552. /**
  12553. * Initializes the generic gamepad
  12554. * @param id The id of the generic gamepad
  12555. * @param index The index of the generic gamepad
  12556. * @param browserGamepad The browser gamepad
  12557. */
  12558. constructor(id: string, index: number, browserGamepad: any);
  12559. private _setButtonValue;
  12560. /**
  12561. * Updates the generic gamepad
  12562. */
  12563. update(): void;
  12564. /**
  12565. * Disposes the generic gamepad
  12566. */
  12567. dispose(): void;
  12568. }
  12569. }
  12570. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12571. import { Observable } from "babylonjs/Misc/observable";
  12572. import { Nullable } from "babylonjs/types";
  12573. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12574. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12576. import { Ray } from "babylonjs/Culling/ray";
  12577. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12578. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12579. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12580. /**
  12581. * Defines the types of pose enabled controllers that are supported
  12582. */
  12583. export enum PoseEnabledControllerType {
  12584. /**
  12585. * HTC Vive
  12586. */
  12587. VIVE = 0,
  12588. /**
  12589. * Oculus Rift
  12590. */
  12591. OCULUS = 1,
  12592. /**
  12593. * Windows mixed reality
  12594. */
  12595. WINDOWS = 2,
  12596. /**
  12597. * Samsung gear VR
  12598. */
  12599. GEAR_VR = 3,
  12600. /**
  12601. * Google Daydream
  12602. */
  12603. DAYDREAM = 4,
  12604. /**
  12605. * Generic
  12606. */
  12607. GENERIC = 5
  12608. }
  12609. /**
  12610. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12611. */
  12612. export interface MutableGamepadButton {
  12613. /**
  12614. * Value of the button/trigger
  12615. */
  12616. value: number;
  12617. /**
  12618. * If the button/trigger is currently touched
  12619. */
  12620. touched: boolean;
  12621. /**
  12622. * If the button/trigger is currently pressed
  12623. */
  12624. pressed: boolean;
  12625. }
  12626. /**
  12627. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12628. * @hidden
  12629. */
  12630. export interface ExtendedGamepadButton extends GamepadButton {
  12631. /**
  12632. * If the button/trigger is currently pressed
  12633. */
  12634. readonly pressed: boolean;
  12635. /**
  12636. * If the button/trigger is currently touched
  12637. */
  12638. readonly touched: boolean;
  12639. /**
  12640. * Value of the button/trigger
  12641. */
  12642. readonly value: number;
  12643. }
  12644. /** @hidden */
  12645. export interface _GamePadFactory {
  12646. /**
  12647. * Returns wether or not the current gamepad can be created for this type of controller.
  12648. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12649. * @returns true if it can be created, otherwise false
  12650. */
  12651. canCreate(gamepadInfo: any): boolean;
  12652. /**
  12653. * Creates a new instance of the Gamepad.
  12654. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12655. * @returns the new gamepad instance
  12656. */
  12657. create(gamepadInfo: any): Gamepad;
  12658. }
  12659. /**
  12660. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12661. */
  12662. export class PoseEnabledControllerHelper {
  12663. /** @hidden */
  12664. static _ControllerFactories: _GamePadFactory[];
  12665. /** @hidden */
  12666. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12667. /**
  12668. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12669. * @param vrGamepad the gamepad to initialized
  12670. * @returns a vr controller of the type the gamepad identified as
  12671. */
  12672. static InitiateController(vrGamepad: any): Gamepad;
  12673. }
  12674. /**
  12675. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12676. */
  12677. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12678. private _deviceRoomPosition;
  12679. private _deviceRoomRotationQuaternion;
  12680. /**
  12681. * The device position in babylon space
  12682. */
  12683. devicePosition: Vector3;
  12684. /**
  12685. * The device rotation in babylon space
  12686. */
  12687. deviceRotationQuaternion: Quaternion;
  12688. /**
  12689. * The scale factor of the device in babylon space
  12690. */
  12691. deviceScaleFactor: number;
  12692. /**
  12693. * (Likely devicePosition should be used instead) The device position in its room space
  12694. */
  12695. position: Vector3;
  12696. /**
  12697. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12698. */
  12699. rotationQuaternion: Quaternion;
  12700. /**
  12701. * The type of controller (Eg. Windows mixed reality)
  12702. */
  12703. controllerType: PoseEnabledControllerType;
  12704. protected _calculatedPosition: Vector3;
  12705. private _calculatedRotation;
  12706. /**
  12707. * The raw pose from the device
  12708. */
  12709. rawPose: DevicePose;
  12710. private _trackPosition;
  12711. private _maxRotationDistFromHeadset;
  12712. private _draggedRoomRotation;
  12713. /**
  12714. * @hidden
  12715. */
  12716. _disableTrackPosition(fixedPosition: Vector3): void;
  12717. /**
  12718. * Internal, the mesh attached to the controller
  12719. * @hidden
  12720. */
  12721. _mesh: Nullable<AbstractMesh>;
  12722. private _poseControlledCamera;
  12723. private _leftHandSystemQuaternion;
  12724. /**
  12725. * Internal, matrix used to convert room space to babylon space
  12726. * @hidden
  12727. */
  12728. _deviceToWorld: Matrix;
  12729. /**
  12730. * Node to be used when casting a ray from the controller
  12731. * @hidden
  12732. */
  12733. _pointingPoseNode: Nullable<TransformNode>;
  12734. /**
  12735. * Name of the child mesh that can be used to cast a ray from the controller
  12736. */
  12737. static readonly POINTING_POSE: string;
  12738. /**
  12739. * Creates a new PoseEnabledController from a gamepad
  12740. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12741. */
  12742. constructor(browserGamepad: any);
  12743. private _workingMatrix;
  12744. /**
  12745. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12746. */
  12747. update(): void;
  12748. /**
  12749. * Updates only the pose device and mesh without doing any button event checking
  12750. */
  12751. protected _updatePoseAndMesh(): void;
  12752. /**
  12753. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12754. * @param poseData raw pose fromthe device
  12755. */
  12756. updateFromDevice(poseData: DevicePose): void;
  12757. /**
  12758. * @hidden
  12759. */
  12760. _meshAttachedObservable: Observable<AbstractMesh>;
  12761. /**
  12762. * Attaches a mesh to the controller
  12763. * @param mesh the mesh to be attached
  12764. */
  12765. attachToMesh(mesh: AbstractMesh): void;
  12766. /**
  12767. * Attaches the controllers mesh to a camera
  12768. * @param camera the camera the mesh should be attached to
  12769. */
  12770. attachToPoseControlledCamera(camera: TargetCamera): void;
  12771. /**
  12772. * Disposes of the controller
  12773. */
  12774. dispose(): void;
  12775. /**
  12776. * The mesh that is attached to the controller
  12777. */
  12778. readonly mesh: Nullable<AbstractMesh>;
  12779. /**
  12780. * Gets the ray of the controller in the direction the controller is pointing
  12781. * @param length the length the resulting ray should be
  12782. * @returns a ray in the direction the controller is pointing
  12783. */
  12784. getForwardRay(length?: number): Ray;
  12785. }
  12786. }
  12787. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12788. import { Observable } from "babylonjs/Misc/observable";
  12789. import { Scene } from "babylonjs/scene";
  12790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12791. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12792. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12793. /**
  12794. * Defines the WebVRController object that represents controllers tracked in 3D space
  12795. */
  12796. export abstract class WebVRController extends PoseEnabledController {
  12797. /**
  12798. * Internal, the default controller model for the controller
  12799. */
  12800. protected _defaultModel: AbstractMesh;
  12801. /**
  12802. * Fired when the trigger state has changed
  12803. */
  12804. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12805. /**
  12806. * Fired when the main button state has changed
  12807. */
  12808. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12809. /**
  12810. * Fired when the secondary button state has changed
  12811. */
  12812. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12813. /**
  12814. * Fired when the pad state has changed
  12815. */
  12816. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12817. /**
  12818. * Fired when controllers stick values have changed
  12819. */
  12820. onPadValuesChangedObservable: Observable<StickValues>;
  12821. /**
  12822. * Array of button availible on the controller
  12823. */
  12824. protected _buttons: Array<MutableGamepadButton>;
  12825. private _onButtonStateChange;
  12826. /**
  12827. * Fired when a controller button's state has changed
  12828. * @param callback the callback containing the button that was modified
  12829. */
  12830. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12831. /**
  12832. * X and Y axis corrisponding to the controllers joystick
  12833. */
  12834. pad: StickValues;
  12835. /**
  12836. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12837. */
  12838. hand: string;
  12839. /**
  12840. * The default controller model for the controller
  12841. */
  12842. readonly defaultModel: AbstractMesh;
  12843. /**
  12844. * Creates a new WebVRController from a gamepad
  12845. * @param vrGamepad the gamepad that the WebVRController should be created from
  12846. */
  12847. constructor(vrGamepad: any);
  12848. /**
  12849. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12850. */
  12851. update(): void;
  12852. /**
  12853. * Function to be called when a button is modified
  12854. */
  12855. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12856. /**
  12857. * Loads a mesh and attaches it to the controller
  12858. * @param scene the scene the mesh should be added to
  12859. * @param meshLoaded callback for when the mesh has been loaded
  12860. */
  12861. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12862. private _setButtonValue;
  12863. private _changes;
  12864. private _checkChanges;
  12865. /**
  12866. * Disposes of th webVRCOntroller
  12867. */
  12868. dispose(): void;
  12869. }
  12870. }
  12871. declare module "babylonjs/Lights/hemisphericLight" {
  12872. import { Nullable } from "babylonjs/types";
  12873. import { Scene } from "babylonjs/scene";
  12874. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12875. import { Effect } from "babylonjs/Materials/effect";
  12876. import { Light } from "babylonjs/Lights/light";
  12877. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12878. /**
  12879. * The HemisphericLight simulates the ambient environment light,
  12880. * so the passed direction is the light reflection direction, not the incoming direction.
  12881. */
  12882. export class HemisphericLight extends Light {
  12883. /**
  12884. * The groundColor is the light in the opposite direction to the one specified during creation.
  12885. * 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.
  12886. */
  12887. groundColor: Color3;
  12888. /**
  12889. * The light reflection direction, not the incoming direction.
  12890. */
  12891. direction: Vector3;
  12892. /**
  12893. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12894. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12895. * The HemisphericLight can't cast shadows.
  12896. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12897. * @param name The friendly name of the light
  12898. * @param direction The direction of the light reflection
  12899. * @param scene The scene the light belongs to
  12900. */
  12901. constructor(name: string, direction: Vector3, scene: Scene);
  12902. protected _buildUniformLayout(): void;
  12903. /**
  12904. * Returns the string "HemisphericLight".
  12905. * @return The class name
  12906. */
  12907. getClassName(): string;
  12908. /**
  12909. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12910. * Returns the updated direction.
  12911. * @param target The target the direction should point to
  12912. * @return The computed direction
  12913. */
  12914. setDirectionToTarget(target: Vector3): Vector3;
  12915. /**
  12916. * Returns the shadow generator associated to the light.
  12917. * @returns Always null for hemispheric lights because it does not support shadows.
  12918. */
  12919. getShadowGenerator(): Nullable<IShadowGenerator>;
  12920. /**
  12921. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12922. * @param effect The effect to update
  12923. * @param lightIndex The index of the light in the effect to update
  12924. * @returns The hemispheric light
  12925. */
  12926. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12927. /**
  12928. * Computes the world matrix of the node
  12929. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12930. * @param useWasUpdatedFlag defines a reserved property
  12931. * @returns the world matrix
  12932. */
  12933. computeWorldMatrix(): Matrix;
  12934. /**
  12935. * Returns the integer 3.
  12936. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12937. */
  12938. getTypeID(): number;
  12939. /**
  12940. * Prepares the list of defines specific to the light type.
  12941. * @param defines the list of defines
  12942. * @param lightIndex defines the index of the light for the effect
  12943. */
  12944. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12945. }
  12946. }
  12947. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  12948. declare module "babylonjs/Cameras/VR/webVRCamera" {
  12949. import { Nullable } from "babylonjs/types";
  12950. import { Observable } from "babylonjs/Misc/observable";
  12951. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12952. import { Scene } from "babylonjs/scene";
  12953. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12954. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  12955. import { Node } from "babylonjs/node";
  12956. import { Ray } from "babylonjs/Culling/ray";
  12957. import "babylonjs/Cameras/RigModes/webVRRigMode";
  12958. /**
  12959. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12960. * IMPORTANT!! The data is right-hand data.
  12961. * @export
  12962. * @interface DevicePose
  12963. */
  12964. export interface DevicePose {
  12965. /**
  12966. * The position of the device, values in array are [x,y,z].
  12967. */
  12968. readonly position: Nullable<Float32Array>;
  12969. /**
  12970. * The linearVelocity of the device, values in array are [x,y,z].
  12971. */
  12972. readonly linearVelocity: Nullable<Float32Array>;
  12973. /**
  12974. * The linearAcceleration of the device, values in array are [x,y,z].
  12975. */
  12976. readonly linearAcceleration: Nullable<Float32Array>;
  12977. /**
  12978. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12979. */
  12980. readonly orientation: Nullable<Float32Array>;
  12981. /**
  12982. * The angularVelocity of the device, values in array are [x,y,z].
  12983. */
  12984. readonly angularVelocity: Nullable<Float32Array>;
  12985. /**
  12986. * The angularAcceleration of the device, values in array are [x,y,z].
  12987. */
  12988. readonly angularAcceleration: Nullable<Float32Array>;
  12989. }
  12990. /**
  12991. * Interface representing a pose controlled object in Babylon.
  12992. * A pose controlled object has both regular pose values as well as pose values
  12993. * from an external device such as a VR head mounted display
  12994. */
  12995. export interface PoseControlled {
  12996. /**
  12997. * The position of the object in babylon space.
  12998. */
  12999. position: Vector3;
  13000. /**
  13001. * The rotation quaternion of the object in babylon space.
  13002. */
  13003. rotationQuaternion: Quaternion;
  13004. /**
  13005. * The position of the device in babylon space.
  13006. */
  13007. devicePosition?: Vector3;
  13008. /**
  13009. * The rotation quaternion of the device in babylon space.
  13010. */
  13011. deviceRotationQuaternion: Quaternion;
  13012. /**
  13013. * The raw pose coming from the device.
  13014. */
  13015. rawPose: Nullable<DevicePose>;
  13016. /**
  13017. * The scale of the device to be used when translating from device space to babylon space.
  13018. */
  13019. deviceScaleFactor: number;
  13020. /**
  13021. * Updates the poseControlled values based on the input device pose.
  13022. * @param poseData the pose data to update the object with
  13023. */
  13024. updateFromDevice(poseData: DevicePose): void;
  13025. }
  13026. /**
  13027. * Set of options to customize the webVRCamera
  13028. */
  13029. export interface WebVROptions {
  13030. /**
  13031. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13032. */
  13033. trackPosition?: boolean;
  13034. /**
  13035. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13036. */
  13037. positionScale?: number;
  13038. /**
  13039. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13040. */
  13041. displayName?: string;
  13042. /**
  13043. * Should the native controller meshes be initialized. (default: true)
  13044. */
  13045. controllerMeshes?: boolean;
  13046. /**
  13047. * Creating a default HemiLight only on controllers. (default: true)
  13048. */
  13049. defaultLightingOnControllers?: boolean;
  13050. /**
  13051. * If you don't want to use the default VR button of the helper. (default: false)
  13052. */
  13053. useCustomVRButton?: boolean;
  13054. /**
  13055. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13056. */
  13057. customVRButton?: HTMLButtonElement;
  13058. /**
  13059. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13060. */
  13061. rayLength?: number;
  13062. /**
  13063. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13064. */
  13065. defaultHeight?: number;
  13066. }
  13067. /**
  13068. * This represents a WebVR camera.
  13069. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13070. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13071. */
  13072. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13073. private webVROptions;
  13074. /**
  13075. * @hidden
  13076. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13077. */
  13078. _vrDevice: any;
  13079. /**
  13080. * The rawPose of the vrDevice.
  13081. */
  13082. rawPose: Nullable<DevicePose>;
  13083. private _onVREnabled;
  13084. private _specsVersion;
  13085. private _attached;
  13086. private _frameData;
  13087. protected _descendants: Array<Node>;
  13088. private _deviceRoomPosition;
  13089. /** @hidden */
  13090. _deviceRoomRotationQuaternion: Quaternion;
  13091. private _standingMatrix;
  13092. /**
  13093. * Represents device position in babylon space.
  13094. */
  13095. devicePosition: Vector3;
  13096. /**
  13097. * Represents device rotation in babylon space.
  13098. */
  13099. deviceRotationQuaternion: Quaternion;
  13100. /**
  13101. * The scale of the device to be used when translating from device space to babylon space.
  13102. */
  13103. deviceScaleFactor: number;
  13104. private _deviceToWorld;
  13105. private _worldToDevice;
  13106. /**
  13107. * References to the webVR controllers for the vrDevice.
  13108. */
  13109. controllers: Array<WebVRController>;
  13110. /**
  13111. * Emits an event when a controller is attached.
  13112. */
  13113. onControllersAttachedObservable: Observable<WebVRController[]>;
  13114. /**
  13115. * Emits an event when a controller's mesh has been loaded;
  13116. */
  13117. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13118. /**
  13119. * Emits an event when the HMD's pose has been updated.
  13120. */
  13121. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13122. private _poseSet;
  13123. /**
  13124. * If the rig cameras be used as parent instead of this camera.
  13125. */
  13126. rigParenting: boolean;
  13127. private _lightOnControllers;
  13128. private _defaultHeight?;
  13129. /**
  13130. * Instantiates a WebVRFreeCamera.
  13131. * @param name The name of the WebVRFreeCamera
  13132. * @param position The starting anchor position for the camera
  13133. * @param scene The scene the camera belongs to
  13134. * @param webVROptions a set of customizable options for the webVRCamera
  13135. */
  13136. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13137. /**
  13138. * Gets the device distance from the ground in meters.
  13139. * @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.
  13140. */
  13141. deviceDistanceToRoomGround(): number;
  13142. /**
  13143. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13144. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13145. */
  13146. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13147. /**
  13148. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13149. * @returns A promise with a boolean set to if the standing matrix is supported.
  13150. */
  13151. useStandingMatrixAsync(): Promise<boolean>;
  13152. /**
  13153. * Disposes the camera
  13154. */
  13155. dispose(): void;
  13156. /**
  13157. * Gets a vrController by name.
  13158. * @param name The name of the controller to retreive
  13159. * @returns the controller matching the name specified or null if not found
  13160. */
  13161. getControllerByName(name: string): Nullable<WebVRController>;
  13162. private _leftController;
  13163. /**
  13164. * The controller corrisponding to the users left hand.
  13165. */
  13166. readonly leftController: Nullable<WebVRController>;
  13167. private _rightController;
  13168. /**
  13169. * The controller corrisponding to the users right hand.
  13170. */
  13171. readonly rightController: Nullable<WebVRController>;
  13172. /**
  13173. * Casts a ray forward from the vrCamera's gaze.
  13174. * @param length Length of the ray (default: 100)
  13175. * @returns the ray corrisponding to the gaze
  13176. */
  13177. getForwardRay(length?: number): Ray;
  13178. /**
  13179. * @hidden
  13180. * Updates the camera based on device's frame data
  13181. */
  13182. _checkInputs(): void;
  13183. /**
  13184. * Updates the poseControlled values based on the input device pose.
  13185. * @param poseData Pose coming from the device
  13186. */
  13187. updateFromDevice(poseData: DevicePose): void;
  13188. private _htmlElementAttached;
  13189. private _detachIfAttached;
  13190. /**
  13191. * WebVR's attach control will start broadcasting frames to the device.
  13192. * Note that in certain browsers (chrome for example) this function must be called
  13193. * within a user-interaction callback. Example:
  13194. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13195. *
  13196. * @param element html element to attach the vrDevice to
  13197. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13198. */
  13199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13200. /**
  13201. * Detaches the camera from the html element and disables VR
  13202. *
  13203. * @param element html element to detach from
  13204. */
  13205. detachControl(element: HTMLElement): void;
  13206. /**
  13207. * @returns the name of this class
  13208. */
  13209. getClassName(): string;
  13210. /**
  13211. * Calls resetPose on the vrDisplay
  13212. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13213. */
  13214. resetToCurrentRotation(): void;
  13215. /**
  13216. * @hidden
  13217. * Updates the rig cameras (left and right eye)
  13218. */
  13219. _updateRigCameras(): void;
  13220. private _workingVector;
  13221. private _oneVector;
  13222. private _workingMatrix;
  13223. private updateCacheCalled;
  13224. private _correctPositionIfNotTrackPosition;
  13225. /**
  13226. * @hidden
  13227. * Updates the cached values of the camera
  13228. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13229. */
  13230. _updateCache(ignoreParentClass?: boolean): void;
  13231. /**
  13232. * @hidden
  13233. * Get current device position in babylon world
  13234. */
  13235. _computeDevicePosition(): void;
  13236. /**
  13237. * Updates the current device position and rotation in the babylon world
  13238. */
  13239. update(): void;
  13240. /**
  13241. * @hidden
  13242. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13243. * @returns an identity matrix
  13244. */
  13245. _getViewMatrix(): Matrix;
  13246. private _tmpMatrix;
  13247. /**
  13248. * This function is called by the two RIG cameras.
  13249. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13250. * @hidden
  13251. */
  13252. _getWebVRViewMatrix(): Matrix;
  13253. /** @hidden */
  13254. _getWebVRProjectionMatrix(): Matrix;
  13255. private _onGamepadConnectedObserver;
  13256. private _onGamepadDisconnectedObserver;
  13257. private _updateCacheWhenTrackingDisabledObserver;
  13258. /**
  13259. * Initializes the controllers and their meshes
  13260. */
  13261. initControllers(): void;
  13262. }
  13263. }
  13264. declare module "babylonjs/PostProcesses/postProcess" {
  13265. import { Nullable } from "babylonjs/types";
  13266. import { SmartArray } from "babylonjs/Misc/smartArray";
  13267. import { Observable } from "babylonjs/Misc/observable";
  13268. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13269. import { Camera } from "babylonjs/Cameras/camera";
  13270. import { Effect } from "babylonjs/Materials/effect";
  13271. import "babylonjs/Shaders/postprocess.vertex";
  13272. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13273. import { Engine } from "babylonjs/Engines/engine";
  13274. /**
  13275. * Size options for a post process
  13276. */
  13277. export type PostProcessOptions = {
  13278. width: number;
  13279. height: number;
  13280. };
  13281. /**
  13282. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13283. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13284. */
  13285. export class PostProcess {
  13286. /** Name of the PostProcess. */
  13287. name: string;
  13288. /**
  13289. * Gets or sets the unique id of the post process
  13290. */
  13291. uniqueId: number;
  13292. /**
  13293. * Width of the texture to apply the post process on
  13294. */
  13295. width: number;
  13296. /**
  13297. * Height of the texture to apply the post process on
  13298. */
  13299. height: number;
  13300. /**
  13301. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13302. * @hidden
  13303. */
  13304. _outputTexture: Nullable<InternalTexture>;
  13305. /**
  13306. * Sampling mode used by the shader
  13307. * See https://doc.babylonjs.com/classes/3.1/texture
  13308. */
  13309. renderTargetSamplingMode: number;
  13310. /**
  13311. * Clear color to use when screen clearing
  13312. */
  13313. clearColor: Color4;
  13314. /**
  13315. * If the buffer needs to be cleared before applying the post process. (default: true)
  13316. * Should be set to false if shader will overwrite all previous pixels.
  13317. */
  13318. autoClear: boolean;
  13319. /**
  13320. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13321. */
  13322. alphaMode: number;
  13323. /**
  13324. * Sets the setAlphaBlendConstants of the babylon engine
  13325. */
  13326. alphaConstants: Color4;
  13327. /**
  13328. * Animations to be used for the post processing
  13329. */
  13330. animations: import("babylonjs/Animations/animation").Animation[];
  13331. /**
  13332. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13333. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13334. */
  13335. enablePixelPerfectMode: boolean;
  13336. /**
  13337. * Force the postprocess to be applied without taking in account viewport
  13338. */
  13339. forceFullscreenViewport: boolean;
  13340. /**
  13341. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13342. *
  13343. * | Value | Type | Description |
  13344. * | ----- | ----------------------------------- | ----------- |
  13345. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13346. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13347. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13348. *
  13349. */
  13350. scaleMode: number;
  13351. /**
  13352. * Force textures to be a power of two (default: false)
  13353. */
  13354. alwaysForcePOT: boolean;
  13355. private _samples;
  13356. /**
  13357. * Number of sample textures (default: 1)
  13358. */
  13359. samples: number;
  13360. /**
  13361. * Modify the scale of the post process to be the same as the viewport (default: false)
  13362. */
  13363. adaptScaleToCurrentViewport: boolean;
  13364. private _camera;
  13365. private _scene;
  13366. private _engine;
  13367. private _options;
  13368. private _reusable;
  13369. private _textureType;
  13370. /**
  13371. * Smart array of input and output textures for the post process.
  13372. * @hidden
  13373. */
  13374. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13375. /**
  13376. * The index in _textures that corresponds to the output texture.
  13377. * @hidden
  13378. */
  13379. _currentRenderTextureInd: number;
  13380. private _effect;
  13381. private _samplers;
  13382. private _fragmentUrl;
  13383. private _vertexUrl;
  13384. private _parameters;
  13385. private _scaleRatio;
  13386. protected _indexParameters: any;
  13387. private _shareOutputWithPostProcess;
  13388. private _texelSize;
  13389. private _forcedOutputTexture;
  13390. /**
  13391. * Returns the fragment url or shader name used in the post process.
  13392. * @returns the fragment url or name in the shader store.
  13393. */
  13394. getEffectName(): string;
  13395. /**
  13396. * An event triggered when the postprocess is activated.
  13397. */
  13398. onActivateObservable: Observable<Camera>;
  13399. private _onActivateObserver;
  13400. /**
  13401. * A function that is added to the onActivateObservable
  13402. */
  13403. onActivate: Nullable<(camera: Camera) => void>;
  13404. /**
  13405. * An event triggered when the postprocess changes its size.
  13406. */
  13407. onSizeChangedObservable: Observable<PostProcess>;
  13408. private _onSizeChangedObserver;
  13409. /**
  13410. * A function that is added to the onSizeChangedObservable
  13411. */
  13412. onSizeChanged: (postProcess: PostProcess) => void;
  13413. /**
  13414. * An event triggered when the postprocess applies its effect.
  13415. */
  13416. onApplyObservable: Observable<Effect>;
  13417. private _onApplyObserver;
  13418. /**
  13419. * A function that is added to the onApplyObservable
  13420. */
  13421. onApply: (effect: Effect) => void;
  13422. /**
  13423. * An event triggered before rendering the postprocess
  13424. */
  13425. onBeforeRenderObservable: Observable<Effect>;
  13426. private _onBeforeRenderObserver;
  13427. /**
  13428. * A function that is added to the onBeforeRenderObservable
  13429. */
  13430. onBeforeRender: (effect: Effect) => void;
  13431. /**
  13432. * An event triggered after rendering the postprocess
  13433. */
  13434. onAfterRenderObservable: Observable<Effect>;
  13435. private _onAfterRenderObserver;
  13436. /**
  13437. * A function that is added to the onAfterRenderObservable
  13438. */
  13439. onAfterRender: (efect: Effect) => void;
  13440. /**
  13441. * 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
  13442. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13443. */
  13444. inputTexture: InternalTexture;
  13445. /**
  13446. * Gets the camera which post process is applied to.
  13447. * @returns The camera the post process is applied to.
  13448. */
  13449. getCamera(): Camera;
  13450. /**
  13451. * Gets the texel size of the postprocess.
  13452. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13453. */
  13454. readonly texelSize: Vector2;
  13455. /**
  13456. * Creates a new instance PostProcess
  13457. * @param name The name of the PostProcess.
  13458. * @param fragmentUrl The url of the fragment shader to be used.
  13459. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13460. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13461. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13462. * @param camera The camera to apply the render pass to.
  13463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13464. * @param engine The engine which the post process will be applied. (default: current engine)
  13465. * @param reusable If the post process can be reused on the same frame. (default: false)
  13466. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13467. * @param textureType Type of textures used when performing the post process. (default: 0)
  13468. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13469. * @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
  13470. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13471. */
  13472. constructor(
  13473. /** Name of the PostProcess. */
  13474. 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);
  13475. /**
  13476. * Gets a string idenfifying the name of the class
  13477. * @returns "PostProcess" string
  13478. */
  13479. getClassName(): string;
  13480. /**
  13481. * Gets the engine which this post process belongs to.
  13482. * @returns The engine the post process was enabled with.
  13483. */
  13484. getEngine(): Engine;
  13485. /**
  13486. * The effect that is created when initializing the post process.
  13487. * @returns The created effect corrisponding the the postprocess.
  13488. */
  13489. getEffect(): Effect;
  13490. /**
  13491. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13492. * @param postProcess The post process to share the output with.
  13493. * @returns This post process.
  13494. */
  13495. shareOutputWith(postProcess: PostProcess): PostProcess;
  13496. /**
  13497. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13498. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13499. */
  13500. useOwnOutput(): void;
  13501. /**
  13502. * Updates the effect with the current post process compile time values and recompiles the shader.
  13503. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13504. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13505. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13506. * @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
  13507. * @param onCompiled Called when the shader has been compiled.
  13508. * @param onError Called if there is an error when compiling a shader.
  13509. */
  13510. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13511. /**
  13512. * The post process is reusable if it can be used multiple times within one frame.
  13513. * @returns If the post process is reusable
  13514. */
  13515. isReusable(): boolean;
  13516. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13517. markTextureDirty(): void;
  13518. /**
  13519. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13520. * 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.
  13521. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13522. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13523. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13524. * @returns The target texture that was bound to be written to.
  13525. */
  13526. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13527. /**
  13528. * If the post process is supported.
  13529. */
  13530. readonly isSupported: boolean;
  13531. /**
  13532. * The aspect ratio of the output texture.
  13533. */
  13534. readonly aspectRatio: number;
  13535. /**
  13536. * Get a value indicating if the post-process is ready to be used
  13537. * @returns true if the post-process is ready (shader is compiled)
  13538. */
  13539. isReady(): boolean;
  13540. /**
  13541. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13542. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13543. */
  13544. apply(): Nullable<Effect>;
  13545. private _disposeTextures;
  13546. /**
  13547. * Disposes the post process.
  13548. * @param camera The camera to dispose the post process on.
  13549. */
  13550. dispose(camera?: Camera): void;
  13551. }
  13552. }
  13553. declare module "babylonjs/PostProcesses/postProcessManager" {
  13554. import { Nullable } from "babylonjs/types";
  13555. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13556. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13557. import { Scene } from "babylonjs/scene";
  13558. /**
  13559. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13560. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13561. */
  13562. export class PostProcessManager {
  13563. private _scene;
  13564. private _indexBuffer;
  13565. private _vertexBuffers;
  13566. /**
  13567. * Creates a new instance PostProcess
  13568. * @param scene The scene that the post process is associated with.
  13569. */
  13570. constructor(scene: Scene);
  13571. private _prepareBuffers;
  13572. private _buildIndexBuffer;
  13573. /**
  13574. * Rebuilds the vertex buffers of the manager.
  13575. * @hidden
  13576. */
  13577. _rebuild(): void;
  13578. /**
  13579. * Prepares a frame to be run through a post process.
  13580. * @param sourceTexture The input texture to the post procesess. (default: null)
  13581. * @param postProcesses An array of post processes to be run. (default: null)
  13582. * @returns True if the post processes were able to be run.
  13583. * @hidden
  13584. */
  13585. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13586. /**
  13587. * Manually render a set of post processes to a texture.
  13588. * @param postProcesses An array of post processes to be run.
  13589. * @param targetTexture The target texture to render to.
  13590. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13591. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13592. * @param lodLevel defines which lod of the texture to render to
  13593. */
  13594. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13595. /**
  13596. * Finalize the result of the output of the postprocesses.
  13597. * @param doNotPresent If true the result will not be displayed to the screen.
  13598. * @param targetTexture The target texture to render to.
  13599. * @param faceIndex The index of the face to bind the target texture to.
  13600. * @param postProcesses The array of post processes to render.
  13601. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13602. * @hidden
  13603. */
  13604. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13605. /**
  13606. * Disposes of the post process manager.
  13607. */
  13608. dispose(): void;
  13609. }
  13610. }
  13611. declare module "babylonjs/Layers/layerSceneComponent" {
  13612. import { Scene } from "babylonjs/scene";
  13613. import { ISceneComponent } from "babylonjs/sceneComponent";
  13614. import { Layer } from "babylonjs/Layers/layer";
  13615. module "babylonjs/abstractScene" {
  13616. interface AbstractScene {
  13617. /**
  13618. * The list of layers (background and foreground) of the scene
  13619. */
  13620. layers: Array<Layer>;
  13621. }
  13622. }
  13623. /**
  13624. * Defines the layer scene component responsible to manage any layers
  13625. * in a given scene.
  13626. */
  13627. export class LayerSceneComponent implements ISceneComponent {
  13628. /**
  13629. * The component name helpfull to identify the component in the list of scene components.
  13630. */
  13631. readonly name: string;
  13632. /**
  13633. * The scene the component belongs to.
  13634. */
  13635. scene: Scene;
  13636. private _engine;
  13637. /**
  13638. * Creates a new instance of the component for the given scene
  13639. * @param scene Defines the scene to register the component in
  13640. */
  13641. constructor(scene: Scene);
  13642. /**
  13643. * Registers the component in a given scene
  13644. */
  13645. register(): void;
  13646. /**
  13647. * Rebuilds the elements related to this component in case of
  13648. * context lost for instance.
  13649. */
  13650. rebuild(): void;
  13651. /**
  13652. * Disposes the component and the associated ressources.
  13653. */
  13654. dispose(): void;
  13655. private _draw;
  13656. private _drawCameraPredicate;
  13657. private _drawCameraBackground;
  13658. private _drawCameraForeground;
  13659. private _drawRenderTargetPredicate;
  13660. private _drawRenderTargetBackground;
  13661. private _drawRenderTargetForeground;
  13662. }
  13663. }
  13664. declare module "babylonjs/Shaders/layer.fragment" {
  13665. /** @hidden */
  13666. export var layerPixelShader: {
  13667. name: string;
  13668. shader: string;
  13669. };
  13670. }
  13671. declare module "babylonjs/Shaders/layer.vertex" {
  13672. /** @hidden */
  13673. export var layerVertexShader: {
  13674. name: string;
  13675. shader: string;
  13676. };
  13677. }
  13678. declare module "babylonjs/Layers/layer" {
  13679. import { Observable } from "babylonjs/Misc/observable";
  13680. import { Nullable } from "babylonjs/types";
  13681. import { Scene } from "babylonjs/scene";
  13682. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13683. import { Texture } from "babylonjs/Materials/Textures/texture";
  13684. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13685. import "babylonjs/Shaders/layer.fragment";
  13686. import "babylonjs/Shaders/layer.vertex";
  13687. /**
  13688. * This represents a full screen 2d layer.
  13689. * This can be useful to display a picture in the background of your scene for instance.
  13690. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13691. */
  13692. export class Layer {
  13693. /**
  13694. * Define the name of the layer.
  13695. */
  13696. name: string;
  13697. /**
  13698. * Define the texture the layer should display.
  13699. */
  13700. texture: Nullable<Texture>;
  13701. /**
  13702. * Is the layer in background or foreground.
  13703. */
  13704. isBackground: boolean;
  13705. /**
  13706. * Define the color of the layer (instead of texture).
  13707. */
  13708. color: Color4;
  13709. /**
  13710. * Define the scale of the layer in order to zoom in out of the texture.
  13711. */
  13712. scale: Vector2;
  13713. /**
  13714. * Define an offset for the layer in order to shift the texture.
  13715. */
  13716. offset: Vector2;
  13717. /**
  13718. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13719. */
  13720. alphaBlendingMode: number;
  13721. /**
  13722. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13723. * Alpha test will not mix with the background color in case of transparency.
  13724. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13725. */
  13726. alphaTest: boolean;
  13727. /**
  13728. * Define a mask to restrict the layer to only some of the scene cameras.
  13729. */
  13730. layerMask: number;
  13731. /**
  13732. * Define the list of render target the layer is visible into.
  13733. */
  13734. renderTargetTextures: RenderTargetTexture[];
  13735. /**
  13736. * Define if the layer is only used in renderTarget or if it also
  13737. * renders in the main frame buffer of the canvas.
  13738. */
  13739. renderOnlyInRenderTargetTextures: boolean;
  13740. private _scene;
  13741. private _vertexBuffers;
  13742. private _indexBuffer;
  13743. private _effect;
  13744. private _alphaTestEffect;
  13745. /**
  13746. * An event triggered when the layer is disposed.
  13747. */
  13748. onDisposeObservable: Observable<Layer>;
  13749. private _onDisposeObserver;
  13750. /**
  13751. * Back compatibility with callback before the onDisposeObservable existed.
  13752. * The set callback will be triggered when the layer has been disposed.
  13753. */
  13754. onDispose: () => void;
  13755. /**
  13756. * An event triggered before rendering the scene
  13757. */
  13758. onBeforeRenderObservable: Observable<Layer>;
  13759. private _onBeforeRenderObserver;
  13760. /**
  13761. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13762. * The set callback will be triggered just before rendering the layer.
  13763. */
  13764. onBeforeRender: () => void;
  13765. /**
  13766. * An event triggered after rendering the scene
  13767. */
  13768. onAfterRenderObservable: Observable<Layer>;
  13769. private _onAfterRenderObserver;
  13770. /**
  13771. * Back compatibility with callback before the onAfterRenderObservable existed.
  13772. * The set callback will be triggered just after rendering the layer.
  13773. */
  13774. onAfterRender: () => void;
  13775. /**
  13776. * Instantiates a new layer.
  13777. * This represents a full screen 2d layer.
  13778. * This can be useful to display a picture in the background of your scene for instance.
  13779. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13780. * @param name Define the name of the layer in the scene
  13781. * @param imgUrl Define the url of the texture to display in the layer
  13782. * @param scene Define the scene the layer belongs to
  13783. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13784. * @param color Defines a color for the layer
  13785. */
  13786. constructor(
  13787. /**
  13788. * Define the name of the layer.
  13789. */
  13790. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13791. private _createIndexBuffer;
  13792. /** @hidden */
  13793. _rebuild(): void;
  13794. /**
  13795. * Renders the layer in the scene.
  13796. */
  13797. render(): void;
  13798. /**
  13799. * Disposes and releases the associated ressources.
  13800. */
  13801. dispose(): void;
  13802. }
  13803. }
  13804. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13805. import { Scene } from "babylonjs/scene";
  13806. import { ISceneComponent } from "babylonjs/sceneComponent";
  13807. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13808. module "babylonjs/abstractScene" {
  13809. interface AbstractScene {
  13810. /**
  13811. * The list of procedural textures added to the scene
  13812. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13813. */
  13814. proceduralTextures: Array<ProceduralTexture>;
  13815. }
  13816. }
  13817. /**
  13818. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13819. * in a given scene.
  13820. */
  13821. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13822. /**
  13823. * The component name helpfull to identify the component in the list of scene components.
  13824. */
  13825. readonly name: string;
  13826. /**
  13827. * The scene the component belongs to.
  13828. */
  13829. scene: Scene;
  13830. /**
  13831. * Creates a new instance of the component for the given scene
  13832. * @param scene Defines the scene to register the component in
  13833. */
  13834. constructor(scene: Scene);
  13835. /**
  13836. * Registers the component in a given scene
  13837. */
  13838. register(): void;
  13839. /**
  13840. * Rebuilds the elements related to this component in case of
  13841. * context lost for instance.
  13842. */
  13843. rebuild(): void;
  13844. /**
  13845. * Disposes the component and the associated ressources.
  13846. */
  13847. dispose(): void;
  13848. private _beforeClear;
  13849. }
  13850. }
  13851. declare module "babylonjs/Shaders/procedural.vertex" {
  13852. /** @hidden */
  13853. export var proceduralVertexShader: {
  13854. name: string;
  13855. shader: string;
  13856. };
  13857. }
  13858. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13859. import { Observable } from "babylonjs/Misc/observable";
  13860. import { Nullable } from "babylonjs/types";
  13861. import { Scene } from "babylonjs/scene";
  13862. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13863. import { Effect } from "babylonjs/Materials/effect";
  13864. import { Texture } from "babylonjs/Materials/Textures/texture";
  13865. import "babylonjs/Shaders/procedural.vertex";
  13866. /**
  13867. * 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.
  13868. * This is the base class of any Procedural texture and contains most of the shareable code.
  13869. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13870. */
  13871. export class ProceduralTexture extends Texture {
  13872. isCube: boolean;
  13873. /**
  13874. * Define if the texture is enabled or not (disabled texture will not render)
  13875. */
  13876. isEnabled: boolean;
  13877. /**
  13878. * Define if the texture must be cleared before rendering (default is true)
  13879. */
  13880. autoClear: boolean;
  13881. /**
  13882. * Callback called when the texture is generated
  13883. */
  13884. onGenerated: () => void;
  13885. /**
  13886. * Event raised when the texture is generated
  13887. */
  13888. onGeneratedObservable: Observable<ProceduralTexture>;
  13889. /** @hidden */
  13890. _generateMipMaps: boolean;
  13891. /** @hidden **/
  13892. _effect: Effect;
  13893. /** @hidden */
  13894. _textures: {
  13895. [key: string]: Texture;
  13896. };
  13897. private _size;
  13898. private _currentRefreshId;
  13899. private _refreshRate;
  13900. private _vertexBuffers;
  13901. private _indexBuffer;
  13902. private _uniforms;
  13903. private _samplers;
  13904. private _fragment;
  13905. private _floats;
  13906. private _ints;
  13907. private _floatsArrays;
  13908. private _colors3;
  13909. private _colors4;
  13910. private _vectors2;
  13911. private _vectors3;
  13912. private _matrices;
  13913. private _fallbackTexture;
  13914. private _fallbackTextureUsed;
  13915. private _engine;
  13916. private _cachedDefines;
  13917. private _contentUpdateId;
  13918. private _contentData;
  13919. /**
  13920. * Instantiates a new procedural texture.
  13921. * 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.
  13922. * This is the base class of any Procedural texture and contains most of the shareable code.
  13923. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13924. * @param name Define the name of the texture
  13925. * @param size Define the size of the texture to create
  13926. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13927. * @param scene Define the scene the texture belongs to
  13928. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13929. * @param generateMipMaps Define if the texture should creates mip maps or not
  13930. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13931. */
  13932. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13933. /**
  13934. * The effect that is created when initializing the post process.
  13935. * @returns The created effect corrisponding the the postprocess.
  13936. */
  13937. getEffect(): Effect;
  13938. /**
  13939. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13940. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13941. */
  13942. getContent(): Nullable<ArrayBufferView>;
  13943. private _createIndexBuffer;
  13944. /** @hidden */
  13945. _rebuild(): void;
  13946. /**
  13947. * Resets the texture in order to recreate its associated resources.
  13948. * This can be called in case of context loss
  13949. */
  13950. reset(): void;
  13951. protected _getDefines(): string;
  13952. /**
  13953. * Is the texture ready to be used ? (rendered at least once)
  13954. * @returns true if ready, otherwise, false.
  13955. */
  13956. isReady(): boolean;
  13957. /**
  13958. * Resets the refresh counter of the texture and start bak from scratch.
  13959. * Could be useful to regenerate the texture if it is setup to render only once.
  13960. */
  13961. resetRefreshCounter(): void;
  13962. /**
  13963. * Set the fragment shader to use in order to render the texture.
  13964. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13965. */
  13966. setFragment(fragment: any): void;
  13967. /**
  13968. * Define the refresh rate of the texture or the rendering frequency.
  13969. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13970. */
  13971. refreshRate: number;
  13972. /** @hidden */
  13973. _shouldRender(): boolean;
  13974. /**
  13975. * Get the size the texture is rendering at.
  13976. * @returns the size (texture is always squared)
  13977. */
  13978. getRenderSize(): number;
  13979. /**
  13980. * Resize the texture to new value.
  13981. * @param size Define the new size the texture should have
  13982. * @param generateMipMaps Define whether the new texture should create mip maps
  13983. */
  13984. resize(size: number, generateMipMaps: boolean): void;
  13985. private _checkUniform;
  13986. /**
  13987. * Set a texture in the shader program used to render.
  13988. * @param name Define the name of the uniform samplers as defined in the shader
  13989. * @param texture Define the texture to bind to this sampler
  13990. * @return the texture itself allowing "fluent" like uniform updates
  13991. */
  13992. setTexture(name: string, texture: Texture): ProceduralTexture;
  13993. /**
  13994. * Set a float in the shader.
  13995. * @param name Define the name of the uniform as defined in the shader
  13996. * @param value Define the value to give to the uniform
  13997. * @return the texture itself allowing "fluent" like uniform updates
  13998. */
  13999. setFloat(name: string, value: number): ProceduralTexture;
  14000. /**
  14001. * Set a int in the shader.
  14002. * @param name Define the name of the uniform as defined in the shader
  14003. * @param value Define the value to give to the uniform
  14004. * @return the texture itself allowing "fluent" like uniform updates
  14005. */
  14006. setInt(name: string, value: number): ProceduralTexture;
  14007. /**
  14008. * Set an array of floats in the shader.
  14009. * @param name Define the name of the uniform as defined in the shader
  14010. * @param value Define the value to give to the uniform
  14011. * @return the texture itself allowing "fluent" like uniform updates
  14012. */
  14013. setFloats(name: string, value: number[]): ProceduralTexture;
  14014. /**
  14015. * Set a vec3 in the shader from a Color3.
  14016. * @param name Define the name of the uniform as defined in the shader
  14017. * @param value Define the value to give to the uniform
  14018. * @return the texture itself allowing "fluent" like uniform updates
  14019. */
  14020. setColor3(name: string, value: Color3): ProceduralTexture;
  14021. /**
  14022. * Set a vec4 in the shader from a Color4.
  14023. * @param name Define the name of the uniform as defined in the shader
  14024. * @param value Define the value to give to the uniform
  14025. * @return the texture itself allowing "fluent" like uniform updates
  14026. */
  14027. setColor4(name: string, value: Color4): ProceduralTexture;
  14028. /**
  14029. * Set a vec2 in the shader from a Vector2.
  14030. * @param name Define the name of the uniform as defined in the shader
  14031. * @param value Define the value to give to the uniform
  14032. * @return the texture itself allowing "fluent" like uniform updates
  14033. */
  14034. setVector2(name: string, value: Vector2): ProceduralTexture;
  14035. /**
  14036. * Set a vec3 in the shader from a Vector3.
  14037. * @param name Define the name of the uniform as defined in the shader
  14038. * @param value Define the value to give to the uniform
  14039. * @return the texture itself allowing "fluent" like uniform updates
  14040. */
  14041. setVector3(name: string, value: Vector3): ProceduralTexture;
  14042. /**
  14043. * Set a mat4 in the shader from a MAtrix.
  14044. * @param name Define the name of the uniform as defined in the shader
  14045. * @param value Define the value to give to the uniform
  14046. * @return the texture itself allowing "fluent" like uniform updates
  14047. */
  14048. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14049. /**
  14050. * Render the texture to its associated render target.
  14051. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14052. */
  14053. render(useCameraPostProcess?: boolean): void;
  14054. /**
  14055. * Clone the texture.
  14056. * @returns the cloned texture
  14057. */
  14058. clone(): ProceduralTexture;
  14059. /**
  14060. * Dispose the texture and release its asoociated resources.
  14061. */
  14062. dispose(): void;
  14063. }
  14064. }
  14065. declare module "babylonjs/Particles/baseParticleSystem" {
  14066. import { Nullable } from "babylonjs/types";
  14067. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14069. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14070. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14071. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14072. import { Scene } from "babylonjs/scene";
  14073. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14074. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14075. import { Texture } from "babylonjs/Materials/Textures/texture";
  14076. import { Animation } from "babylonjs/Animations/animation";
  14077. /**
  14078. * This represents the base class for particle system in Babylon.
  14079. * 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.
  14080. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14081. * @example https://doc.babylonjs.com/babylon101/particles
  14082. */
  14083. export class BaseParticleSystem {
  14084. /**
  14085. * Source color is added to the destination color without alpha affecting the result
  14086. */
  14087. static BLENDMODE_ONEONE: number;
  14088. /**
  14089. * Blend current color and particle color using particle’s alpha
  14090. */
  14091. static BLENDMODE_STANDARD: number;
  14092. /**
  14093. * Add current color and particle color multiplied by particle’s alpha
  14094. */
  14095. static BLENDMODE_ADD: number;
  14096. /**
  14097. * Multiply current color with particle color
  14098. */
  14099. static BLENDMODE_MULTIPLY: number;
  14100. /**
  14101. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14102. */
  14103. static BLENDMODE_MULTIPLYADD: number;
  14104. /**
  14105. * List of animations used by the particle system.
  14106. */
  14107. animations: Animation[];
  14108. /**
  14109. * The id of the Particle system.
  14110. */
  14111. id: string;
  14112. /**
  14113. * The friendly name of the Particle system.
  14114. */
  14115. name: string;
  14116. /**
  14117. * The rendering group used by the Particle system to chose when to render.
  14118. */
  14119. renderingGroupId: number;
  14120. /**
  14121. * The emitter represents the Mesh or position we are attaching the particle system to.
  14122. */
  14123. emitter: Nullable<AbstractMesh | Vector3>;
  14124. /**
  14125. * The maximum number of particles to emit per frame
  14126. */
  14127. emitRate: number;
  14128. /**
  14129. * If you want to launch only a few particles at once, that can be done, as well.
  14130. */
  14131. manualEmitCount: number;
  14132. /**
  14133. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14134. */
  14135. updateSpeed: number;
  14136. /**
  14137. * The amount of time the particle system is running (depends of the overall update speed).
  14138. */
  14139. targetStopDuration: number;
  14140. /**
  14141. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14142. */
  14143. disposeOnStop: boolean;
  14144. /**
  14145. * Minimum power of emitting particles.
  14146. */
  14147. minEmitPower: number;
  14148. /**
  14149. * Maximum power of emitting particles.
  14150. */
  14151. maxEmitPower: number;
  14152. /**
  14153. * Minimum life time of emitting particles.
  14154. */
  14155. minLifeTime: number;
  14156. /**
  14157. * Maximum life time of emitting particles.
  14158. */
  14159. maxLifeTime: number;
  14160. /**
  14161. * Minimum Size of emitting particles.
  14162. */
  14163. minSize: number;
  14164. /**
  14165. * Maximum Size of emitting particles.
  14166. */
  14167. maxSize: number;
  14168. /**
  14169. * Minimum scale of emitting particles on X axis.
  14170. */
  14171. minScaleX: number;
  14172. /**
  14173. * Maximum scale of emitting particles on X axis.
  14174. */
  14175. maxScaleX: number;
  14176. /**
  14177. * Minimum scale of emitting particles on Y axis.
  14178. */
  14179. minScaleY: number;
  14180. /**
  14181. * Maximum scale of emitting particles on Y axis.
  14182. */
  14183. maxScaleY: number;
  14184. /**
  14185. * Gets or sets the minimal initial rotation in radians.
  14186. */
  14187. minInitialRotation: number;
  14188. /**
  14189. * Gets or sets the maximal initial rotation in radians.
  14190. */
  14191. maxInitialRotation: number;
  14192. /**
  14193. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14194. */
  14195. minAngularSpeed: number;
  14196. /**
  14197. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14198. */
  14199. maxAngularSpeed: number;
  14200. /**
  14201. * The texture used to render each particle. (this can be a spritesheet)
  14202. */
  14203. particleTexture: Nullable<Texture>;
  14204. /**
  14205. * The layer mask we are rendering the particles through.
  14206. */
  14207. layerMask: number;
  14208. /**
  14209. * This can help using your own shader to render the particle system.
  14210. * The according effect will be created
  14211. */
  14212. customShader: any;
  14213. /**
  14214. * By default particle system starts as soon as they are created. This prevents the
  14215. * automatic start to happen and let you decide when to start emitting particles.
  14216. */
  14217. preventAutoStart: boolean;
  14218. private _noiseTexture;
  14219. /**
  14220. * Gets or sets a texture used to add random noise to particle positions
  14221. */
  14222. noiseTexture: Nullable<ProceduralTexture>;
  14223. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14224. noiseStrength: Vector3;
  14225. /**
  14226. * Callback triggered when the particle animation is ending.
  14227. */
  14228. onAnimationEnd: Nullable<() => void>;
  14229. /**
  14230. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14231. */
  14232. blendMode: number;
  14233. /**
  14234. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14235. * to override the particles.
  14236. */
  14237. forceDepthWrite: boolean;
  14238. /** 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 */
  14239. preWarmCycles: number;
  14240. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14241. preWarmStepOffset: number;
  14242. /**
  14243. * 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)
  14244. */
  14245. spriteCellChangeSpeed: number;
  14246. /**
  14247. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14248. */
  14249. startSpriteCellID: number;
  14250. /**
  14251. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14252. */
  14253. endSpriteCellID: number;
  14254. /**
  14255. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14256. */
  14257. spriteCellWidth: number;
  14258. /**
  14259. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14260. */
  14261. spriteCellHeight: number;
  14262. /**
  14263. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14264. */
  14265. spriteRandomStartCell: boolean;
  14266. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14267. translationPivot: Vector2;
  14268. /** @hidden */
  14269. protected _isAnimationSheetEnabled: boolean;
  14270. /**
  14271. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14272. */
  14273. beginAnimationOnStart: boolean;
  14274. /**
  14275. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14276. */
  14277. beginAnimationFrom: number;
  14278. /**
  14279. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14280. */
  14281. beginAnimationTo: number;
  14282. /**
  14283. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14284. */
  14285. beginAnimationLoop: boolean;
  14286. /**
  14287. * Gets or sets a world offset applied to all particles
  14288. */
  14289. worldOffset: Vector3;
  14290. /**
  14291. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14292. */
  14293. isAnimationSheetEnabled: boolean;
  14294. /**
  14295. * Get hosting scene
  14296. * @returns the scene
  14297. */
  14298. getScene(): Scene;
  14299. /**
  14300. * You can use gravity if you want to give an orientation to your particles.
  14301. */
  14302. gravity: Vector3;
  14303. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14304. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14305. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14306. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14307. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14308. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14309. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14310. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14311. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14312. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14313. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14314. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14315. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14316. /**
  14317. * Defines the delay in milliseconds before starting the system (0 by default)
  14318. */
  14319. startDelay: number;
  14320. /**
  14321. * Gets the current list of drag gradients.
  14322. * You must use addDragGradient and removeDragGradient to udpate this list
  14323. * @returns the list of drag gradients
  14324. */
  14325. getDragGradients(): Nullable<Array<FactorGradient>>;
  14326. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14327. limitVelocityDamping: number;
  14328. /**
  14329. * Gets the current list of limit velocity gradients.
  14330. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14331. * @returns the list of limit velocity gradients
  14332. */
  14333. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14334. /**
  14335. * Gets the current list of color gradients.
  14336. * You must use addColorGradient and removeColorGradient to udpate this list
  14337. * @returns the list of color gradients
  14338. */
  14339. getColorGradients(): Nullable<Array<ColorGradient>>;
  14340. /**
  14341. * Gets the current list of size gradients.
  14342. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14343. * @returns the list of size gradients
  14344. */
  14345. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14346. /**
  14347. * Gets the current list of color remap gradients.
  14348. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14349. * @returns the list of color remap gradients
  14350. */
  14351. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14352. /**
  14353. * Gets the current list of alpha remap gradients.
  14354. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14355. * @returns the list of alpha remap gradients
  14356. */
  14357. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14358. /**
  14359. * Gets the current list of life time gradients.
  14360. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14361. * @returns the list of life time gradients
  14362. */
  14363. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14364. /**
  14365. * Gets the current list of angular speed gradients.
  14366. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14367. * @returns the list of angular speed gradients
  14368. */
  14369. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14370. /**
  14371. * Gets the current list of velocity gradients.
  14372. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14373. * @returns the list of velocity gradients
  14374. */
  14375. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14376. /**
  14377. * Gets the current list of start size gradients.
  14378. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14379. * @returns the list of start size gradients
  14380. */
  14381. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14382. /**
  14383. * Gets the current list of emit rate gradients.
  14384. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14385. * @returns the list of emit rate gradients
  14386. */
  14387. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14388. /**
  14389. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14390. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14391. */
  14392. direction1: Vector3;
  14393. /**
  14394. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14395. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14396. */
  14397. direction2: Vector3;
  14398. /**
  14399. * 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.
  14400. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14401. */
  14402. minEmitBox: Vector3;
  14403. /**
  14404. * 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.
  14405. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14406. */
  14407. maxEmitBox: Vector3;
  14408. /**
  14409. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14410. */
  14411. color1: Color4;
  14412. /**
  14413. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14414. */
  14415. color2: Color4;
  14416. /**
  14417. * Color the particle will have at the end of its lifetime
  14418. */
  14419. colorDead: Color4;
  14420. /**
  14421. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14422. */
  14423. textureMask: Color4;
  14424. /**
  14425. * The particle emitter type defines the emitter used by the particle system.
  14426. * It can be for example box, sphere, or cone...
  14427. */
  14428. particleEmitterType: IParticleEmitterType;
  14429. /** @hidden */
  14430. _isSubEmitter: boolean;
  14431. /**
  14432. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14433. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14434. */
  14435. billboardMode: number;
  14436. protected _isBillboardBased: boolean;
  14437. /**
  14438. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14439. */
  14440. isBillboardBased: boolean;
  14441. /**
  14442. * The scene the particle system belongs to.
  14443. */
  14444. protected _scene: Scene;
  14445. /**
  14446. * Local cache of defines for image processing.
  14447. */
  14448. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14449. /**
  14450. * Default configuration related to image processing available in the standard Material.
  14451. */
  14452. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14453. /**
  14454. * Gets the image processing configuration used either in this material.
  14455. */
  14456. /**
  14457. * Sets the Default image processing configuration used either in the this material.
  14458. *
  14459. * If sets to null, the scene one is in use.
  14460. */
  14461. imageProcessingConfiguration: ImageProcessingConfiguration;
  14462. /**
  14463. * Attaches a new image processing configuration to the Standard Material.
  14464. * @param configuration
  14465. */
  14466. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14467. /** @hidden */
  14468. protected _reset(): void;
  14469. /** @hidden */
  14470. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14471. /**
  14472. * Instantiates a particle system.
  14473. * 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.
  14474. * @param name The name of the particle system
  14475. */
  14476. constructor(name: string);
  14477. /**
  14478. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14479. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14480. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14481. * @returns the emitter
  14482. */
  14483. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14484. /**
  14485. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14486. * @param radius The radius of the hemisphere to emit from
  14487. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14488. * @returns the emitter
  14489. */
  14490. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14491. /**
  14492. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14493. * @param radius The radius of the sphere to emit from
  14494. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14495. * @returns the emitter
  14496. */
  14497. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14498. /**
  14499. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14500. * @param radius The radius of the sphere to emit from
  14501. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14502. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14503. * @returns the emitter
  14504. */
  14505. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14506. /**
  14507. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14508. * @param radius The radius of the emission cylinder
  14509. * @param height The height of the emission cylinder
  14510. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14511. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14512. * @returns the emitter
  14513. */
  14514. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14515. /**
  14516. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14517. * @param radius The radius of the cylinder to emit from
  14518. * @param height The height of the emission cylinder
  14519. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14520. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14521. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14522. * @returns the emitter
  14523. */
  14524. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14525. /**
  14526. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14527. * @param radius The radius of the cone to emit from
  14528. * @param angle The base angle of the cone
  14529. * @returns the emitter
  14530. */
  14531. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14532. /**
  14533. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14534. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14535. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14536. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14537. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14538. * @returns the emitter
  14539. */
  14540. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14541. }
  14542. }
  14543. declare module "babylonjs/Particles/subEmitter" {
  14544. import { Scene } from "babylonjs/scene";
  14545. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14546. /**
  14547. * Type of sub emitter
  14548. */
  14549. export enum SubEmitterType {
  14550. /**
  14551. * Attached to the particle over it's lifetime
  14552. */
  14553. ATTACHED = 0,
  14554. /**
  14555. * Created when the particle dies
  14556. */
  14557. END = 1
  14558. }
  14559. /**
  14560. * Sub emitter class used to emit particles from an existing particle
  14561. */
  14562. export class SubEmitter {
  14563. /**
  14564. * the particle system to be used by the sub emitter
  14565. */
  14566. particleSystem: ParticleSystem;
  14567. /**
  14568. * Type of the submitter (Default: END)
  14569. */
  14570. type: SubEmitterType;
  14571. /**
  14572. * 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)
  14573. * Note: This only is supported when using an emitter of type Mesh
  14574. */
  14575. inheritDirection: boolean;
  14576. /**
  14577. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14578. */
  14579. inheritedVelocityAmount: number;
  14580. /**
  14581. * Creates a sub emitter
  14582. * @param particleSystem the particle system to be used by the sub emitter
  14583. */
  14584. constructor(
  14585. /**
  14586. * the particle system to be used by the sub emitter
  14587. */
  14588. particleSystem: ParticleSystem);
  14589. /**
  14590. * Clones the sub emitter
  14591. * @returns the cloned sub emitter
  14592. */
  14593. clone(): SubEmitter;
  14594. /**
  14595. * Serialize current object to a JSON object
  14596. * @returns the serialized object
  14597. */
  14598. serialize(): any;
  14599. /** @hidden */
  14600. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14601. /**
  14602. * Creates a new SubEmitter from a serialized JSON version
  14603. * @param serializationObject defines the JSON object to read from
  14604. * @param scene defines the hosting scene
  14605. * @param rootUrl defines the rootUrl for data loading
  14606. * @returns a new SubEmitter
  14607. */
  14608. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14609. /** Release associated resources */
  14610. dispose(): void;
  14611. }
  14612. }
  14613. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14614. /** @hidden */
  14615. export var clipPlaneFragmentDeclaration: {
  14616. name: string;
  14617. shader: string;
  14618. };
  14619. }
  14620. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14621. /** @hidden */
  14622. export var imageProcessingDeclaration: {
  14623. name: string;
  14624. shader: string;
  14625. };
  14626. }
  14627. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14628. /** @hidden */
  14629. export var imageProcessingFunctions: {
  14630. name: string;
  14631. shader: string;
  14632. };
  14633. }
  14634. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14635. /** @hidden */
  14636. export var clipPlaneFragment: {
  14637. name: string;
  14638. shader: string;
  14639. };
  14640. }
  14641. declare module "babylonjs/Shaders/particles.fragment" {
  14642. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14643. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14644. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14645. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14646. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14647. /** @hidden */
  14648. export var particlesPixelShader: {
  14649. name: string;
  14650. shader: string;
  14651. };
  14652. }
  14653. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14654. /** @hidden */
  14655. export var clipPlaneVertexDeclaration: {
  14656. name: string;
  14657. shader: string;
  14658. };
  14659. }
  14660. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14661. /** @hidden */
  14662. export var clipPlaneVertex: {
  14663. name: string;
  14664. shader: string;
  14665. };
  14666. }
  14667. declare module "babylonjs/Shaders/particles.vertex" {
  14668. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14669. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14670. /** @hidden */
  14671. export var particlesVertexShader: {
  14672. name: string;
  14673. shader: string;
  14674. };
  14675. }
  14676. declare module "babylonjs/Particles/particleSystem" {
  14677. import { Nullable } from "babylonjs/types";
  14678. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14679. import { Observable } from "babylonjs/Misc/observable";
  14680. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14681. import { Effect } from "babylonjs/Materials/effect";
  14682. import { Scene, IDisposable } from "babylonjs/scene";
  14683. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14684. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14685. import { Particle } from "babylonjs/Particles/particle";
  14686. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14687. import "babylonjs/Shaders/particles.fragment";
  14688. import "babylonjs/Shaders/particles.vertex";
  14689. /**
  14690. * This represents a particle system in Babylon.
  14691. * 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.
  14692. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14693. * @example https://doc.babylonjs.com/babylon101/particles
  14694. */
  14695. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14696. /**
  14697. * Billboard mode will only apply to Y axis
  14698. */
  14699. static readonly BILLBOARDMODE_Y: number;
  14700. /**
  14701. * Billboard mode will apply to all axes
  14702. */
  14703. static readonly BILLBOARDMODE_ALL: number;
  14704. /**
  14705. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14706. */
  14707. static readonly BILLBOARDMODE_STRETCHED: number;
  14708. /**
  14709. * This function can be defined to provide custom update for active particles.
  14710. * This function will be called instead of regular update (age, position, color, etc.).
  14711. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14712. */
  14713. updateFunction: (particles: Particle[]) => void;
  14714. private _emitterWorldMatrix;
  14715. /**
  14716. * This function can be defined to specify initial direction for every new particle.
  14717. * It by default use the emitterType defined function
  14718. */
  14719. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14720. /**
  14721. * This function can be defined to specify initial position for every new particle.
  14722. * It by default use the emitterType defined function
  14723. */
  14724. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14725. /**
  14726. * @hidden
  14727. */
  14728. _inheritedVelocityOffset: Vector3;
  14729. /**
  14730. * An event triggered when the system is disposed
  14731. */
  14732. onDisposeObservable: Observable<ParticleSystem>;
  14733. private _onDisposeObserver;
  14734. /**
  14735. * Sets a callback that will be triggered when the system is disposed
  14736. */
  14737. onDispose: () => void;
  14738. private _particles;
  14739. private _epsilon;
  14740. private _capacity;
  14741. private _stockParticles;
  14742. private _newPartsExcess;
  14743. private _vertexData;
  14744. private _vertexBuffer;
  14745. private _vertexBuffers;
  14746. private _spriteBuffer;
  14747. private _indexBuffer;
  14748. private _effect;
  14749. private _customEffect;
  14750. private _cachedDefines;
  14751. private _scaledColorStep;
  14752. private _colorDiff;
  14753. private _scaledDirection;
  14754. private _scaledGravity;
  14755. private _currentRenderId;
  14756. private _alive;
  14757. private _useInstancing;
  14758. private _started;
  14759. private _stopped;
  14760. private _actualFrame;
  14761. private _scaledUpdateSpeed;
  14762. private _vertexBufferSize;
  14763. /** @hidden */
  14764. _currentEmitRateGradient: Nullable<FactorGradient>;
  14765. /** @hidden */
  14766. _currentEmitRate1: number;
  14767. /** @hidden */
  14768. _currentEmitRate2: number;
  14769. /** @hidden */
  14770. _currentStartSizeGradient: Nullable<FactorGradient>;
  14771. /** @hidden */
  14772. _currentStartSize1: number;
  14773. /** @hidden */
  14774. _currentStartSize2: number;
  14775. private readonly _rawTextureWidth;
  14776. private _rampGradientsTexture;
  14777. private _useRampGradients;
  14778. /** Gets or sets a boolean indicating that ramp gradients must be used
  14779. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14780. */
  14781. useRampGradients: boolean;
  14782. /**
  14783. * 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.
  14784. * 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: [])
  14785. */
  14786. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14787. private _subEmitters;
  14788. /**
  14789. * @hidden
  14790. * If the particle systems emitter should be disposed when the particle system is disposed
  14791. */
  14792. _disposeEmitterOnDispose: boolean;
  14793. /**
  14794. * The current active Sub-systems, this property is used by the root particle system only.
  14795. */
  14796. activeSubSystems: Array<ParticleSystem>;
  14797. private _rootParticleSystem;
  14798. /**
  14799. * Gets the current list of active particles
  14800. */
  14801. readonly particles: Particle[];
  14802. /**
  14803. * Returns the string "ParticleSystem"
  14804. * @returns a string containing the class name
  14805. */
  14806. getClassName(): string;
  14807. /**
  14808. * Instantiates a particle system.
  14809. * 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.
  14810. * @param name The name of the particle system
  14811. * @param capacity The max number of particles alive at the same time
  14812. * @param scene The scene the particle system belongs to
  14813. * @param customEffect a custom effect used to change the way particles are rendered by default
  14814. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14815. * @param epsilon Offset used to render the particles
  14816. */
  14817. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14818. private _addFactorGradient;
  14819. private _removeFactorGradient;
  14820. /**
  14821. * Adds a new life time gradient
  14822. * @param gradient defines the gradient to use (between 0 and 1)
  14823. * @param factor defines the life time factor to affect to the specified gradient
  14824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14825. * @returns the current particle system
  14826. */
  14827. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14828. /**
  14829. * Remove a specific life time gradient
  14830. * @param gradient defines the gradient to remove
  14831. * @returns the current particle system
  14832. */
  14833. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14834. /**
  14835. * Adds a new size gradient
  14836. * @param gradient defines the gradient to use (between 0 and 1)
  14837. * @param factor defines the size factor to affect to the specified gradient
  14838. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14839. * @returns the current particle system
  14840. */
  14841. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14842. /**
  14843. * Remove a specific size gradient
  14844. * @param gradient defines the gradient to remove
  14845. * @returns the current particle system
  14846. */
  14847. removeSizeGradient(gradient: number): IParticleSystem;
  14848. /**
  14849. * Adds a new color remap gradient
  14850. * @param gradient defines the gradient to use (between 0 and 1)
  14851. * @param min defines the color remap minimal range
  14852. * @param max defines the color remap maximal range
  14853. * @returns the current particle system
  14854. */
  14855. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14856. /**
  14857. * Remove a specific color remap gradient
  14858. * @param gradient defines the gradient to remove
  14859. * @returns the current particle system
  14860. */
  14861. removeColorRemapGradient(gradient: number): IParticleSystem;
  14862. /**
  14863. * Adds a new alpha remap gradient
  14864. * @param gradient defines the gradient to use (between 0 and 1)
  14865. * @param min defines the alpha remap minimal range
  14866. * @param max defines the alpha remap maximal range
  14867. * @returns the current particle system
  14868. */
  14869. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14870. /**
  14871. * Remove a specific alpha remap gradient
  14872. * @param gradient defines the gradient to remove
  14873. * @returns the current particle system
  14874. */
  14875. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14876. /**
  14877. * Adds a new angular speed gradient
  14878. * @param gradient defines the gradient to use (between 0 and 1)
  14879. * @param factor defines the angular speed to affect to the specified gradient
  14880. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14881. * @returns the current particle system
  14882. */
  14883. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14884. /**
  14885. * Remove a specific angular speed gradient
  14886. * @param gradient defines the gradient to remove
  14887. * @returns the current particle system
  14888. */
  14889. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14890. /**
  14891. * Adds a new velocity gradient
  14892. * @param gradient defines the gradient to use (between 0 and 1)
  14893. * @param factor defines the velocity to affect to the specified gradient
  14894. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14895. * @returns the current particle system
  14896. */
  14897. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14898. /**
  14899. * Remove a specific velocity gradient
  14900. * @param gradient defines the gradient to remove
  14901. * @returns the current particle system
  14902. */
  14903. removeVelocityGradient(gradient: number): IParticleSystem;
  14904. /**
  14905. * Adds a new limit velocity gradient
  14906. * @param gradient defines the gradient to use (between 0 and 1)
  14907. * @param factor defines the limit velocity value to affect to the specified gradient
  14908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14909. * @returns the current particle system
  14910. */
  14911. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14912. /**
  14913. * Remove a specific limit velocity gradient
  14914. * @param gradient defines the gradient to remove
  14915. * @returns the current particle system
  14916. */
  14917. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14918. /**
  14919. * Adds a new drag gradient
  14920. * @param gradient defines the gradient to use (between 0 and 1)
  14921. * @param factor defines the drag value to affect to the specified gradient
  14922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14923. * @returns the current particle system
  14924. */
  14925. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14926. /**
  14927. * Remove a specific drag gradient
  14928. * @param gradient defines the gradient to remove
  14929. * @returns the current particle system
  14930. */
  14931. removeDragGradient(gradient: number): IParticleSystem;
  14932. /**
  14933. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14934. * @param gradient defines the gradient to use (between 0 and 1)
  14935. * @param factor defines the emit rate value to affect to the specified gradient
  14936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14937. * @returns the current particle system
  14938. */
  14939. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14940. /**
  14941. * Remove a specific emit rate gradient
  14942. * @param gradient defines the gradient to remove
  14943. * @returns the current particle system
  14944. */
  14945. removeEmitRateGradient(gradient: number): IParticleSystem;
  14946. /**
  14947. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14948. * @param gradient defines the gradient to use (between 0 and 1)
  14949. * @param factor defines the start size value to affect to the specified gradient
  14950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14951. * @returns the current particle system
  14952. */
  14953. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14954. /**
  14955. * Remove a specific start size gradient
  14956. * @param gradient defines the gradient to remove
  14957. * @returns the current particle system
  14958. */
  14959. removeStartSizeGradient(gradient: number): IParticleSystem;
  14960. private _createRampGradientTexture;
  14961. /**
  14962. * Gets the current list of ramp gradients.
  14963. * You must use addRampGradient and removeRampGradient to udpate this list
  14964. * @returns the list of ramp gradients
  14965. */
  14966. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14967. /**
  14968. * Adds a new ramp gradient used to remap particle colors
  14969. * @param gradient defines the gradient to use (between 0 and 1)
  14970. * @param color defines the color to affect to the specified gradient
  14971. * @returns the current particle system
  14972. */
  14973. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14974. /**
  14975. * Remove a specific ramp gradient
  14976. * @param gradient defines the gradient to remove
  14977. * @returns the current particle system
  14978. */
  14979. removeRampGradient(gradient: number): ParticleSystem;
  14980. /**
  14981. * Adds a new color gradient
  14982. * @param gradient defines the gradient to use (between 0 and 1)
  14983. * @param color1 defines the color to affect to the specified gradient
  14984. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14985. * @returns this particle system
  14986. */
  14987. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14988. /**
  14989. * Remove a specific color gradient
  14990. * @param gradient defines the gradient to remove
  14991. * @returns this particle system
  14992. */
  14993. removeColorGradient(gradient: number): IParticleSystem;
  14994. private _fetchR;
  14995. protected _reset(): void;
  14996. private _resetEffect;
  14997. private _createVertexBuffers;
  14998. private _createIndexBuffer;
  14999. /**
  15000. * Gets the maximum number of particles active at the same time.
  15001. * @returns The max number of active particles.
  15002. */
  15003. getCapacity(): number;
  15004. /**
  15005. * Gets whether there are still active particles in the system.
  15006. * @returns True if it is alive, otherwise false.
  15007. */
  15008. isAlive(): boolean;
  15009. /**
  15010. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15011. * @returns True if it has been started, otherwise false.
  15012. */
  15013. isStarted(): boolean;
  15014. private _prepareSubEmitterInternalArray;
  15015. /**
  15016. * Starts the particle system and begins to emit
  15017. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15018. */
  15019. start(delay?: number): void;
  15020. /**
  15021. * Stops the particle system.
  15022. * @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.
  15023. */
  15024. stop(stopSubEmitters?: boolean): void;
  15025. /**
  15026. * Remove all active particles
  15027. */
  15028. reset(): void;
  15029. /**
  15030. * @hidden (for internal use only)
  15031. */
  15032. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15033. /**
  15034. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15035. * Its lifetime will start back at 0.
  15036. */
  15037. recycleParticle: (particle: Particle) => void;
  15038. private _stopSubEmitters;
  15039. private _createParticle;
  15040. private _removeFromRoot;
  15041. private _emitFromParticle;
  15042. private _update;
  15043. /** @hidden */
  15044. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15045. /** @hidden */
  15046. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15047. /** @hidden */
  15048. private _getEffect;
  15049. /**
  15050. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15051. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15052. */
  15053. animate(preWarmOnly?: boolean): void;
  15054. private _appendParticleVertices;
  15055. /**
  15056. * Rebuilds the particle system.
  15057. */
  15058. rebuild(): void;
  15059. /**
  15060. * Is this system ready to be used/rendered
  15061. * @return true if the system is ready
  15062. */
  15063. isReady(): boolean;
  15064. private _render;
  15065. /**
  15066. * Renders the particle system in its current state.
  15067. * @returns the current number of particles
  15068. */
  15069. render(): number;
  15070. /**
  15071. * Disposes the particle system and free the associated resources
  15072. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15073. */
  15074. dispose(disposeTexture?: boolean): void;
  15075. /**
  15076. * Clones the particle system.
  15077. * @param name The name of the cloned object
  15078. * @param newEmitter The new emitter to use
  15079. * @returns the cloned particle system
  15080. */
  15081. clone(name: string, newEmitter: any): ParticleSystem;
  15082. /**
  15083. * Serializes the particle system to a JSON object.
  15084. * @returns the JSON object
  15085. */
  15086. serialize(): any;
  15087. /** @hidden */
  15088. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15089. /** @hidden */
  15090. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15091. /**
  15092. * Parses a JSON object to create a particle system.
  15093. * @param parsedParticleSystem The JSON object to parse
  15094. * @param scene The scene to create the particle system in
  15095. * @param rootUrl The root url to use to load external dependencies like texture
  15096. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15097. * @returns the Parsed particle system
  15098. */
  15099. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15100. }
  15101. }
  15102. declare module "babylonjs/Particles/particle" {
  15103. import { Nullable } from "babylonjs/types";
  15104. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15105. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15106. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15107. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15108. /**
  15109. * A particle represents one of the element emitted by a particle system.
  15110. * This is mainly define by its coordinates, direction, velocity and age.
  15111. */
  15112. export class Particle {
  15113. /**
  15114. * The particle system the particle belongs to.
  15115. */
  15116. particleSystem: ParticleSystem;
  15117. private static _Count;
  15118. /**
  15119. * Unique ID of the particle
  15120. */
  15121. id: number;
  15122. /**
  15123. * The world position of the particle in the scene.
  15124. */
  15125. position: Vector3;
  15126. /**
  15127. * The world direction of the particle in the scene.
  15128. */
  15129. direction: Vector3;
  15130. /**
  15131. * The color of the particle.
  15132. */
  15133. color: Color4;
  15134. /**
  15135. * The color change of the particle per step.
  15136. */
  15137. colorStep: Color4;
  15138. /**
  15139. * Defines how long will the life of the particle be.
  15140. */
  15141. lifeTime: number;
  15142. /**
  15143. * The current age of the particle.
  15144. */
  15145. age: number;
  15146. /**
  15147. * The current size of the particle.
  15148. */
  15149. size: number;
  15150. /**
  15151. * The current scale of the particle.
  15152. */
  15153. scale: Vector2;
  15154. /**
  15155. * The current angle of the particle.
  15156. */
  15157. angle: number;
  15158. /**
  15159. * Defines how fast is the angle changing.
  15160. */
  15161. angularSpeed: number;
  15162. /**
  15163. * Defines the cell index used by the particle to be rendered from a sprite.
  15164. */
  15165. cellIndex: number;
  15166. /**
  15167. * The information required to support color remapping
  15168. */
  15169. remapData: Vector4;
  15170. /** @hidden */
  15171. _randomCellOffset?: number;
  15172. /** @hidden */
  15173. _initialDirection: Nullable<Vector3>;
  15174. /** @hidden */
  15175. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15176. /** @hidden */
  15177. _initialStartSpriteCellID: number;
  15178. /** @hidden */
  15179. _initialEndSpriteCellID: number;
  15180. /** @hidden */
  15181. _currentColorGradient: Nullable<ColorGradient>;
  15182. /** @hidden */
  15183. _currentColor1: Color4;
  15184. /** @hidden */
  15185. _currentColor2: Color4;
  15186. /** @hidden */
  15187. _currentSizeGradient: Nullable<FactorGradient>;
  15188. /** @hidden */
  15189. _currentSize1: number;
  15190. /** @hidden */
  15191. _currentSize2: number;
  15192. /** @hidden */
  15193. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15194. /** @hidden */
  15195. _currentAngularSpeed1: number;
  15196. /** @hidden */
  15197. _currentAngularSpeed2: number;
  15198. /** @hidden */
  15199. _currentVelocityGradient: Nullable<FactorGradient>;
  15200. /** @hidden */
  15201. _currentVelocity1: number;
  15202. /** @hidden */
  15203. _currentVelocity2: number;
  15204. /** @hidden */
  15205. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15206. /** @hidden */
  15207. _currentLimitVelocity1: number;
  15208. /** @hidden */
  15209. _currentLimitVelocity2: number;
  15210. /** @hidden */
  15211. _currentDragGradient: Nullable<FactorGradient>;
  15212. /** @hidden */
  15213. _currentDrag1: number;
  15214. /** @hidden */
  15215. _currentDrag2: number;
  15216. /** @hidden */
  15217. _randomNoiseCoordinates1: Vector3;
  15218. /** @hidden */
  15219. _randomNoiseCoordinates2: Vector3;
  15220. /**
  15221. * Creates a new instance Particle
  15222. * @param particleSystem the particle system the particle belongs to
  15223. */
  15224. constructor(
  15225. /**
  15226. * The particle system the particle belongs to.
  15227. */
  15228. particleSystem: ParticleSystem);
  15229. private updateCellInfoFromSystem;
  15230. /**
  15231. * Defines how the sprite cell index is updated for the particle
  15232. */
  15233. updateCellIndex(): void;
  15234. /** @hidden */
  15235. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15236. /** @hidden */
  15237. _inheritParticleInfoToSubEmitters(): void;
  15238. /** @hidden */
  15239. _reset(): void;
  15240. /**
  15241. * Copy the properties of particle to another one.
  15242. * @param other the particle to copy the information to.
  15243. */
  15244. copyTo(other: Particle): void;
  15245. }
  15246. }
  15247. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15248. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15249. import { Effect } from "babylonjs/Materials/effect";
  15250. import { Particle } from "babylonjs/Particles/particle";
  15251. /**
  15252. * Particle emitter represents a volume emitting particles.
  15253. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15254. */
  15255. export interface IParticleEmitterType {
  15256. /**
  15257. * Called by the particle System when the direction is computed for the created particle.
  15258. * @param worldMatrix is the world matrix of the particle system
  15259. * @param directionToUpdate is the direction vector to update with the result
  15260. * @param particle is the particle we are computed the direction for
  15261. */
  15262. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15263. /**
  15264. * Called by the particle System when the position is computed for the created particle.
  15265. * @param worldMatrix is the world matrix of the particle system
  15266. * @param positionToUpdate is the position vector to update with the result
  15267. * @param particle is the particle we are computed the position for
  15268. */
  15269. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15270. /**
  15271. * Clones the current emitter and returns a copy of it
  15272. * @returns the new emitter
  15273. */
  15274. clone(): IParticleEmitterType;
  15275. /**
  15276. * Called by the GPUParticleSystem to setup the update shader
  15277. * @param effect defines the update shader
  15278. */
  15279. applyToShader(effect: Effect): void;
  15280. /**
  15281. * Returns a string to use to update the GPU particles update shader
  15282. * @returns the effect defines string
  15283. */
  15284. getEffectDefines(): string;
  15285. /**
  15286. * Returns a string representing the class name
  15287. * @returns a string containing the class name
  15288. */
  15289. getClassName(): string;
  15290. /**
  15291. * Serializes the particle system to a JSON object.
  15292. * @returns the JSON object
  15293. */
  15294. serialize(): any;
  15295. /**
  15296. * Parse properties from a JSON object
  15297. * @param serializationObject defines the JSON object
  15298. */
  15299. parse(serializationObject: any): void;
  15300. }
  15301. }
  15302. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15303. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15304. import { Effect } from "babylonjs/Materials/effect";
  15305. import { Particle } from "babylonjs/Particles/particle";
  15306. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15307. /**
  15308. * Particle emitter emitting particles from the inside of a box.
  15309. * It emits the particles randomly between 2 given directions.
  15310. */
  15311. export class BoxParticleEmitter implements IParticleEmitterType {
  15312. /**
  15313. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15314. */
  15315. direction1: Vector3;
  15316. /**
  15317. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15318. */
  15319. direction2: Vector3;
  15320. /**
  15321. * 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.
  15322. */
  15323. minEmitBox: Vector3;
  15324. /**
  15325. * 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.
  15326. */
  15327. maxEmitBox: Vector3;
  15328. /**
  15329. * Creates a new instance BoxParticleEmitter
  15330. */
  15331. constructor();
  15332. /**
  15333. * Called by the particle System when the direction is computed for the created particle.
  15334. * @param worldMatrix is the world matrix of the particle system
  15335. * @param directionToUpdate is the direction vector to update with the result
  15336. * @param particle is the particle we are computed the direction for
  15337. */
  15338. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15339. /**
  15340. * Called by the particle System when the position is computed for the created particle.
  15341. * @param worldMatrix is the world matrix of the particle system
  15342. * @param positionToUpdate is the position vector to update with the result
  15343. * @param particle is the particle we are computed the position for
  15344. */
  15345. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15346. /**
  15347. * Clones the current emitter and returns a copy of it
  15348. * @returns the new emitter
  15349. */
  15350. clone(): BoxParticleEmitter;
  15351. /**
  15352. * Called by the GPUParticleSystem to setup the update shader
  15353. * @param effect defines the update shader
  15354. */
  15355. applyToShader(effect: Effect): void;
  15356. /**
  15357. * Returns a string to use to update the GPU particles update shader
  15358. * @returns a string containng the defines string
  15359. */
  15360. getEffectDefines(): string;
  15361. /**
  15362. * Returns the string "BoxParticleEmitter"
  15363. * @returns a string containing the class name
  15364. */
  15365. getClassName(): string;
  15366. /**
  15367. * Serializes the particle system to a JSON object.
  15368. * @returns the JSON object
  15369. */
  15370. serialize(): any;
  15371. /**
  15372. * Parse properties from a JSON object
  15373. * @param serializationObject defines the JSON object
  15374. */
  15375. parse(serializationObject: any): void;
  15376. }
  15377. }
  15378. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15379. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15380. import { Effect } from "babylonjs/Materials/effect";
  15381. import { Particle } from "babylonjs/Particles/particle";
  15382. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15383. /**
  15384. * Particle emitter emitting particles from the inside of a cone.
  15385. * It emits the particles alongside the cone volume from the base to the particle.
  15386. * The emission direction might be randomized.
  15387. */
  15388. export class ConeParticleEmitter implements IParticleEmitterType {
  15389. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15390. directionRandomizer: number;
  15391. private _radius;
  15392. private _angle;
  15393. private _height;
  15394. /**
  15395. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15396. */
  15397. radiusRange: number;
  15398. /**
  15399. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15400. */
  15401. heightRange: number;
  15402. /**
  15403. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15404. */
  15405. emitFromSpawnPointOnly: boolean;
  15406. /**
  15407. * Gets or sets the radius of the emission cone
  15408. */
  15409. radius: number;
  15410. /**
  15411. * Gets or sets the angle of the emission cone
  15412. */
  15413. angle: number;
  15414. private _buildHeight;
  15415. /**
  15416. * Creates a new instance ConeParticleEmitter
  15417. * @param radius the radius of the emission cone (1 by default)
  15418. * @param angle the cone base angle (PI by default)
  15419. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15420. */
  15421. constructor(radius?: number, angle?: number,
  15422. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15423. directionRandomizer?: number);
  15424. /**
  15425. * Called by the particle System when the direction is computed for the created particle.
  15426. * @param worldMatrix is the world matrix of the particle system
  15427. * @param directionToUpdate is the direction vector to update with the result
  15428. * @param particle is the particle we are computed the direction for
  15429. */
  15430. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15431. /**
  15432. * Called by the particle System when the position is computed for the created particle.
  15433. * @param worldMatrix is the world matrix of the particle system
  15434. * @param positionToUpdate is the position vector to update with the result
  15435. * @param particle is the particle we are computed the position for
  15436. */
  15437. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15438. /**
  15439. * Clones the current emitter and returns a copy of it
  15440. * @returns the new emitter
  15441. */
  15442. clone(): ConeParticleEmitter;
  15443. /**
  15444. * Called by the GPUParticleSystem to setup the update shader
  15445. * @param effect defines the update shader
  15446. */
  15447. applyToShader(effect: Effect): void;
  15448. /**
  15449. * Returns a string to use to update the GPU particles update shader
  15450. * @returns a string containng the defines string
  15451. */
  15452. getEffectDefines(): string;
  15453. /**
  15454. * Returns the string "ConeParticleEmitter"
  15455. * @returns a string containing the class name
  15456. */
  15457. getClassName(): string;
  15458. /**
  15459. * Serializes the particle system to a JSON object.
  15460. * @returns the JSON object
  15461. */
  15462. serialize(): any;
  15463. /**
  15464. * Parse properties from a JSON object
  15465. * @param serializationObject defines the JSON object
  15466. */
  15467. parse(serializationObject: any): void;
  15468. }
  15469. }
  15470. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15471. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15472. import { Effect } from "babylonjs/Materials/effect";
  15473. import { Particle } from "babylonjs/Particles/particle";
  15474. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15475. /**
  15476. * Particle emitter emitting particles from the inside of a cylinder.
  15477. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15478. */
  15479. export class CylinderParticleEmitter implements IParticleEmitterType {
  15480. /**
  15481. * The radius of the emission cylinder.
  15482. */
  15483. radius: number;
  15484. /**
  15485. * The height of the emission cylinder.
  15486. */
  15487. height: number;
  15488. /**
  15489. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15490. */
  15491. radiusRange: number;
  15492. /**
  15493. * How much to randomize the particle direction [0-1].
  15494. */
  15495. directionRandomizer: number;
  15496. /**
  15497. * Creates a new instance CylinderParticleEmitter
  15498. * @param radius the radius of the emission cylinder (1 by default)
  15499. * @param height the height of the emission cylinder (1 by default)
  15500. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15501. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15502. */
  15503. constructor(
  15504. /**
  15505. * The radius of the emission cylinder.
  15506. */
  15507. radius?: number,
  15508. /**
  15509. * The height of the emission cylinder.
  15510. */
  15511. height?: number,
  15512. /**
  15513. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15514. */
  15515. radiusRange?: number,
  15516. /**
  15517. * How much to randomize the particle direction [0-1].
  15518. */
  15519. directionRandomizer?: number);
  15520. /**
  15521. * Called by the particle System when the direction is computed for the created particle.
  15522. * @param worldMatrix is the world matrix of the particle system
  15523. * @param directionToUpdate is the direction vector to update with the result
  15524. * @param particle is the particle we are computed the direction for
  15525. */
  15526. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15527. /**
  15528. * Called by the particle System when the position is computed for the created particle.
  15529. * @param worldMatrix is the world matrix of the particle system
  15530. * @param positionToUpdate is the position vector to update with the result
  15531. * @param particle is the particle we are computed the position for
  15532. */
  15533. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15534. /**
  15535. * Clones the current emitter and returns a copy of it
  15536. * @returns the new emitter
  15537. */
  15538. clone(): CylinderParticleEmitter;
  15539. /**
  15540. * Called by the GPUParticleSystem to setup the update shader
  15541. * @param effect defines the update shader
  15542. */
  15543. applyToShader(effect: Effect): void;
  15544. /**
  15545. * Returns a string to use to update the GPU particles update shader
  15546. * @returns a string containng the defines string
  15547. */
  15548. getEffectDefines(): string;
  15549. /**
  15550. * Returns the string "CylinderParticleEmitter"
  15551. * @returns a string containing the class name
  15552. */
  15553. getClassName(): string;
  15554. /**
  15555. * Serializes the particle system to a JSON object.
  15556. * @returns the JSON object
  15557. */
  15558. serialize(): any;
  15559. /**
  15560. * Parse properties from a JSON object
  15561. * @param serializationObject defines the JSON object
  15562. */
  15563. parse(serializationObject: any): void;
  15564. }
  15565. /**
  15566. * Particle emitter emitting particles from the inside of a cylinder.
  15567. * It emits the particles randomly between two vectors.
  15568. */
  15569. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15570. /**
  15571. * The min limit of the emission direction.
  15572. */
  15573. direction1: Vector3;
  15574. /**
  15575. * The max limit of the emission direction.
  15576. */
  15577. direction2: Vector3;
  15578. /**
  15579. * Creates a new instance CylinderDirectedParticleEmitter
  15580. * @param radius the radius of the emission cylinder (1 by default)
  15581. * @param height the height of the emission cylinder (1 by default)
  15582. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15583. * @param direction1 the min limit of the emission direction (up vector by default)
  15584. * @param direction2 the max limit of the emission direction (up vector by default)
  15585. */
  15586. constructor(radius?: number, height?: number, radiusRange?: number,
  15587. /**
  15588. * The min limit of the emission direction.
  15589. */
  15590. direction1?: Vector3,
  15591. /**
  15592. * The max limit of the emission direction.
  15593. */
  15594. direction2?: Vector3);
  15595. /**
  15596. * Called by the particle System when the direction is computed for the created particle.
  15597. * @param worldMatrix is the world matrix of the particle system
  15598. * @param directionToUpdate is the direction vector to update with the result
  15599. * @param particle is the particle we are computed the direction for
  15600. */
  15601. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15602. /**
  15603. * Clones the current emitter and returns a copy of it
  15604. * @returns the new emitter
  15605. */
  15606. clone(): CylinderDirectedParticleEmitter;
  15607. /**
  15608. * Called by the GPUParticleSystem to setup the update shader
  15609. * @param effect defines the update shader
  15610. */
  15611. applyToShader(effect: Effect): void;
  15612. /**
  15613. * Returns a string to use to update the GPU particles update shader
  15614. * @returns a string containng the defines string
  15615. */
  15616. getEffectDefines(): string;
  15617. /**
  15618. * Returns the string "CylinderDirectedParticleEmitter"
  15619. * @returns a string containing the class name
  15620. */
  15621. getClassName(): string;
  15622. /**
  15623. * Serializes the particle system to a JSON object.
  15624. * @returns the JSON object
  15625. */
  15626. serialize(): any;
  15627. /**
  15628. * Parse properties from a JSON object
  15629. * @param serializationObject defines the JSON object
  15630. */
  15631. parse(serializationObject: any): void;
  15632. }
  15633. }
  15634. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15635. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15636. import { Effect } from "babylonjs/Materials/effect";
  15637. import { Particle } from "babylonjs/Particles/particle";
  15638. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15639. /**
  15640. * Particle emitter emitting particles from the inside of a hemisphere.
  15641. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15642. */
  15643. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15644. /**
  15645. * The radius of the emission hemisphere.
  15646. */
  15647. radius: number;
  15648. /**
  15649. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15650. */
  15651. radiusRange: number;
  15652. /**
  15653. * How much to randomize the particle direction [0-1].
  15654. */
  15655. directionRandomizer: number;
  15656. /**
  15657. * Creates a new instance HemisphericParticleEmitter
  15658. * @param radius the radius of the emission hemisphere (1 by default)
  15659. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15660. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15661. */
  15662. constructor(
  15663. /**
  15664. * The radius of the emission hemisphere.
  15665. */
  15666. radius?: number,
  15667. /**
  15668. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15669. */
  15670. radiusRange?: number,
  15671. /**
  15672. * How much to randomize the particle direction [0-1].
  15673. */
  15674. directionRandomizer?: number);
  15675. /**
  15676. * Called by the particle System when the direction is computed for the created particle.
  15677. * @param worldMatrix is the world matrix of the particle system
  15678. * @param directionToUpdate is the direction vector to update with the result
  15679. * @param particle is the particle we are computed the direction for
  15680. */
  15681. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15682. /**
  15683. * Called by the particle System when the position is computed for the created particle.
  15684. * @param worldMatrix is the world matrix of the particle system
  15685. * @param positionToUpdate is the position vector to update with the result
  15686. * @param particle is the particle we are computed the position for
  15687. */
  15688. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15689. /**
  15690. * Clones the current emitter and returns a copy of it
  15691. * @returns the new emitter
  15692. */
  15693. clone(): HemisphericParticleEmitter;
  15694. /**
  15695. * Called by the GPUParticleSystem to setup the update shader
  15696. * @param effect defines the update shader
  15697. */
  15698. applyToShader(effect: Effect): void;
  15699. /**
  15700. * Returns a string to use to update the GPU particles update shader
  15701. * @returns a string containng the defines string
  15702. */
  15703. getEffectDefines(): string;
  15704. /**
  15705. * Returns the string "HemisphericParticleEmitter"
  15706. * @returns a string containing the class name
  15707. */
  15708. getClassName(): string;
  15709. /**
  15710. * Serializes the particle system to a JSON object.
  15711. * @returns the JSON object
  15712. */
  15713. serialize(): any;
  15714. /**
  15715. * Parse properties from a JSON object
  15716. * @param serializationObject defines the JSON object
  15717. */
  15718. parse(serializationObject: any): void;
  15719. }
  15720. }
  15721. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15722. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15723. import { Effect } from "babylonjs/Materials/effect";
  15724. import { Particle } from "babylonjs/Particles/particle";
  15725. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15726. /**
  15727. * Particle emitter emitting particles from a point.
  15728. * It emits the particles randomly between 2 given directions.
  15729. */
  15730. export class PointParticleEmitter implements IParticleEmitterType {
  15731. /**
  15732. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15733. */
  15734. direction1: Vector3;
  15735. /**
  15736. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15737. */
  15738. direction2: Vector3;
  15739. /**
  15740. * Creates a new instance PointParticleEmitter
  15741. */
  15742. constructor();
  15743. /**
  15744. * Called by the particle System when the direction is computed for the created particle.
  15745. * @param worldMatrix is the world matrix of the particle system
  15746. * @param directionToUpdate is the direction vector to update with the result
  15747. * @param particle is the particle we are computed the direction for
  15748. */
  15749. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15750. /**
  15751. * Called by the particle System when the position is computed for the created particle.
  15752. * @param worldMatrix is the world matrix of the particle system
  15753. * @param positionToUpdate is the position vector to update with the result
  15754. * @param particle is the particle we are computed the position for
  15755. */
  15756. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15757. /**
  15758. * Clones the current emitter and returns a copy of it
  15759. * @returns the new emitter
  15760. */
  15761. clone(): PointParticleEmitter;
  15762. /**
  15763. * Called by the GPUParticleSystem to setup the update shader
  15764. * @param effect defines the update shader
  15765. */
  15766. applyToShader(effect: Effect): void;
  15767. /**
  15768. * Returns a string to use to update the GPU particles update shader
  15769. * @returns a string containng the defines string
  15770. */
  15771. getEffectDefines(): string;
  15772. /**
  15773. * Returns the string "PointParticleEmitter"
  15774. * @returns a string containing the class name
  15775. */
  15776. getClassName(): string;
  15777. /**
  15778. * Serializes the particle system to a JSON object.
  15779. * @returns the JSON object
  15780. */
  15781. serialize(): any;
  15782. /**
  15783. * Parse properties from a JSON object
  15784. * @param serializationObject defines the JSON object
  15785. */
  15786. parse(serializationObject: any): void;
  15787. }
  15788. }
  15789. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15790. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15791. import { Effect } from "babylonjs/Materials/effect";
  15792. import { Particle } from "babylonjs/Particles/particle";
  15793. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15794. /**
  15795. * Particle emitter emitting particles from the inside of a sphere.
  15796. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15797. */
  15798. export class SphereParticleEmitter implements IParticleEmitterType {
  15799. /**
  15800. * The radius of the emission sphere.
  15801. */
  15802. radius: number;
  15803. /**
  15804. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15805. */
  15806. radiusRange: number;
  15807. /**
  15808. * How much to randomize the particle direction [0-1].
  15809. */
  15810. directionRandomizer: number;
  15811. /**
  15812. * Creates a new instance SphereParticleEmitter
  15813. * @param radius the radius of the emission sphere (1 by default)
  15814. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15815. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15816. */
  15817. constructor(
  15818. /**
  15819. * The radius of the emission sphere.
  15820. */
  15821. radius?: number,
  15822. /**
  15823. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15824. */
  15825. radiusRange?: number,
  15826. /**
  15827. * How much to randomize the particle direction [0-1].
  15828. */
  15829. directionRandomizer?: number);
  15830. /**
  15831. * Called by the particle System when the direction is computed for the created particle.
  15832. * @param worldMatrix is the world matrix of the particle system
  15833. * @param directionToUpdate is the direction vector to update with the result
  15834. * @param particle is the particle we are computed the direction for
  15835. */
  15836. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15837. /**
  15838. * Called by the particle System when the position is computed for the created particle.
  15839. * @param worldMatrix is the world matrix of the particle system
  15840. * @param positionToUpdate is the position vector to update with the result
  15841. * @param particle is the particle we are computed the position for
  15842. */
  15843. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15844. /**
  15845. * Clones the current emitter and returns a copy of it
  15846. * @returns the new emitter
  15847. */
  15848. clone(): SphereParticleEmitter;
  15849. /**
  15850. * Called by the GPUParticleSystem to setup the update shader
  15851. * @param effect defines the update shader
  15852. */
  15853. applyToShader(effect: Effect): void;
  15854. /**
  15855. * Returns a string to use to update the GPU particles update shader
  15856. * @returns a string containng the defines string
  15857. */
  15858. getEffectDefines(): string;
  15859. /**
  15860. * Returns the string "SphereParticleEmitter"
  15861. * @returns a string containing the class name
  15862. */
  15863. getClassName(): string;
  15864. /**
  15865. * Serializes the particle system to a JSON object.
  15866. * @returns the JSON object
  15867. */
  15868. serialize(): any;
  15869. /**
  15870. * Parse properties from a JSON object
  15871. * @param serializationObject defines the JSON object
  15872. */
  15873. parse(serializationObject: any): void;
  15874. }
  15875. /**
  15876. * Particle emitter emitting particles from the inside of a sphere.
  15877. * It emits the particles randomly between two vectors.
  15878. */
  15879. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15880. /**
  15881. * The min limit of the emission direction.
  15882. */
  15883. direction1: Vector3;
  15884. /**
  15885. * The max limit of the emission direction.
  15886. */
  15887. direction2: Vector3;
  15888. /**
  15889. * Creates a new instance SphereDirectedParticleEmitter
  15890. * @param radius the radius of the emission sphere (1 by default)
  15891. * @param direction1 the min limit of the emission direction (up vector by default)
  15892. * @param direction2 the max limit of the emission direction (up vector by default)
  15893. */
  15894. constructor(radius?: number,
  15895. /**
  15896. * The min limit of the emission direction.
  15897. */
  15898. direction1?: Vector3,
  15899. /**
  15900. * The max limit of the emission direction.
  15901. */
  15902. direction2?: Vector3);
  15903. /**
  15904. * Called by the particle System when the direction is computed for the created particle.
  15905. * @param worldMatrix is the world matrix of the particle system
  15906. * @param directionToUpdate is the direction vector to update with the result
  15907. * @param particle is the particle we are computed the direction for
  15908. */
  15909. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15910. /**
  15911. * Clones the current emitter and returns a copy of it
  15912. * @returns the new emitter
  15913. */
  15914. clone(): SphereDirectedParticleEmitter;
  15915. /**
  15916. * Called by the GPUParticleSystem to setup the update shader
  15917. * @param effect defines the update shader
  15918. */
  15919. applyToShader(effect: Effect): void;
  15920. /**
  15921. * Returns a string to use to update the GPU particles update shader
  15922. * @returns a string containng the defines string
  15923. */
  15924. getEffectDefines(): string;
  15925. /**
  15926. * Returns the string "SphereDirectedParticleEmitter"
  15927. * @returns a string containing the class name
  15928. */
  15929. getClassName(): string;
  15930. /**
  15931. * Serializes the particle system to a JSON object.
  15932. * @returns the JSON object
  15933. */
  15934. serialize(): any;
  15935. /**
  15936. * Parse properties from a JSON object
  15937. * @param serializationObject defines the JSON object
  15938. */
  15939. parse(serializationObject: any): void;
  15940. }
  15941. }
  15942. declare module "babylonjs/Particles/EmitterTypes/index" {
  15943. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15944. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15945. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15946. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15947. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15948. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15949. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15950. }
  15951. declare module "babylonjs/Particles/IParticleSystem" {
  15952. import { Nullable } from "babylonjs/types";
  15953. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15956. import { Texture } from "babylonjs/Materials/Textures/texture";
  15957. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15958. import { Scene } from "babylonjs/scene";
  15959. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15960. import { Animation } from "babylonjs/Animations/animation";
  15961. /**
  15962. * Interface representing a particle system in Babylon.js.
  15963. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15964. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15965. */
  15966. export interface IParticleSystem {
  15967. /**
  15968. * List of animations used by the particle system.
  15969. */
  15970. animations: Animation[];
  15971. /**
  15972. * The id of the Particle system.
  15973. */
  15974. id: string;
  15975. /**
  15976. * The name of the Particle system.
  15977. */
  15978. name: string;
  15979. /**
  15980. * The emitter represents the Mesh or position we are attaching the particle system to.
  15981. */
  15982. emitter: Nullable<AbstractMesh | Vector3>;
  15983. /**
  15984. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15985. */
  15986. isBillboardBased: boolean;
  15987. /**
  15988. * The rendering group used by the Particle system to chose when to render.
  15989. */
  15990. renderingGroupId: number;
  15991. /**
  15992. * The layer mask we are rendering the particles through.
  15993. */
  15994. layerMask: number;
  15995. /**
  15996. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15997. */
  15998. updateSpeed: number;
  15999. /**
  16000. * The amount of time the particle system is running (depends of the overall update speed).
  16001. */
  16002. targetStopDuration: number;
  16003. /**
  16004. * The texture used to render each particle. (this can be a spritesheet)
  16005. */
  16006. particleTexture: Nullable<Texture>;
  16007. /**
  16008. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16009. */
  16010. blendMode: number;
  16011. /**
  16012. * Minimum life time of emitting particles.
  16013. */
  16014. minLifeTime: number;
  16015. /**
  16016. * Maximum life time of emitting particles.
  16017. */
  16018. maxLifeTime: number;
  16019. /**
  16020. * Minimum Size of emitting particles.
  16021. */
  16022. minSize: number;
  16023. /**
  16024. * Maximum Size of emitting particles.
  16025. */
  16026. maxSize: number;
  16027. /**
  16028. * Minimum scale of emitting particles on X axis.
  16029. */
  16030. minScaleX: number;
  16031. /**
  16032. * Maximum scale of emitting particles on X axis.
  16033. */
  16034. maxScaleX: number;
  16035. /**
  16036. * Minimum scale of emitting particles on Y axis.
  16037. */
  16038. minScaleY: number;
  16039. /**
  16040. * Maximum scale of emitting particles on Y axis.
  16041. */
  16042. maxScaleY: number;
  16043. /**
  16044. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16045. */
  16046. color1: Color4;
  16047. /**
  16048. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16049. */
  16050. color2: Color4;
  16051. /**
  16052. * Color the particle will have at the end of its lifetime.
  16053. */
  16054. colorDead: Color4;
  16055. /**
  16056. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16057. */
  16058. emitRate: number;
  16059. /**
  16060. * You can use gravity if you want to give an orientation to your particles.
  16061. */
  16062. gravity: Vector3;
  16063. /**
  16064. * Minimum power of emitting particles.
  16065. */
  16066. minEmitPower: number;
  16067. /**
  16068. * Maximum power of emitting particles.
  16069. */
  16070. maxEmitPower: number;
  16071. /**
  16072. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16073. */
  16074. minAngularSpeed: number;
  16075. /**
  16076. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16077. */
  16078. maxAngularSpeed: number;
  16079. /**
  16080. * Gets or sets the minimal initial rotation in radians.
  16081. */
  16082. minInitialRotation: number;
  16083. /**
  16084. * Gets or sets the maximal initial rotation in radians.
  16085. */
  16086. maxInitialRotation: number;
  16087. /**
  16088. * The particle emitter type defines the emitter used by the particle system.
  16089. * It can be for example box, sphere, or cone...
  16090. */
  16091. particleEmitterType: Nullable<IParticleEmitterType>;
  16092. /**
  16093. * Defines the delay in milliseconds before starting the system (0 by default)
  16094. */
  16095. startDelay: number;
  16096. /**
  16097. * 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
  16098. */
  16099. preWarmCycles: number;
  16100. /**
  16101. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16102. */
  16103. preWarmStepOffset: number;
  16104. /**
  16105. * 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)
  16106. */
  16107. spriteCellChangeSpeed: number;
  16108. /**
  16109. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16110. */
  16111. startSpriteCellID: number;
  16112. /**
  16113. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16114. */
  16115. endSpriteCellID: number;
  16116. /**
  16117. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16118. */
  16119. spriteCellWidth: number;
  16120. /**
  16121. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16122. */
  16123. spriteCellHeight: number;
  16124. /**
  16125. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16126. */
  16127. spriteRandomStartCell: boolean;
  16128. /**
  16129. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16130. */
  16131. isAnimationSheetEnabled: boolean;
  16132. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16133. translationPivot: Vector2;
  16134. /**
  16135. * Gets or sets a texture used to add random noise to particle positions
  16136. */
  16137. noiseTexture: Nullable<BaseTexture>;
  16138. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16139. noiseStrength: Vector3;
  16140. /**
  16141. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16142. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16143. */
  16144. billboardMode: number;
  16145. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16146. limitVelocityDamping: number;
  16147. /**
  16148. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16149. */
  16150. beginAnimationOnStart: boolean;
  16151. /**
  16152. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16153. */
  16154. beginAnimationFrom: number;
  16155. /**
  16156. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16157. */
  16158. beginAnimationTo: number;
  16159. /**
  16160. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16161. */
  16162. beginAnimationLoop: boolean;
  16163. /**
  16164. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16165. */
  16166. disposeOnStop: boolean;
  16167. /**
  16168. * Gets the maximum number of particles active at the same time.
  16169. * @returns The max number of active particles.
  16170. */
  16171. getCapacity(): number;
  16172. /**
  16173. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16174. * @returns True if it has been started, otherwise false.
  16175. */
  16176. isStarted(): boolean;
  16177. /**
  16178. * Animates the particle system for this frame.
  16179. */
  16180. animate(): void;
  16181. /**
  16182. * Renders the particle system in its current state.
  16183. * @returns the current number of particles
  16184. */
  16185. render(): number;
  16186. /**
  16187. * Dispose the particle system and frees its associated resources.
  16188. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16189. */
  16190. dispose(disposeTexture?: boolean): void;
  16191. /**
  16192. * Clones the particle system.
  16193. * @param name The name of the cloned object
  16194. * @param newEmitter The new emitter to use
  16195. * @returns the cloned particle system
  16196. */
  16197. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16198. /**
  16199. * Serializes the particle system to a JSON object.
  16200. * @returns the JSON object
  16201. */
  16202. serialize(): any;
  16203. /**
  16204. * Rebuild the particle system
  16205. */
  16206. rebuild(): void;
  16207. /**
  16208. * Starts the particle system and begins to emit
  16209. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16210. */
  16211. start(delay?: number): void;
  16212. /**
  16213. * Stops the particle system.
  16214. */
  16215. stop(): void;
  16216. /**
  16217. * Remove all active particles
  16218. */
  16219. reset(): void;
  16220. /**
  16221. * Is this system ready to be used/rendered
  16222. * @return true if the system is ready
  16223. */
  16224. isReady(): boolean;
  16225. /**
  16226. * Adds a new color gradient
  16227. * @param gradient defines the gradient to use (between 0 and 1)
  16228. * @param color1 defines the color to affect to the specified gradient
  16229. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16230. * @returns the current particle system
  16231. */
  16232. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16233. /**
  16234. * Remove a specific color gradient
  16235. * @param gradient defines the gradient to remove
  16236. * @returns the current particle system
  16237. */
  16238. removeColorGradient(gradient: number): IParticleSystem;
  16239. /**
  16240. * Adds a new size gradient
  16241. * @param gradient defines the gradient to use (between 0 and 1)
  16242. * @param factor defines the size factor to affect to the specified gradient
  16243. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16244. * @returns the current particle system
  16245. */
  16246. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16247. /**
  16248. * Remove a specific size gradient
  16249. * @param gradient defines the gradient to remove
  16250. * @returns the current particle system
  16251. */
  16252. removeSizeGradient(gradient: number): IParticleSystem;
  16253. /**
  16254. * Gets the current list of color gradients.
  16255. * You must use addColorGradient and removeColorGradient to udpate this list
  16256. * @returns the list of color gradients
  16257. */
  16258. getColorGradients(): Nullable<Array<ColorGradient>>;
  16259. /**
  16260. * Gets the current list of size gradients.
  16261. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16262. * @returns the list of size gradients
  16263. */
  16264. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16265. /**
  16266. * Gets the current list of angular speed gradients.
  16267. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16268. * @returns the list of angular speed gradients
  16269. */
  16270. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16271. /**
  16272. * Adds a new angular speed gradient
  16273. * @param gradient defines the gradient to use (between 0 and 1)
  16274. * @param factor defines the angular speed to affect to the specified gradient
  16275. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16276. * @returns the current particle system
  16277. */
  16278. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16279. /**
  16280. * Remove a specific angular speed gradient
  16281. * @param gradient defines the gradient to remove
  16282. * @returns the current particle system
  16283. */
  16284. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16285. /**
  16286. * Gets the current list of velocity gradients.
  16287. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16288. * @returns the list of velocity gradients
  16289. */
  16290. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16291. /**
  16292. * Adds a new velocity gradient
  16293. * @param gradient defines the gradient to use (between 0 and 1)
  16294. * @param factor defines the velocity to affect to the specified gradient
  16295. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16296. * @returns the current particle system
  16297. */
  16298. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16299. /**
  16300. * Remove a specific velocity gradient
  16301. * @param gradient defines the gradient to remove
  16302. * @returns the current particle system
  16303. */
  16304. removeVelocityGradient(gradient: number): IParticleSystem;
  16305. /**
  16306. * Gets the current list of limit velocity gradients.
  16307. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16308. * @returns the list of limit velocity gradients
  16309. */
  16310. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16311. /**
  16312. * Adds a new limit velocity gradient
  16313. * @param gradient defines the gradient to use (between 0 and 1)
  16314. * @param factor defines the limit velocity to affect to the specified gradient
  16315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16316. * @returns the current particle system
  16317. */
  16318. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16319. /**
  16320. * Remove a specific limit velocity gradient
  16321. * @param gradient defines the gradient to remove
  16322. * @returns the current particle system
  16323. */
  16324. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16325. /**
  16326. * Adds a new drag gradient
  16327. * @param gradient defines the gradient to use (between 0 and 1)
  16328. * @param factor defines the drag to affect to the specified gradient
  16329. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16330. * @returns the current particle system
  16331. */
  16332. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16333. /**
  16334. * Remove a specific drag gradient
  16335. * @param gradient defines the gradient to remove
  16336. * @returns the current particle system
  16337. */
  16338. removeDragGradient(gradient: number): IParticleSystem;
  16339. /**
  16340. * Gets the current list of drag gradients.
  16341. * You must use addDragGradient and removeDragGradient to udpate this list
  16342. * @returns the list of drag gradients
  16343. */
  16344. getDragGradients(): Nullable<Array<FactorGradient>>;
  16345. /**
  16346. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16347. * @param gradient defines the gradient to use (between 0 and 1)
  16348. * @param factor defines the emit rate to affect to the specified gradient
  16349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16350. * @returns the current particle system
  16351. */
  16352. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16353. /**
  16354. * Remove a specific emit rate gradient
  16355. * @param gradient defines the gradient to remove
  16356. * @returns the current particle system
  16357. */
  16358. removeEmitRateGradient(gradient: number): IParticleSystem;
  16359. /**
  16360. * Gets the current list of emit rate gradients.
  16361. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16362. * @returns the list of emit rate gradients
  16363. */
  16364. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16365. /**
  16366. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16367. * @param gradient defines the gradient to use (between 0 and 1)
  16368. * @param factor defines the start size to affect to the specified gradient
  16369. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16370. * @returns the current particle system
  16371. */
  16372. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16373. /**
  16374. * Remove a specific start size gradient
  16375. * @param gradient defines the gradient to remove
  16376. * @returns the current particle system
  16377. */
  16378. removeStartSizeGradient(gradient: number): IParticleSystem;
  16379. /**
  16380. * Gets the current list of start size gradients.
  16381. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16382. * @returns the list of start size gradients
  16383. */
  16384. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16385. /**
  16386. * Adds a new life time gradient
  16387. * @param gradient defines the gradient to use (between 0 and 1)
  16388. * @param factor defines the life time factor to affect to the specified gradient
  16389. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16390. * @returns the current particle system
  16391. */
  16392. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16393. /**
  16394. * Remove a specific life time gradient
  16395. * @param gradient defines the gradient to remove
  16396. * @returns the current particle system
  16397. */
  16398. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16399. /**
  16400. * Gets the current list of life time gradients.
  16401. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16402. * @returns the list of life time gradients
  16403. */
  16404. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16405. /**
  16406. * Gets the current list of color gradients.
  16407. * You must use addColorGradient and removeColorGradient to udpate this list
  16408. * @returns the list of color gradients
  16409. */
  16410. getColorGradients(): Nullable<Array<ColorGradient>>;
  16411. /**
  16412. * Adds a new ramp gradient used to remap particle colors
  16413. * @param gradient defines the gradient to use (between 0 and 1)
  16414. * @param color defines the color to affect to the specified gradient
  16415. * @returns the current particle system
  16416. */
  16417. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16418. /**
  16419. * Gets the current list of ramp gradients.
  16420. * You must use addRampGradient and removeRampGradient to udpate this list
  16421. * @returns the list of ramp gradients
  16422. */
  16423. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16424. /** Gets or sets a boolean indicating that ramp gradients must be used
  16425. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16426. */
  16427. useRampGradients: boolean;
  16428. /**
  16429. * Adds a new color remap gradient
  16430. * @param gradient defines the gradient to use (between 0 and 1)
  16431. * @param min defines the color remap minimal range
  16432. * @param max defines the color remap maximal range
  16433. * @returns the current particle system
  16434. */
  16435. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16436. /**
  16437. * Gets the current list of color remap gradients.
  16438. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16439. * @returns the list of color remap gradients
  16440. */
  16441. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16442. /**
  16443. * Adds a new alpha remap gradient
  16444. * @param gradient defines the gradient to use (between 0 and 1)
  16445. * @param min defines the alpha remap minimal range
  16446. * @param max defines the alpha remap maximal range
  16447. * @returns the current particle system
  16448. */
  16449. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16450. /**
  16451. * Gets the current list of alpha remap gradients.
  16452. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16453. * @returns the list of alpha remap gradients
  16454. */
  16455. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16456. /**
  16457. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16458. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16459. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16460. * @returns the emitter
  16461. */
  16462. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16463. /**
  16464. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16465. * @param radius The radius of the hemisphere to emit from
  16466. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16467. * @returns the emitter
  16468. */
  16469. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16470. /**
  16471. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16472. * @param radius The radius of the sphere to emit from
  16473. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16474. * @returns the emitter
  16475. */
  16476. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16477. /**
  16478. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16479. * @param radius The radius of the sphere to emit from
  16480. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16481. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16482. * @returns the emitter
  16483. */
  16484. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16485. /**
  16486. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16487. * @param radius The radius of the emission cylinder
  16488. * @param height The height of the emission cylinder
  16489. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16490. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16491. * @returns the emitter
  16492. */
  16493. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16494. /**
  16495. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16496. * @param radius The radius of the cylinder to emit from
  16497. * @param height The height of the emission cylinder
  16498. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16499. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16500. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16501. * @returns the emitter
  16502. */
  16503. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16504. /**
  16505. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16506. * @param radius The radius of the cone to emit from
  16507. * @param angle The base angle of the cone
  16508. * @returns the emitter
  16509. */
  16510. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16511. /**
  16512. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16513. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16514. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16515. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16516. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16517. * @returns the emitter
  16518. */
  16519. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16520. /**
  16521. * Get hosting scene
  16522. * @returns the scene
  16523. */
  16524. getScene(): Scene;
  16525. }
  16526. }
  16527. declare module "babylonjs/Meshes/instancedMesh" {
  16528. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16529. import { Vector3 } from "babylonjs/Maths/math";
  16530. import { Camera } from "babylonjs/Cameras/camera";
  16531. import { Node } from "babylonjs/node";
  16532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16533. import { Mesh } from "babylonjs/Meshes/mesh";
  16534. import { Material } from "babylonjs/Materials/material";
  16535. import { Skeleton } from "babylonjs/Bones/skeleton";
  16536. /**
  16537. * Creates an instance based on a source mesh.
  16538. */
  16539. export class InstancedMesh extends AbstractMesh {
  16540. private _sourceMesh;
  16541. private _currentLOD;
  16542. /** @hidden */
  16543. _indexInSourceMeshInstanceArray: number;
  16544. constructor(name: string, source: Mesh);
  16545. /**
  16546. * Returns the string "InstancedMesh".
  16547. */
  16548. getClassName(): string;
  16549. /**
  16550. * If the source mesh receives shadows
  16551. */
  16552. readonly receiveShadows: boolean;
  16553. /**
  16554. * The material of the source mesh
  16555. */
  16556. readonly material: Nullable<Material>;
  16557. /**
  16558. * Visibility of the source mesh
  16559. */
  16560. readonly visibility: number;
  16561. /**
  16562. * Skeleton of the source mesh
  16563. */
  16564. readonly skeleton: Nullable<Skeleton>;
  16565. /**
  16566. * Rendering ground id of the source mesh
  16567. */
  16568. renderingGroupId: number;
  16569. /**
  16570. * Returns the total number of vertices (integer).
  16571. */
  16572. getTotalVertices(): number;
  16573. /**
  16574. * Returns a positive integer : the total number of indices in this mesh geometry.
  16575. * @returns the numner of indices or zero if the mesh has no geometry.
  16576. */
  16577. getTotalIndices(): number;
  16578. /**
  16579. * The source mesh of the instance
  16580. */
  16581. readonly sourceMesh: Mesh;
  16582. /**
  16583. * Is this node ready to be used/rendered
  16584. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16585. * @return {boolean} is it ready
  16586. */
  16587. isReady(completeCheck?: boolean): boolean;
  16588. /**
  16589. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16590. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16591. * @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.
  16592. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16593. */
  16594. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16595. /**
  16596. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16597. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16598. * The `data` are either a numeric array either a Float32Array.
  16599. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16600. * 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).
  16601. * Note that a new underlying VertexBuffer object is created each call.
  16602. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16603. *
  16604. * Possible `kind` values :
  16605. * - VertexBuffer.PositionKind
  16606. * - VertexBuffer.UVKind
  16607. * - VertexBuffer.UV2Kind
  16608. * - VertexBuffer.UV3Kind
  16609. * - VertexBuffer.UV4Kind
  16610. * - VertexBuffer.UV5Kind
  16611. * - VertexBuffer.UV6Kind
  16612. * - VertexBuffer.ColorKind
  16613. * - VertexBuffer.MatricesIndicesKind
  16614. * - VertexBuffer.MatricesIndicesExtraKind
  16615. * - VertexBuffer.MatricesWeightsKind
  16616. * - VertexBuffer.MatricesWeightsExtraKind
  16617. *
  16618. * Returns the Mesh.
  16619. */
  16620. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16621. /**
  16622. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16623. * If the mesh has no geometry, it is simply returned as it is.
  16624. * The `data` are either a numeric array either a Float32Array.
  16625. * No new underlying VertexBuffer object is created.
  16626. * 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.
  16627. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16628. *
  16629. * Possible `kind` values :
  16630. * - VertexBuffer.PositionKind
  16631. * - VertexBuffer.UVKind
  16632. * - VertexBuffer.UV2Kind
  16633. * - VertexBuffer.UV3Kind
  16634. * - VertexBuffer.UV4Kind
  16635. * - VertexBuffer.UV5Kind
  16636. * - VertexBuffer.UV6Kind
  16637. * - VertexBuffer.ColorKind
  16638. * - VertexBuffer.MatricesIndicesKind
  16639. * - VertexBuffer.MatricesIndicesExtraKind
  16640. * - VertexBuffer.MatricesWeightsKind
  16641. * - VertexBuffer.MatricesWeightsExtraKind
  16642. *
  16643. * Returns the Mesh.
  16644. */
  16645. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16646. /**
  16647. * Sets the mesh indices.
  16648. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16649. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16650. * This method creates a new index buffer each call.
  16651. * Returns the Mesh.
  16652. */
  16653. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16654. /**
  16655. * Boolean : True if the mesh owns the requested kind of data.
  16656. */
  16657. isVerticesDataPresent(kind: string): boolean;
  16658. /**
  16659. * Returns an array of indices (IndicesArray).
  16660. */
  16661. getIndices(): Nullable<IndicesArray>;
  16662. readonly _positions: Nullable<Vector3[]>;
  16663. /**
  16664. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16665. * This means the mesh underlying bounding box and sphere are recomputed.
  16666. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16667. * @returns the current mesh
  16668. */
  16669. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16670. /** @hidden */
  16671. _preActivate(): InstancedMesh;
  16672. /** @hidden */
  16673. _activate(renderId: number): InstancedMesh;
  16674. /**
  16675. * Returns the current associated LOD AbstractMesh.
  16676. */
  16677. getLOD(camera: Camera): AbstractMesh;
  16678. /** @hidden */
  16679. _syncSubMeshes(): InstancedMesh;
  16680. /** @hidden */
  16681. _generatePointsArray(): boolean;
  16682. /**
  16683. * Creates a new InstancedMesh from the current mesh.
  16684. * - name (string) : the cloned mesh name
  16685. * - newParent (optional Node) : the optional Node to parent the clone to.
  16686. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16687. *
  16688. * Returns the clone.
  16689. */
  16690. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16691. /**
  16692. * Disposes the InstancedMesh.
  16693. * Returns nothing.
  16694. */
  16695. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16696. }
  16697. }
  16698. declare module "babylonjs/Materials/shaderMaterial" {
  16699. import { Scene } from "babylonjs/scene";
  16700. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16702. import { Mesh } from "babylonjs/Meshes/mesh";
  16703. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16704. import { Texture } from "babylonjs/Materials/Textures/texture";
  16705. import { Material } from "babylonjs/Materials/material";
  16706. /**
  16707. * Defines the options associated with the creation of a shader material.
  16708. */
  16709. export interface IShaderMaterialOptions {
  16710. /**
  16711. * Does the material work in alpha blend mode
  16712. */
  16713. needAlphaBlending: boolean;
  16714. /**
  16715. * Does the material work in alpha test mode
  16716. */
  16717. needAlphaTesting: boolean;
  16718. /**
  16719. * The list of attribute names used in the shader
  16720. */
  16721. attributes: string[];
  16722. /**
  16723. * The list of unifrom names used in the shader
  16724. */
  16725. uniforms: string[];
  16726. /**
  16727. * The list of UBO names used in the shader
  16728. */
  16729. uniformBuffers: string[];
  16730. /**
  16731. * The list of sampler names used in the shader
  16732. */
  16733. samplers: string[];
  16734. /**
  16735. * The list of defines used in the shader
  16736. */
  16737. defines: string[];
  16738. }
  16739. /**
  16740. * 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.
  16741. *
  16742. * This returned material effects how the mesh will look based on the code in the shaders.
  16743. *
  16744. * @see http://doc.babylonjs.com/how_to/shader_material
  16745. */
  16746. export class ShaderMaterial extends Material {
  16747. private _shaderPath;
  16748. private _options;
  16749. private _textures;
  16750. private _textureArrays;
  16751. private _floats;
  16752. private _ints;
  16753. private _floatsArrays;
  16754. private _colors3;
  16755. private _colors3Arrays;
  16756. private _colors4;
  16757. private _vectors2;
  16758. private _vectors3;
  16759. private _vectors4;
  16760. private _matrices;
  16761. private _matrices3x3;
  16762. private _matrices2x2;
  16763. private _vectors2Arrays;
  16764. private _vectors3Arrays;
  16765. private _cachedWorldViewMatrix;
  16766. private _renderId;
  16767. /**
  16768. * Instantiate a new shader material.
  16769. * 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.
  16770. * This returned material effects how the mesh will look based on the code in the shaders.
  16771. * @see http://doc.babylonjs.com/how_to/shader_material
  16772. * @param name Define the name of the material in the scene
  16773. * @param scene Define the scene the material belongs to
  16774. * @param shaderPath Defines the route to the shader code in one of three ways:
  16775. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16776. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16777. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16778. * @param options Define the options used to create the shader
  16779. */
  16780. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16781. /**
  16782. * Gets the current class name of the material e.g. "ShaderMaterial"
  16783. * Mainly use in serialization.
  16784. * @returns the class name
  16785. */
  16786. getClassName(): string;
  16787. /**
  16788. * Specifies if the material will require alpha blending
  16789. * @returns a boolean specifying if alpha blending is needed
  16790. */
  16791. needAlphaBlending(): boolean;
  16792. /**
  16793. * Specifies if this material should be rendered in alpha test mode
  16794. * @returns a boolean specifying if an alpha test is needed.
  16795. */
  16796. needAlphaTesting(): boolean;
  16797. private _checkUniform;
  16798. /**
  16799. * Set a texture in the shader.
  16800. * @param name Define the name of the uniform samplers as defined in the shader
  16801. * @param texture Define the texture to bind to this sampler
  16802. * @return the material itself allowing "fluent" like uniform updates
  16803. */
  16804. setTexture(name: string, texture: Texture): ShaderMaterial;
  16805. /**
  16806. * Set a texture array in the shader.
  16807. * @param name Define the name of the uniform sampler array as defined in the shader
  16808. * @param textures Define the list of textures to bind to this sampler
  16809. * @return the material itself allowing "fluent" like uniform updates
  16810. */
  16811. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16812. /**
  16813. * Set a float in the shader.
  16814. * @param name Define the name of the uniform as defined in the shader
  16815. * @param value Define the value to give to the uniform
  16816. * @return the material itself allowing "fluent" like uniform updates
  16817. */
  16818. setFloat(name: string, value: number): ShaderMaterial;
  16819. /**
  16820. * Set a int in the shader.
  16821. * @param name Define the name of the uniform as defined in the shader
  16822. * @param value Define the value to give to the uniform
  16823. * @return the material itself allowing "fluent" like uniform updates
  16824. */
  16825. setInt(name: string, value: number): ShaderMaterial;
  16826. /**
  16827. * Set an array of floats in the shader.
  16828. * @param name Define the name of the uniform as defined in the shader
  16829. * @param value Define the value to give to the uniform
  16830. * @return the material itself allowing "fluent" like uniform updates
  16831. */
  16832. setFloats(name: string, value: number[]): ShaderMaterial;
  16833. /**
  16834. * Set a vec3 in the shader from a Color3.
  16835. * @param name Define the name of the uniform as defined in the shader
  16836. * @param value Define the value to give to the uniform
  16837. * @return the material itself allowing "fluent" like uniform updates
  16838. */
  16839. setColor3(name: string, value: Color3): ShaderMaterial;
  16840. /**
  16841. * Set a vec3 array in the shader from a Color3 array.
  16842. * @param name Define the name of the uniform as defined in the shader
  16843. * @param value Define the value to give to the uniform
  16844. * @return the material itself allowing "fluent" like uniform updates
  16845. */
  16846. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16847. /**
  16848. * Set a vec4 in the shader from a Color4.
  16849. * @param name Define the name of the uniform as defined in the shader
  16850. * @param value Define the value to give to the uniform
  16851. * @return the material itself allowing "fluent" like uniform updates
  16852. */
  16853. setColor4(name: string, value: Color4): ShaderMaterial;
  16854. /**
  16855. * Set a vec2 in the shader from a Vector2.
  16856. * @param name Define the name of the uniform as defined in the shader
  16857. * @param value Define the value to give to the uniform
  16858. * @return the material itself allowing "fluent" like uniform updates
  16859. */
  16860. setVector2(name: string, value: Vector2): ShaderMaterial;
  16861. /**
  16862. * Set a vec3 in the shader from a Vector3.
  16863. * @param name Define the name of the uniform as defined in the shader
  16864. * @param value Define the value to give to the uniform
  16865. * @return the material itself allowing "fluent" like uniform updates
  16866. */
  16867. setVector3(name: string, value: Vector3): ShaderMaterial;
  16868. /**
  16869. * Set a vec4 in the shader from a Vector4.
  16870. * @param name Define the name of the uniform as defined in the shader
  16871. * @param value Define the value to give to the uniform
  16872. * @return the material itself allowing "fluent" like uniform updates
  16873. */
  16874. setVector4(name: string, value: Vector4): ShaderMaterial;
  16875. /**
  16876. * Set a mat4 in the shader from a Matrix.
  16877. * @param name Define the name of the uniform as defined in the shader
  16878. * @param value Define the value to give to the uniform
  16879. * @return the material itself allowing "fluent" like uniform updates
  16880. */
  16881. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16882. /**
  16883. * Set a mat3 in the shader from a Float32Array.
  16884. * @param name Define the name of the uniform as defined in the shader
  16885. * @param value Define the value to give to the uniform
  16886. * @return the material itself allowing "fluent" like uniform updates
  16887. */
  16888. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16889. /**
  16890. * Set a mat2 in the shader from a Float32Array.
  16891. * @param name Define the name of the uniform as defined in the shader
  16892. * @param value Define the value to give to the uniform
  16893. * @return the material itself allowing "fluent" like uniform updates
  16894. */
  16895. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16896. /**
  16897. * Set a vec2 array in the shader from a number array.
  16898. * @param name Define the name of the uniform as defined in the shader
  16899. * @param value Define the value to give to the uniform
  16900. * @return the material itself allowing "fluent" like uniform updates
  16901. */
  16902. setArray2(name: string, value: number[]): ShaderMaterial;
  16903. /**
  16904. * Set a vec3 array in the shader from a number array.
  16905. * @param name Define the name of the uniform as defined in the shader
  16906. * @param value Define the value to give to the uniform
  16907. * @return the material itself allowing "fluent" like uniform updates
  16908. */
  16909. setArray3(name: string, value: number[]): ShaderMaterial;
  16910. private _checkCache;
  16911. /**
  16912. * Checks if the material is ready to render the requested mesh
  16913. * @param mesh Define the mesh to render
  16914. * @param useInstances Define whether or not the material is used with instances
  16915. * @returns true if ready, otherwise false
  16916. */
  16917. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16918. /**
  16919. * Binds the world matrix to the material
  16920. * @param world defines the world transformation matrix
  16921. */
  16922. bindOnlyWorldMatrix(world: Matrix): void;
  16923. /**
  16924. * Binds the material to the mesh
  16925. * @param world defines the world transformation matrix
  16926. * @param mesh defines the mesh to bind the material to
  16927. */
  16928. bind(world: Matrix, mesh?: Mesh): void;
  16929. /**
  16930. * Gets the active textures from the material
  16931. * @returns an array of textures
  16932. */
  16933. getActiveTextures(): BaseTexture[];
  16934. /**
  16935. * Specifies if the material uses a texture
  16936. * @param texture defines the texture to check against the material
  16937. * @returns a boolean specifying if the material uses the texture
  16938. */
  16939. hasTexture(texture: BaseTexture): boolean;
  16940. /**
  16941. * Makes a duplicate of the material, and gives it a new name
  16942. * @param name defines the new name for the duplicated material
  16943. * @returns the cloned material
  16944. */
  16945. clone(name: string): ShaderMaterial;
  16946. /**
  16947. * Disposes the material
  16948. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16949. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16950. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16951. */
  16952. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16953. /**
  16954. * Serializes this material in a JSON representation
  16955. * @returns the serialized material object
  16956. */
  16957. serialize(): any;
  16958. /**
  16959. * Creates a shader material from parsed shader material data
  16960. * @param source defines the JSON represnetation of the material
  16961. * @param scene defines the hosting scene
  16962. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16963. * @returns a new material
  16964. */
  16965. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16966. }
  16967. }
  16968. declare module "babylonjs/Shaders/color.fragment" {
  16969. /** @hidden */
  16970. export var colorPixelShader: {
  16971. name: string;
  16972. shader: string;
  16973. };
  16974. }
  16975. declare module "babylonjs/Shaders/color.vertex" {
  16976. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16977. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16978. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16979. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16980. /** @hidden */
  16981. export var colorVertexShader: {
  16982. name: string;
  16983. shader: string;
  16984. };
  16985. }
  16986. declare module "babylonjs/Meshes/linesMesh" {
  16987. import { Nullable } from "babylonjs/types";
  16988. import { Scene } from "babylonjs/scene";
  16989. import { Color3 } from "babylonjs/Maths/math";
  16990. import { Node } from "babylonjs/node";
  16991. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16992. import { Mesh } from "babylonjs/Meshes/mesh";
  16993. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16994. import { Effect } from "babylonjs/Materials/effect";
  16995. import { Material } from "babylonjs/Materials/material";
  16996. import "babylonjs/Shaders/color.fragment";
  16997. import "babylonjs/Shaders/color.vertex";
  16998. /**
  16999. * Line mesh
  17000. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17001. */
  17002. export class LinesMesh extends Mesh {
  17003. /**
  17004. * If vertex color should be applied to the mesh
  17005. */
  17006. useVertexColor?: boolean | undefined;
  17007. /**
  17008. * If vertex alpha should be applied to the mesh
  17009. */
  17010. useVertexAlpha?: boolean | undefined;
  17011. /**
  17012. * Color of the line (Default: White)
  17013. */
  17014. color: Color3;
  17015. /**
  17016. * Alpha of the line (Default: 1)
  17017. */
  17018. alpha: number;
  17019. /**
  17020. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17021. * This margin is expressed in world space coordinates, so its value may vary.
  17022. * Default value is 0.1
  17023. */
  17024. intersectionThreshold: number;
  17025. private _colorShader;
  17026. /**
  17027. * Creates a new LinesMesh
  17028. * @param name defines the name
  17029. * @param scene defines the hosting scene
  17030. * @param parent defines the parent mesh if any
  17031. * @param source defines the optional source LinesMesh used to clone data from
  17032. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17033. * When false, achieved by calling a clone(), also passing False.
  17034. * This will make creation of children, recursive.
  17035. * @param useVertexColor defines if this LinesMesh supports vertex color
  17036. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17037. */
  17038. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17039. /**
  17040. * If vertex color should be applied to the mesh
  17041. */
  17042. useVertexColor?: boolean | undefined,
  17043. /**
  17044. * If vertex alpha should be applied to the mesh
  17045. */
  17046. useVertexAlpha?: boolean | undefined);
  17047. /**
  17048. * Returns the string "LineMesh"
  17049. */
  17050. getClassName(): string;
  17051. /**
  17052. * @hidden
  17053. */
  17054. /**
  17055. * @hidden
  17056. */
  17057. material: Material;
  17058. /**
  17059. * @hidden
  17060. */
  17061. readonly checkCollisions: boolean;
  17062. /** @hidden */
  17063. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17064. /** @hidden */
  17065. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17066. /**
  17067. * Disposes of the line mesh
  17068. * @param doNotRecurse If children should be disposed
  17069. */
  17070. dispose(doNotRecurse?: boolean): void;
  17071. /**
  17072. * Returns a new LineMesh object cloned from the current one.
  17073. */
  17074. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17075. /**
  17076. * Creates a new InstancedLinesMesh object from the mesh model.
  17077. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17078. * @param name defines the name of the new instance
  17079. * @returns a new InstancedLinesMesh
  17080. */
  17081. createInstance(name: string): InstancedLinesMesh;
  17082. }
  17083. /**
  17084. * Creates an instance based on a source LinesMesh
  17085. */
  17086. export class InstancedLinesMesh extends InstancedMesh {
  17087. /**
  17088. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17089. * This margin is expressed in world space coordinates, so its value may vary.
  17090. * Initilized with the intersectionThreshold value of the source LinesMesh
  17091. */
  17092. intersectionThreshold: number;
  17093. constructor(name: string, source: LinesMesh);
  17094. /**
  17095. * Returns the string "InstancedLinesMesh".
  17096. */
  17097. getClassName(): string;
  17098. }
  17099. }
  17100. declare module "babylonjs/Shaders/line.fragment" {
  17101. /** @hidden */
  17102. export var linePixelShader: {
  17103. name: string;
  17104. shader: string;
  17105. };
  17106. }
  17107. declare module "babylonjs/Shaders/line.vertex" {
  17108. /** @hidden */
  17109. export var lineVertexShader: {
  17110. name: string;
  17111. shader: string;
  17112. };
  17113. }
  17114. declare module "babylonjs/Rendering/edgesRenderer" {
  17115. import { Nullable } from "babylonjs/types";
  17116. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17118. import { Vector3 } from "babylonjs/Maths/math";
  17119. import { IDisposable } from "babylonjs/scene";
  17120. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17121. import "babylonjs/Shaders/line.fragment";
  17122. import "babylonjs/Shaders/line.vertex";
  17123. module "babylonjs/Meshes/abstractMesh" {
  17124. interface AbstractMesh {
  17125. /**
  17126. * Disables the mesh edge rendering mode
  17127. * @returns the currentAbstractMesh
  17128. */
  17129. disableEdgesRendering(): AbstractMesh;
  17130. /**
  17131. * Enables the edge rendering mode on the mesh.
  17132. * This mode makes the mesh edges visible
  17133. * @param epsilon defines the maximal distance between two angles to detect a face
  17134. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17135. * @returns the currentAbstractMesh
  17136. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17137. */
  17138. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17139. /**
  17140. * Gets the edgesRenderer associated with the mesh
  17141. */
  17142. edgesRenderer: Nullable<EdgesRenderer>;
  17143. }
  17144. }
  17145. module "babylonjs/Meshes/linesMesh" {
  17146. interface LinesMesh {
  17147. /**
  17148. * Enables the edge rendering mode on the mesh.
  17149. * This mode makes the mesh edges visible
  17150. * @param epsilon defines the maximal distance between two angles to detect a face
  17151. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17152. * @returns the currentAbstractMesh
  17153. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17154. */
  17155. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17156. }
  17157. }
  17158. module "babylonjs/Meshes/linesMesh" {
  17159. interface InstancedLinesMesh {
  17160. /**
  17161. * Enables the edge rendering mode on the mesh.
  17162. * This mode makes the mesh edges visible
  17163. * @param epsilon defines the maximal distance between two angles to detect a face
  17164. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17165. * @returns the current InstancedLinesMesh
  17166. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17167. */
  17168. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17169. }
  17170. }
  17171. /**
  17172. * Defines the minimum contract an Edges renderer should follow.
  17173. */
  17174. export interface IEdgesRenderer extends IDisposable {
  17175. /**
  17176. * Gets or sets a boolean indicating if the edgesRenderer is active
  17177. */
  17178. isEnabled: boolean;
  17179. /**
  17180. * Renders the edges of the attached mesh,
  17181. */
  17182. render(): void;
  17183. /**
  17184. * Checks wether or not the edges renderer is ready to render.
  17185. * @return true if ready, otherwise false.
  17186. */
  17187. isReady(): boolean;
  17188. }
  17189. /**
  17190. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17191. */
  17192. export class EdgesRenderer implements IEdgesRenderer {
  17193. /**
  17194. * Define the size of the edges with an orthographic camera
  17195. */
  17196. edgesWidthScalerForOrthographic: number;
  17197. /**
  17198. * Define the size of the edges with a perspective camera
  17199. */
  17200. edgesWidthScalerForPerspective: number;
  17201. protected _source: AbstractMesh;
  17202. protected _linesPositions: number[];
  17203. protected _linesNormals: number[];
  17204. protected _linesIndices: number[];
  17205. protected _epsilon: number;
  17206. protected _indicesCount: number;
  17207. protected _lineShader: ShaderMaterial;
  17208. protected _ib: WebGLBuffer;
  17209. protected _buffers: {
  17210. [key: string]: Nullable<VertexBuffer>;
  17211. };
  17212. protected _checkVerticesInsteadOfIndices: boolean;
  17213. private _meshRebuildObserver;
  17214. private _meshDisposeObserver;
  17215. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17216. isEnabled: boolean;
  17217. /**
  17218. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17219. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17220. * @param source Mesh used to create edges
  17221. * @param epsilon sum of angles in adjacency to check for edge
  17222. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17223. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17224. */
  17225. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17226. protected _prepareRessources(): void;
  17227. /** @hidden */
  17228. _rebuild(): void;
  17229. /**
  17230. * Releases the required resources for the edges renderer
  17231. */
  17232. dispose(): void;
  17233. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17234. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17235. /**
  17236. * Checks if the pair of p0 and p1 is en edge
  17237. * @param faceIndex
  17238. * @param edge
  17239. * @param faceNormals
  17240. * @param p0
  17241. * @param p1
  17242. * @private
  17243. */
  17244. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17245. /**
  17246. * push line into the position, normal and index buffer
  17247. * @protected
  17248. */
  17249. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17250. /**
  17251. * Generates lines edges from adjacencjes
  17252. * @private
  17253. */
  17254. _generateEdgesLines(): void;
  17255. /**
  17256. * Checks wether or not the edges renderer is ready to render.
  17257. * @return true if ready, otherwise false.
  17258. */
  17259. isReady(): boolean;
  17260. /**
  17261. * Renders the edges of the attached mesh,
  17262. */
  17263. render(): void;
  17264. }
  17265. /**
  17266. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17267. */
  17268. export class LineEdgesRenderer extends EdgesRenderer {
  17269. /**
  17270. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17271. * @param source LineMesh used to generate edges
  17272. * @param epsilon not important (specified angle for edge detection)
  17273. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17274. */
  17275. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17276. /**
  17277. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17278. */
  17279. _generateEdgesLines(): void;
  17280. }
  17281. }
  17282. declare module "babylonjs/Rendering/renderingGroup" {
  17283. import { SmartArray } from "babylonjs/Misc/smartArray";
  17284. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17286. import { Nullable } from "babylonjs/types";
  17287. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17288. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17289. import { Material } from "babylonjs/Materials/material";
  17290. import { Scene } from "babylonjs/scene";
  17291. /**
  17292. * This represents the object necessary to create a rendering group.
  17293. * This is exclusively used and created by the rendering manager.
  17294. * To modify the behavior, you use the available helpers in your scene or meshes.
  17295. * @hidden
  17296. */
  17297. export class RenderingGroup {
  17298. index: number;
  17299. private _scene;
  17300. private _opaqueSubMeshes;
  17301. private _transparentSubMeshes;
  17302. private _alphaTestSubMeshes;
  17303. private _depthOnlySubMeshes;
  17304. private _particleSystems;
  17305. private _spriteManagers;
  17306. private _opaqueSortCompareFn;
  17307. private _alphaTestSortCompareFn;
  17308. private _transparentSortCompareFn;
  17309. private _renderOpaque;
  17310. private _renderAlphaTest;
  17311. private _renderTransparent;
  17312. private _edgesRenderers;
  17313. onBeforeTransparentRendering: () => void;
  17314. /**
  17315. * Set the opaque sort comparison function.
  17316. * If null the sub meshes will be render in the order they were created
  17317. */
  17318. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17319. /**
  17320. * Set the alpha test sort comparison function.
  17321. * If null the sub meshes will be render in the order they were created
  17322. */
  17323. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17324. /**
  17325. * Set the transparent sort comparison function.
  17326. * If null the sub meshes will be render in the order they were created
  17327. */
  17328. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17329. /**
  17330. * Creates a new rendering group.
  17331. * @param index The rendering group index
  17332. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17333. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17334. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17335. */
  17336. 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>);
  17337. /**
  17338. * Render all the sub meshes contained in the group.
  17339. * @param customRenderFunction Used to override the default render behaviour of the group.
  17340. * @returns true if rendered some submeshes.
  17341. */
  17342. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17343. /**
  17344. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17345. * @param subMeshes The submeshes to render
  17346. */
  17347. private renderOpaqueSorted;
  17348. /**
  17349. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17350. * @param subMeshes The submeshes to render
  17351. */
  17352. private renderAlphaTestSorted;
  17353. /**
  17354. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17355. * @param subMeshes The submeshes to render
  17356. */
  17357. private renderTransparentSorted;
  17358. /**
  17359. * Renders the submeshes in a specified order.
  17360. * @param subMeshes The submeshes to sort before render
  17361. * @param sortCompareFn The comparison function use to sort
  17362. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17363. * @param transparent Specifies to activate blending if true
  17364. */
  17365. private static renderSorted;
  17366. /**
  17367. * Renders the submeshes in the order they were dispatched (no sort applied).
  17368. * @param subMeshes The submeshes to render
  17369. */
  17370. private static renderUnsorted;
  17371. /**
  17372. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17373. * are rendered back to front if in the same alpha index.
  17374. *
  17375. * @param a The first submesh
  17376. * @param b The second submesh
  17377. * @returns The result of the comparison
  17378. */
  17379. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17380. /**
  17381. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17382. * are rendered back to front.
  17383. *
  17384. * @param a The first submesh
  17385. * @param b The second submesh
  17386. * @returns The result of the comparison
  17387. */
  17388. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17389. /**
  17390. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17391. * are rendered front to back (prevent overdraw).
  17392. *
  17393. * @param a The first submesh
  17394. * @param b The second submesh
  17395. * @returns The result of the comparison
  17396. */
  17397. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17398. /**
  17399. * Resets the different lists of submeshes to prepare a new frame.
  17400. */
  17401. prepare(): void;
  17402. dispose(): void;
  17403. /**
  17404. * Inserts the submesh in its correct queue depending on its material.
  17405. * @param subMesh The submesh to dispatch
  17406. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17407. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17408. */
  17409. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17410. dispatchSprites(spriteManager: ISpriteManager): void;
  17411. dispatchParticles(particleSystem: IParticleSystem): void;
  17412. private _renderParticles;
  17413. private _renderSprites;
  17414. }
  17415. }
  17416. declare module "babylonjs/Rendering/renderingManager" {
  17417. import { Nullable } from "babylonjs/types";
  17418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17420. import { SmartArray } from "babylonjs/Misc/smartArray";
  17421. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17422. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17423. import { Material } from "babylonjs/Materials/material";
  17424. import { Scene } from "babylonjs/scene";
  17425. import { Camera } from "babylonjs/Cameras/camera";
  17426. /**
  17427. * Interface describing the different options available in the rendering manager
  17428. * regarding Auto Clear between groups.
  17429. */
  17430. export interface IRenderingManagerAutoClearSetup {
  17431. /**
  17432. * Defines whether or not autoclear is enable.
  17433. */
  17434. autoClear: boolean;
  17435. /**
  17436. * Defines whether or not to autoclear the depth buffer.
  17437. */
  17438. depth: boolean;
  17439. /**
  17440. * Defines whether or not to autoclear the stencil buffer.
  17441. */
  17442. stencil: boolean;
  17443. }
  17444. /**
  17445. * This class is used by the onRenderingGroupObservable
  17446. */
  17447. export class RenderingGroupInfo {
  17448. /**
  17449. * The Scene that being rendered
  17450. */
  17451. scene: Scene;
  17452. /**
  17453. * The camera currently used for the rendering pass
  17454. */
  17455. camera: Nullable<Camera>;
  17456. /**
  17457. * The ID of the renderingGroup being processed
  17458. */
  17459. renderingGroupId: number;
  17460. }
  17461. /**
  17462. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17463. * It is enable to manage the different groups as well as the different necessary sort functions.
  17464. * This should not be used directly aside of the few static configurations
  17465. */
  17466. export class RenderingManager {
  17467. /**
  17468. * The max id used for rendering groups (not included)
  17469. */
  17470. static MAX_RENDERINGGROUPS: number;
  17471. /**
  17472. * The min id used for rendering groups (included)
  17473. */
  17474. static MIN_RENDERINGGROUPS: number;
  17475. /**
  17476. * Used to globally prevent autoclearing scenes.
  17477. */
  17478. static AUTOCLEAR: boolean;
  17479. /**
  17480. * @hidden
  17481. */
  17482. _useSceneAutoClearSetup: boolean;
  17483. private _scene;
  17484. private _renderingGroups;
  17485. private _depthStencilBufferAlreadyCleaned;
  17486. private _autoClearDepthStencil;
  17487. private _customOpaqueSortCompareFn;
  17488. private _customAlphaTestSortCompareFn;
  17489. private _customTransparentSortCompareFn;
  17490. private _renderingGroupInfo;
  17491. /**
  17492. * Instantiates a new rendering group for a particular scene
  17493. * @param scene Defines the scene the groups belongs to
  17494. */
  17495. constructor(scene: Scene);
  17496. private _clearDepthStencilBuffer;
  17497. /**
  17498. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17499. * @hidden
  17500. */
  17501. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17502. /**
  17503. * Resets the different information of the group to prepare a new frame
  17504. * @hidden
  17505. */
  17506. reset(): void;
  17507. /**
  17508. * Dispose and release the group and its associated resources.
  17509. * @hidden
  17510. */
  17511. dispose(): void;
  17512. /**
  17513. * Clear the info related to rendering groups preventing retention points during dispose.
  17514. */
  17515. freeRenderingGroups(): void;
  17516. private _prepareRenderingGroup;
  17517. /**
  17518. * Add a sprite manager to the rendering manager in order to render it this frame.
  17519. * @param spriteManager Define the sprite manager to render
  17520. */
  17521. dispatchSprites(spriteManager: ISpriteManager): void;
  17522. /**
  17523. * Add a particle system to the rendering manager in order to render it this frame.
  17524. * @param particleSystem Define the particle system to render
  17525. */
  17526. dispatchParticles(particleSystem: IParticleSystem): void;
  17527. /**
  17528. * Add a submesh to the manager in order to render it this frame
  17529. * @param subMesh The submesh to dispatch
  17530. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17531. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17532. */
  17533. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17534. /**
  17535. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17536. * This allowed control for front to back rendering or reversly depending of the special needs.
  17537. *
  17538. * @param renderingGroupId The rendering group id corresponding to its index
  17539. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17540. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17541. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17542. */
  17543. 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;
  17544. /**
  17545. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17546. *
  17547. * @param renderingGroupId The rendering group id corresponding to its index
  17548. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17549. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17550. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17551. */
  17552. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17553. /**
  17554. * Gets the current auto clear configuration for one rendering group of the rendering
  17555. * manager.
  17556. * @param index the rendering group index to get the information for
  17557. * @returns The auto clear setup for the requested rendering group
  17558. */
  17559. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17560. }
  17561. }
  17562. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17563. import { Observable } from "babylonjs/Misc/observable";
  17564. import { SmartArray } from "babylonjs/Misc/smartArray";
  17565. import { Nullable } from "babylonjs/types";
  17566. import { Camera } from "babylonjs/Cameras/camera";
  17567. import { Scene } from "babylonjs/scene";
  17568. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17569. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17571. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17573. import { Texture } from "babylonjs/Materials/Textures/texture";
  17574. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17575. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17576. import { Engine } from "babylonjs/Engines/engine";
  17577. /**
  17578. * This Helps creating a texture that will be created from a camera in your scene.
  17579. * It is basically a dynamic texture that could be used to create special effects for instance.
  17580. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17581. */
  17582. export class RenderTargetTexture extends Texture {
  17583. isCube: boolean;
  17584. /**
  17585. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17586. */
  17587. static readonly REFRESHRATE_RENDER_ONCE: number;
  17588. /**
  17589. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17590. */
  17591. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17592. /**
  17593. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17594. * the central point of your effect and can save a lot of performances.
  17595. */
  17596. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17597. /**
  17598. * Use this predicate to dynamically define the list of mesh you want to render.
  17599. * If set, the renderList property will be overwritten.
  17600. */
  17601. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17602. private _renderList;
  17603. /**
  17604. * Use this list to define the list of mesh you want to render.
  17605. */
  17606. renderList: Nullable<Array<AbstractMesh>>;
  17607. private _hookArray;
  17608. /**
  17609. * Define if particles should be rendered in your texture.
  17610. */
  17611. renderParticles: boolean;
  17612. /**
  17613. * Define if sprites should be rendered in your texture.
  17614. */
  17615. renderSprites: boolean;
  17616. /**
  17617. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17618. */
  17619. coordinatesMode: number;
  17620. /**
  17621. * Define the camera used to render the texture.
  17622. */
  17623. activeCamera: Nullable<Camera>;
  17624. /**
  17625. * Override the render function of the texture with your own one.
  17626. */
  17627. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17628. /**
  17629. * Define if camera post processes should be use while rendering the texture.
  17630. */
  17631. useCameraPostProcesses: boolean;
  17632. /**
  17633. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17634. */
  17635. ignoreCameraViewport: boolean;
  17636. private _postProcessManager;
  17637. private _postProcesses;
  17638. private _resizeObserver;
  17639. /**
  17640. * An event triggered when the texture is unbind.
  17641. */
  17642. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17643. /**
  17644. * An event triggered when the texture is unbind.
  17645. */
  17646. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17647. private _onAfterUnbindObserver;
  17648. /**
  17649. * Set a after unbind callback in the texture.
  17650. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17651. */
  17652. onAfterUnbind: () => void;
  17653. /**
  17654. * An event triggered before rendering the texture
  17655. */
  17656. onBeforeRenderObservable: Observable<number>;
  17657. private _onBeforeRenderObserver;
  17658. /**
  17659. * Set a before render callback in the texture.
  17660. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17661. */
  17662. onBeforeRender: (faceIndex: number) => void;
  17663. /**
  17664. * An event triggered after rendering the texture
  17665. */
  17666. onAfterRenderObservable: Observable<number>;
  17667. private _onAfterRenderObserver;
  17668. /**
  17669. * Set a after render callback in the texture.
  17670. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17671. */
  17672. onAfterRender: (faceIndex: number) => void;
  17673. /**
  17674. * An event triggered after the texture clear
  17675. */
  17676. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17677. private _onClearObserver;
  17678. /**
  17679. * Set a clear callback in the texture.
  17680. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17681. */
  17682. onClear: (Engine: Engine) => void;
  17683. /**
  17684. * Define the clear color of the Render Target if it should be different from the scene.
  17685. */
  17686. clearColor: Color4;
  17687. protected _size: number | {
  17688. width: number;
  17689. height: number;
  17690. };
  17691. protected _initialSizeParameter: number | {
  17692. width: number;
  17693. height: number;
  17694. } | {
  17695. ratio: number;
  17696. };
  17697. protected _sizeRatio: Nullable<number>;
  17698. /** @hidden */
  17699. _generateMipMaps: boolean;
  17700. protected _renderingManager: RenderingManager;
  17701. /** @hidden */
  17702. _waitingRenderList: string[];
  17703. protected _doNotChangeAspectRatio: boolean;
  17704. protected _currentRefreshId: number;
  17705. protected _refreshRate: number;
  17706. protected _textureMatrix: Matrix;
  17707. protected _samples: number;
  17708. protected _renderTargetOptions: RenderTargetCreationOptions;
  17709. /**
  17710. * Gets render target creation options that were used.
  17711. */
  17712. readonly renderTargetOptions: RenderTargetCreationOptions;
  17713. protected _engine: Engine;
  17714. protected _onRatioRescale(): void;
  17715. /**
  17716. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17717. * It must define where the camera used to render the texture is set
  17718. */
  17719. boundingBoxPosition: Vector3;
  17720. private _boundingBoxSize;
  17721. /**
  17722. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17723. * When defined, the cubemap will switch to local mode
  17724. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17725. * @example https://www.babylonjs-playground.com/#RNASML
  17726. */
  17727. boundingBoxSize: Vector3;
  17728. /**
  17729. * In case the RTT has been created with a depth texture, get the associated
  17730. * depth texture.
  17731. * Otherwise, return null.
  17732. */
  17733. depthStencilTexture: Nullable<InternalTexture>;
  17734. /**
  17735. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17736. * or used a shadow, depth texture...
  17737. * @param name The friendly name of the texture
  17738. * @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)
  17739. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17740. * @param generateMipMaps True if mip maps need to be generated after render.
  17741. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17742. * @param type The type of the buffer in the RTT (int, half float, float...)
  17743. * @param isCube True if a cube texture needs to be created
  17744. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17745. * @param generateDepthBuffer True to generate a depth buffer
  17746. * @param generateStencilBuffer True to generate a stencil buffer
  17747. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17748. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17749. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17750. */
  17751. constructor(name: string, size: number | {
  17752. width: number;
  17753. height: number;
  17754. } | {
  17755. ratio: number;
  17756. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17757. /**
  17758. * Creates a depth stencil texture.
  17759. * This is only available in WebGL 2 or with the depth texture extension available.
  17760. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17761. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17762. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17763. */
  17764. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17765. private _processSizeParameter;
  17766. /**
  17767. * Define the number of samples to use in case of MSAA.
  17768. * It defaults to one meaning no MSAA has been enabled.
  17769. */
  17770. samples: number;
  17771. /**
  17772. * Resets the refresh counter of the texture and start bak from scratch.
  17773. * Could be useful to regenerate the texture if it is setup to render only once.
  17774. */
  17775. resetRefreshCounter(): void;
  17776. /**
  17777. * Define the refresh rate of the texture or the rendering frequency.
  17778. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17779. */
  17780. refreshRate: number;
  17781. /**
  17782. * Adds a post process to the render target rendering passes.
  17783. * @param postProcess define the post process to add
  17784. */
  17785. addPostProcess(postProcess: PostProcess): void;
  17786. /**
  17787. * Clear all the post processes attached to the render target
  17788. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17789. */
  17790. clearPostProcesses(dispose?: boolean): void;
  17791. /**
  17792. * Remove one of the post process from the list of attached post processes to the texture
  17793. * @param postProcess define the post process to remove from the list
  17794. */
  17795. removePostProcess(postProcess: PostProcess): void;
  17796. /** @hidden */
  17797. _shouldRender(): boolean;
  17798. /**
  17799. * Gets the actual render size of the texture.
  17800. * @returns the width of the render size
  17801. */
  17802. getRenderSize(): number;
  17803. /**
  17804. * Gets the actual render width of the texture.
  17805. * @returns the width of the render size
  17806. */
  17807. getRenderWidth(): number;
  17808. /**
  17809. * Gets the actual render height of the texture.
  17810. * @returns the height of the render size
  17811. */
  17812. getRenderHeight(): number;
  17813. /**
  17814. * Get if the texture can be rescaled or not.
  17815. */
  17816. readonly canRescale: boolean;
  17817. /**
  17818. * Resize the texture using a ratio.
  17819. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17820. */
  17821. scale(ratio: number): void;
  17822. /**
  17823. * Get the texture reflection matrix used to rotate/transform the reflection.
  17824. * @returns the reflection matrix
  17825. */
  17826. getReflectionTextureMatrix(): Matrix;
  17827. /**
  17828. * Resize the texture to a new desired size.
  17829. * Be carrefull as it will recreate all the data in the new texture.
  17830. * @param size Define the new size. It can be:
  17831. * - a number for squared texture,
  17832. * - an object containing { width: number, height: number }
  17833. * - or an object containing a ratio { ratio: number }
  17834. */
  17835. resize(size: number | {
  17836. width: number;
  17837. height: number;
  17838. } | {
  17839. ratio: number;
  17840. }): void;
  17841. /**
  17842. * Renders all the objects from the render list into the texture.
  17843. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17844. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17845. */
  17846. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17847. private _bestReflectionRenderTargetDimension;
  17848. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17849. private renderToTarget;
  17850. /**
  17851. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17852. * This allowed control for front to back rendering or reversly depending of the special needs.
  17853. *
  17854. * @param renderingGroupId The rendering group id corresponding to its index
  17855. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17856. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17857. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17858. */
  17859. 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;
  17860. /**
  17861. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17862. *
  17863. * @param renderingGroupId The rendering group id corresponding to its index
  17864. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17865. */
  17866. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17867. /**
  17868. * Clones the texture.
  17869. * @returns the cloned texture
  17870. */
  17871. clone(): RenderTargetTexture;
  17872. /**
  17873. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17874. * @returns The JSON representation of the texture
  17875. */
  17876. serialize(): any;
  17877. /**
  17878. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17879. */
  17880. disposeFramebufferObjects(): void;
  17881. /**
  17882. * Dispose the texture and release its associated resources.
  17883. */
  17884. dispose(): void;
  17885. /** @hidden */
  17886. _rebuild(): void;
  17887. /**
  17888. * Clear the info related to rendering groups preventing retention point in material dispose.
  17889. */
  17890. freeRenderingGroups(): void;
  17891. }
  17892. }
  17893. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17894. import { Scene } from "babylonjs/scene";
  17895. import { Plane } from "babylonjs/Maths/math";
  17896. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17897. /**
  17898. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17899. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17900. * You can then easily use it as a reflectionTexture on a flat surface.
  17901. * In case the surface is not a plane, please consider relying on reflection probes.
  17902. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17903. */
  17904. export class MirrorTexture extends RenderTargetTexture {
  17905. private scene;
  17906. /**
  17907. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17908. * 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.
  17909. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17910. */
  17911. mirrorPlane: Plane;
  17912. /**
  17913. * Define the blur ratio used to blur the reflection if needed.
  17914. */
  17915. blurRatio: number;
  17916. /**
  17917. * Define the adaptive blur kernel used to blur the reflection if needed.
  17918. * This will autocompute the closest best match for the `blurKernel`
  17919. */
  17920. adaptiveBlurKernel: number;
  17921. /**
  17922. * Define the blur kernel used to blur the reflection if needed.
  17923. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17924. */
  17925. blurKernel: number;
  17926. /**
  17927. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17928. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17929. */
  17930. blurKernelX: number;
  17931. /**
  17932. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17933. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17934. */
  17935. blurKernelY: number;
  17936. private _autoComputeBlurKernel;
  17937. protected _onRatioRescale(): void;
  17938. private _updateGammaSpace;
  17939. private _imageProcessingConfigChangeObserver;
  17940. private _transformMatrix;
  17941. private _mirrorMatrix;
  17942. private _savedViewMatrix;
  17943. private _blurX;
  17944. private _blurY;
  17945. private _adaptiveBlurKernel;
  17946. private _blurKernelX;
  17947. private _blurKernelY;
  17948. private _blurRatio;
  17949. /**
  17950. * Instantiates a Mirror Texture.
  17951. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17952. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17953. * You can then easily use it as a reflectionTexture on a flat surface.
  17954. * In case the surface is not a plane, please consider relying on reflection probes.
  17955. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17956. * @param name
  17957. * @param size
  17958. * @param scene
  17959. * @param generateMipMaps
  17960. * @param type
  17961. * @param samplingMode
  17962. * @param generateDepthBuffer
  17963. */
  17964. constructor(name: string, size: number | {
  17965. width: number;
  17966. height: number;
  17967. } | {
  17968. ratio: number;
  17969. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17970. private _preparePostProcesses;
  17971. /**
  17972. * Clone the mirror texture.
  17973. * @returns the cloned texture
  17974. */
  17975. clone(): MirrorTexture;
  17976. /**
  17977. * Serialize the texture to a JSON representation you could use in Parse later on
  17978. * @returns the serialized JSON representation
  17979. */
  17980. serialize(): any;
  17981. /**
  17982. * Dispose the texture and release its associated resources.
  17983. */
  17984. dispose(): void;
  17985. }
  17986. }
  17987. declare module "babylonjs/Materials/Textures/texture" {
  17988. import { Observable } from "babylonjs/Misc/observable";
  17989. import { Nullable } from "babylonjs/types";
  17990. import { Scene } from "babylonjs/scene";
  17991. import { Matrix } from "babylonjs/Maths/math";
  17992. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17993. /**
  17994. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17995. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17996. */
  17997. export class Texture extends BaseTexture {
  17998. /** @hidden */
  17999. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18000. /** @hidden */
  18001. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18002. /** @hidden */
  18003. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18004. /** nearest is mag = nearest and min = nearest and mip = linear */
  18005. static readonly NEAREST_SAMPLINGMODE: number;
  18006. /** nearest is mag = nearest and min = nearest and mip = linear */
  18007. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18008. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18009. static readonly BILINEAR_SAMPLINGMODE: number;
  18010. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18011. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18012. /** Trilinear is mag = linear and min = linear and mip = linear */
  18013. static readonly TRILINEAR_SAMPLINGMODE: number;
  18014. /** Trilinear is mag = linear and min = linear and mip = linear */
  18015. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18016. /** mag = nearest and min = nearest and mip = nearest */
  18017. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18018. /** mag = nearest and min = linear and mip = nearest */
  18019. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18020. /** mag = nearest and min = linear and mip = linear */
  18021. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18022. /** mag = nearest and min = linear and mip = none */
  18023. static readonly NEAREST_LINEAR: number;
  18024. /** mag = nearest and min = nearest and mip = none */
  18025. static readonly NEAREST_NEAREST: number;
  18026. /** mag = linear and min = nearest and mip = nearest */
  18027. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18028. /** mag = linear and min = nearest and mip = linear */
  18029. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18030. /** mag = linear and min = linear and mip = none */
  18031. static readonly LINEAR_LINEAR: number;
  18032. /** mag = linear and min = nearest and mip = none */
  18033. static readonly LINEAR_NEAREST: number;
  18034. /** Explicit coordinates mode */
  18035. static readonly EXPLICIT_MODE: number;
  18036. /** Spherical coordinates mode */
  18037. static readonly SPHERICAL_MODE: number;
  18038. /** Planar coordinates mode */
  18039. static readonly PLANAR_MODE: number;
  18040. /** Cubic coordinates mode */
  18041. static readonly CUBIC_MODE: number;
  18042. /** Projection coordinates mode */
  18043. static readonly PROJECTION_MODE: number;
  18044. /** Inverse Cubic coordinates mode */
  18045. static readonly SKYBOX_MODE: number;
  18046. /** Inverse Cubic coordinates mode */
  18047. static readonly INVCUBIC_MODE: number;
  18048. /** Equirectangular coordinates mode */
  18049. static readonly EQUIRECTANGULAR_MODE: number;
  18050. /** Equirectangular Fixed coordinates mode */
  18051. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18052. /** Equirectangular Fixed Mirrored coordinates mode */
  18053. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18054. /** Texture is not repeating outside of 0..1 UVs */
  18055. static readonly CLAMP_ADDRESSMODE: number;
  18056. /** Texture is repeating outside of 0..1 UVs */
  18057. static readonly WRAP_ADDRESSMODE: number;
  18058. /** Texture is repeating and mirrored */
  18059. static readonly MIRROR_ADDRESSMODE: number;
  18060. /**
  18061. * 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
  18062. */
  18063. static UseSerializedUrlIfAny: boolean;
  18064. /**
  18065. * Define the url of the texture.
  18066. */
  18067. url: Nullable<string>;
  18068. /**
  18069. * Define an offset on the texture to offset the u coordinates of the UVs
  18070. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18071. */
  18072. uOffset: number;
  18073. /**
  18074. * Define an offset on the texture to offset the v coordinates of the UVs
  18075. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18076. */
  18077. vOffset: number;
  18078. /**
  18079. * Define an offset on the texture to scale the u coordinates of the UVs
  18080. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18081. */
  18082. uScale: number;
  18083. /**
  18084. * Define an offset on the texture to scale the v coordinates of the UVs
  18085. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18086. */
  18087. vScale: number;
  18088. /**
  18089. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18090. * @see http://doc.babylonjs.com/how_to/more_materials
  18091. */
  18092. uAng: number;
  18093. /**
  18094. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18095. * @see http://doc.babylonjs.com/how_to/more_materials
  18096. */
  18097. vAng: number;
  18098. /**
  18099. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18100. * @see http://doc.babylonjs.com/how_to/more_materials
  18101. */
  18102. wAng: number;
  18103. /**
  18104. * Defines the center of rotation (U)
  18105. */
  18106. uRotationCenter: number;
  18107. /**
  18108. * Defines the center of rotation (V)
  18109. */
  18110. vRotationCenter: number;
  18111. /**
  18112. * Defines the center of rotation (W)
  18113. */
  18114. wRotationCenter: number;
  18115. /**
  18116. * Are mip maps generated for this texture or not.
  18117. */
  18118. readonly noMipmap: boolean;
  18119. private _noMipmap;
  18120. /** @hidden */
  18121. _invertY: boolean;
  18122. private _rowGenerationMatrix;
  18123. private _cachedTextureMatrix;
  18124. private _projectionModeMatrix;
  18125. private _t0;
  18126. private _t1;
  18127. private _t2;
  18128. private _cachedUOffset;
  18129. private _cachedVOffset;
  18130. private _cachedUScale;
  18131. private _cachedVScale;
  18132. private _cachedUAng;
  18133. private _cachedVAng;
  18134. private _cachedWAng;
  18135. private _cachedProjectionMatrixId;
  18136. private _cachedCoordinatesMode;
  18137. /** @hidden */
  18138. protected _initialSamplingMode: number;
  18139. /** @hidden */
  18140. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18141. private _deleteBuffer;
  18142. protected _format: Nullable<number>;
  18143. private _delayedOnLoad;
  18144. private _delayedOnError;
  18145. /**
  18146. * Observable triggered once the texture has been loaded.
  18147. */
  18148. onLoadObservable: Observable<Texture>;
  18149. protected _isBlocking: boolean;
  18150. /**
  18151. * Is the texture preventing material to render while loading.
  18152. * If false, a default texture will be used instead of the loading one during the preparation step.
  18153. */
  18154. isBlocking: boolean;
  18155. /**
  18156. * Get the current sampling mode associated with the texture.
  18157. */
  18158. readonly samplingMode: number;
  18159. /**
  18160. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18161. */
  18162. readonly invertY: boolean;
  18163. /**
  18164. * Instantiates a new texture.
  18165. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18166. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18167. * @param url define the url of the picture to load as a texture
  18168. * @param scene define the scene the texture will belong to
  18169. * @param noMipmap define if the texture will require mip maps or not
  18170. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18171. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18172. * @param onLoad define a callback triggered when the texture has been loaded
  18173. * @param onError define a callback triggered when an error occurred during the loading session
  18174. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18175. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18176. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18177. */
  18178. 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);
  18179. /**
  18180. * Update the url (and optional buffer) of this texture if url was null during construction.
  18181. * @param url the url of the texture
  18182. * @param buffer the buffer of the texture (defaults to null)
  18183. * @param onLoad callback called when the texture is loaded (defaults to null)
  18184. */
  18185. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18186. /**
  18187. * Finish the loading sequence of a texture flagged as delayed load.
  18188. * @hidden
  18189. */
  18190. delayLoad(): void;
  18191. private _prepareRowForTextureGeneration;
  18192. /**
  18193. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18194. * @returns the transform matrix of the texture.
  18195. */
  18196. getTextureMatrix(): Matrix;
  18197. /**
  18198. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18199. * @returns The reflection texture transform
  18200. */
  18201. getReflectionTextureMatrix(): Matrix;
  18202. /**
  18203. * Clones the texture.
  18204. * @returns the cloned texture
  18205. */
  18206. clone(): Texture;
  18207. /**
  18208. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18209. * @returns The JSON representation of the texture
  18210. */
  18211. serialize(): any;
  18212. /**
  18213. * Get the current class name of the texture useful for serialization or dynamic coding.
  18214. * @returns "Texture"
  18215. */
  18216. getClassName(): string;
  18217. /**
  18218. * Dispose the texture and release its associated resources.
  18219. */
  18220. dispose(): void;
  18221. /**
  18222. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18223. * @param parsedTexture Define the JSON representation of the texture
  18224. * @param scene Define the scene the parsed texture should be instantiated in
  18225. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18226. * @returns The parsed texture if successful
  18227. */
  18228. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18229. /**
  18230. * Creates a texture from its base 64 representation.
  18231. * @param data Define the base64 payload without the data: prefix
  18232. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18233. * @param scene Define the scene the texture should belong to
  18234. * @param noMipmap Forces the texture to not create mip map information if true
  18235. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18236. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18237. * @param onLoad define a callback triggered when the texture has been loaded
  18238. * @param onError define a callback triggered when an error occurred during the loading session
  18239. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18240. * @returns the created texture
  18241. */
  18242. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18243. /**
  18244. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18245. * @param data Define the base64 payload without the data: prefix
  18246. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18247. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18248. * @param scene Define the scene the texture should belong to
  18249. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18250. * @param noMipmap Forces the texture to not create mip map information if true
  18251. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18252. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18253. * @param onLoad define a callback triggered when the texture has been loaded
  18254. * @param onError define a callback triggered when an error occurred during the loading session
  18255. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18256. * @returns the created texture
  18257. */
  18258. 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;
  18259. }
  18260. }
  18261. declare module "babylonjs/Materials/Textures/rawTexture" {
  18262. import { Scene } from "babylonjs/scene";
  18263. import { Texture } from "babylonjs/Materials/Textures/texture";
  18264. /**
  18265. * Raw texture can help creating a texture directly from an array of data.
  18266. * This can be super useful if you either get the data from an uncompressed source or
  18267. * if you wish to create your texture pixel by pixel.
  18268. */
  18269. export class RawTexture extends Texture {
  18270. /**
  18271. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18272. */
  18273. format: number;
  18274. private _engine;
  18275. /**
  18276. * Instantiates a new RawTexture.
  18277. * Raw texture can help creating a texture directly from an array of data.
  18278. * This can be super useful if you either get the data from an uncompressed source or
  18279. * if you wish to create your texture pixel by pixel.
  18280. * @param data define the array of data to use to create the texture
  18281. * @param width define the width of the texture
  18282. * @param height define the height of the texture
  18283. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18284. * @param scene define the scene the texture belongs to
  18285. * @param generateMipMaps define whether mip maps should be generated or not
  18286. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18287. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18288. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18289. */
  18290. constructor(data: ArrayBufferView, width: number, height: number,
  18291. /**
  18292. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18293. */
  18294. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18295. /**
  18296. * Updates the texture underlying data.
  18297. * @param data Define the new data of the texture
  18298. */
  18299. update(data: ArrayBufferView): void;
  18300. /**
  18301. * Creates a luminance texture from some data.
  18302. * @param data Define the texture data
  18303. * @param width Define the width of the texture
  18304. * @param height Define the height of the texture
  18305. * @param scene Define the scene the texture belongs to
  18306. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18307. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18308. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18309. * @returns the luminance texture
  18310. */
  18311. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18312. /**
  18313. * Creates a luminance alpha texture from some data.
  18314. * @param data Define the texture data
  18315. * @param width Define the width of the texture
  18316. * @param height Define the height of the texture
  18317. * @param scene Define the scene the texture belongs to
  18318. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18319. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18320. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18321. * @returns the luminance alpha texture
  18322. */
  18323. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18324. /**
  18325. * Creates an alpha texture from some data.
  18326. * @param data Define the texture data
  18327. * @param width Define the width of the texture
  18328. * @param height Define the height of the texture
  18329. * @param scene Define the scene the texture belongs to
  18330. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18331. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18332. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18333. * @returns the alpha texture
  18334. */
  18335. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18336. /**
  18337. * Creates a RGB texture from some data.
  18338. * @param data Define the texture data
  18339. * @param width Define the width of the texture
  18340. * @param height Define the height of the texture
  18341. * @param scene Define the scene the texture belongs to
  18342. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18343. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18344. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18345. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18346. * @returns the RGB alpha texture
  18347. */
  18348. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18349. /**
  18350. * Creates a RGBA texture from some data.
  18351. * @param data Define the texture data
  18352. * @param width Define the width of the texture
  18353. * @param height Define the height of the texture
  18354. * @param scene Define the scene the texture belongs to
  18355. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18356. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18357. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18358. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18359. * @returns the RGBA texture
  18360. */
  18361. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18362. /**
  18363. * Creates a R texture from some data.
  18364. * @param data Define the texture data
  18365. * @param width Define the width of the texture
  18366. * @param height Define the height of the texture
  18367. * @param scene Define the scene the texture belongs to
  18368. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18369. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18370. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18371. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18372. * @returns the R texture
  18373. */
  18374. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18375. }
  18376. }
  18377. declare module "babylonjs/Animations/runtimeAnimation" {
  18378. import { Animation } from "babylonjs/Animations/animation";
  18379. import { Animatable } from "babylonjs/Animations/animatable";
  18380. import { Scene } from "babylonjs/scene";
  18381. /**
  18382. * Defines a runtime animation
  18383. */
  18384. export class RuntimeAnimation {
  18385. private _events;
  18386. /**
  18387. * The current frame of the runtime animation
  18388. */
  18389. private _currentFrame;
  18390. /**
  18391. * The animation used by the runtime animation
  18392. */
  18393. private _animation;
  18394. /**
  18395. * The target of the runtime animation
  18396. */
  18397. private _target;
  18398. /**
  18399. * The initiating animatable
  18400. */
  18401. private _host;
  18402. /**
  18403. * The original value of the runtime animation
  18404. */
  18405. private _originalValue;
  18406. /**
  18407. * The original blend value of the runtime animation
  18408. */
  18409. private _originalBlendValue;
  18410. /**
  18411. * The offsets cache of the runtime animation
  18412. */
  18413. private _offsetsCache;
  18414. /**
  18415. * The high limits cache of the runtime animation
  18416. */
  18417. private _highLimitsCache;
  18418. /**
  18419. * Specifies if the runtime animation has been stopped
  18420. */
  18421. private _stopped;
  18422. /**
  18423. * The blending factor of the runtime animation
  18424. */
  18425. private _blendingFactor;
  18426. /**
  18427. * The BabylonJS scene
  18428. */
  18429. private _scene;
  18430. /**
  18431. * The current value of the runtime animation
  18432. */
  18433. private _currentValue;
  18434. /** @hidden */
  18435. _workValue: any;
  18436. /**
  18437. * The active target of the runtime animation
  18438. */
  18439. private _activeTarget;
  18440. /**
  18441. * The target path of the runtime animation
  18442. */
  18443. private _targetPath;
  18444. /**
  18445. * The weight of the runtime animation
  18446. */
  18447. private _weight;
  18448. /**
  18449. * The ratio offset of the runtime animation
  18450. */
  18451. private _ratioOffset;
  18452. /**
  18453. * The previous delay of the runtime animation
  18454. */
  18455. private _previousDelay;
  18456. /**
  18457. * The previous ratio of the runtime animation
  18458. */
  18459. private _previousRatio;
  18460. /**
  18461. * Gets the current frame of the runtime animation
  18462. */
  18463. readonly currentFrame: number;
  18464. /**
  18465. * Gets the weight of the runtime animation
  18466. */
  18467. readonly weight: number;
  18468. /**
  18469. * Gets the current value of the runtime animation
  18470. */
  18471. readonly currentValue: any;
  18472. /**
  18473. * Gets the target path of the runtime animation
  18474. */
  18475. readonly targetPath: string;
  18476. /**
  18477. * Gets the actual target of the runtime animation
  18478. */
  18479. readonly target: any;
  18480. /**
  18481. * Create a new RuntimeAnimation object
  18482. * @param target defines the target of the animation
  18483. * @param animation defines the source animation object
  18484. * @param scene defines the hosting scene
  18485. * @param host defines the initiating Animatable
  18486. */
  18487. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18488. /**
  18489. * Gets the animation from the runtime animation
  18490. */
  18491. readonly animation: Animation;
  18492. /**
  18493. * Resets the runtime animation to the beginning
  18494. * @param restoreOriginal defines whether to restore the target property to the original value
  18495. */
  18496. reset(restoreOriginal?: boolean): void;
  18497. /**
  18498. * Specifies if the runtime animation is stopped
  18499. * @returns Boolean specifying if the runtime animation is stopped
  18500. */
  18501. isStopped(): boolean;
  18502. /**
  18503. * Disposes of the runtime animation
  18504. */
  18505. dispose(): void;
  18506. /**
  18507. * Interpolates the animation from the current frame
  18508. * @param currentFrame The frame to interpolate the animation to
  18509. * @param repeatCount The number of times that the animation should loop
  18510. * @param loopMode The type of looping mode to use
  18511. * @param offsetValue Animation offset value
  18512. * @param highLimitValue The high limit value
  18513. * @returns The interpolated value
  18514. */
  18515. private _interpolate;
  18516. /**
  18517. * Apply the interpolated value to the target
  18518. * @param currentValue defines the value computed by the animation
  18519. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18520. */
  18521. setValue(currentValue: any, weight?: number): void;
  18522. private _setValue;
  18523. /**
  18524. * Gets the loop pmode of the runtime animation
  18525. * @returns Loop Mode
  18526. */
  18527. private _getCorrectLoopMode;
  18528. /**
  18529. * Move the current animation to a given frame
  18530. * @param frame defines the frame to move to
  18531. */
  18532. goToFrame(frame: number): void;
  18533. /**
  18534. * @hidden Internal use only
  18535. */
  18536. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18537. /**
  18538. * Execute the current animation
  18539. * @param delay defines the delay to add to the current frame
  18540. * @param from defines the lower bound of the animation range
  18541. * @param to defines the upper bound of the animation range
  18542. * @param loop defines if the current animation must loop
  18543. * @param speedRatio defines the current speed ratio
  18544. * @param weight defines the weight of the animation (default is -1 so no weight)
  18545. * @param onLoop optional callback called when animation loops
  18546. * @returns a boolean indicating if the animation is running
  18547. */
  18548. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18549. }
  18550. }
  18551. declare module "babylonjs/Animations/animatable" {
  18552. import { Animation } from "babylonjs/Animations/animation";
  18553. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18554. import { Nullable } from "babylonjs/types";
  18555. import { Observable } from "babylonjs/Misc/observable";
  18556. import { Scene } from "babylonjs/scene";
  18557. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18558. import { Node } from "babylonjs/node";
  18559. /**
  18560. * Class used to store an actual running animation
  18561. */
  18562. export class Animatable {
  18563. /** defines the target object */
  18564. target: any;
  18565. /** defines the starting frame number (default is 0) */
  18566. fromFrame: number;
  18567. /** defines the ending frame number (default is 100) */
  18568. toFrame: number;
  18569. /** defines if the animation must loop (default is false) */
  18570. loopAnimation: boolean;
  18571. /** defines a callback to call when animation ends if it is not looping */
  18572. onAnimationEnd?: (() => void) | null | undefined;
  18573. /** defines a callback to call when animation loops */
  18574. onAnimationLoop?: (() => void) | null | undefined;
  18575. private _localDelayOffset;
  18576. private _pausedDelay;
  18577. private _runtimeAnimations;
  18578. private _paused;
  18579. private _scene;
  18580. private _speedRatio;
  18581. private _weight;
  18582. private _syncRoot;
  18583. /**
  18584. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18585. * This will only apply for non looping animation (default is true)
  18586. */
  18587. disposeOnEnd: boolean;
  18588. /**
  18589. * Gets a boolean indicating if the animation has started
  18590. */
  18591. animationStarted: boolean;
  18592. /**
  18593. * Observer raised when the animation ends
  18594. */
  18595. onAnimationEndObservable: Observable<Animatable>;
  18596. /**
  18597. * Observer raised when the animation loops
  18598. */
  18599. onAnimationLoopObservable: Observable<Animatable>;
  18600. /**
  18601. * Gets the root Animatable used to synchronize and normalize animations
  18602. */
  18603. readonly syncRoot: Animatable;
  18604. /**
  18605. * Gets the current frame of the first RuntimeAnimation
  18606. * Used to synchronize Animatables
  18607. */
  18608. readonly masterFrame: number;
  18609. /**
  18610. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18611. */
  18612. weight: number;
  18613. /**
  18614. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18615. */
  18616. speedRatio: number;
  18617. /**
  18618. * Creates a new Animatable
  18619. * @param scene defines the hosting scene
  18620. * @param target defines the target object
  18621. * @param fromFrame defines the starting frame number (default is 0)
  18622. * @param toFrame defines the ending frame number (default is 100)
  18623. * @param loopAnimation defines if the animation must loop (default is false)
  18624. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18625. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18626. * @param animations defines a group of animation to add to the new Animatable
  18627. * @param onAnimationLoop defines a callback to call when animation loops
  18628. */
  18629. constructor(scene: Scene,
  18630. /** defines the target object */
  18631. target: any,
  18632. /** defines the starting frame number (default is 0) */
  18633. fromFrame?: number,
  18634. /** defines the ending frame number (default is 100) */
  18635. toFrame?: number,
  18636. /** defines if the animation must loop (default is false) */
  18637. loopAnimation?: boolean, speedRatio?: number,
  18638. /** defines a callback to call when animation ends if it is not looping */
  18639. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18640. /** defines a callback to call when animation loops */
  18641. onAnimationLoop?: (() => void) | null | undefined);
  18642. /**
  18643. * Synchronize and normalize current Animatable with a source Animatable
  18644. * This is useful when using animation weights and when animations are not of the same length
  18645. * @param root defines the root Animatable to synchronize with
  18646. * @returns the current Animatable
  18647. */
  18648. syncWith(root: Animatable): Animatable;
  18649. /**
  18650. * Gets the list of runtime animations
  18651. * @returns an array of RuntimeAnimation
  18652. */
  18653. getAnimations(): RuntimeAnimation[];
  18654. /**
  18655. * Adds more animations to the current animatable
  18656. * @param target defines the target of the animations
  18657. * @param animations defines the new animations to add
  18658. */
  18659. appendAnimations(target: any, animations: Animation[]): void;
  18660. /**
  18661. * Gets the source animation for a specific property
  18662. * @param property defines the propertyu to look for
  18663. * @returns null or the source animation for the given property
  18664. */
  18665. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18666. /**
  18667. * Gets the runtime animation for a specific property
  18668. * @param property defines the propertyu to look for
  18669. * @returns null or the runtime animation for the given property
  18670. */
  18671. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18672. /**
  18673. * Resets the animatable to its original state
  18674. */
  18675. reset(): void;
  18676. /**
  18677. * Allows the animatable to blend with current running animations
  18678. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18679. * @param blendingSpeed defines the blending speed to use
  18680. */
  18681. enableBlending(blendingSpeed: number): void;
  18682. /**
  18683. * Disable animation blending
  18684. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18685. */
  18686. disableBlending(): void;
  18687. /**
  18688. * Jump directly to a given frame
  18689. * @param frame defines the frame to jump to
  18690. */
  18691. goToFrame(frame: number): void;
  18692. /**
  18693. * Pause the animation
  18694. */
  18695. pause(): void;
  18696. /**
  18697. * Restart the animation
  18698. */
  18699. restart(): void;
  18700. private _raiseOnAnimationEnd;
  18701. /**
  18702. * Stop and delete the current animation
  18703. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18704. * @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)
  18705. */
  18706. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18707. /**
  18708. * Wait asynchronously for the animation to end
  18709. * @returns a promise which will be fullfilled when the animation ends
  18710. */
  18711. waitAsync(): Promise<Animatable>;
  18712. /** @hidden */
  18713. _animate(delay: number): boolean;
  18714. }
  18715. module "babylonjs/scene" {
  18716. interface Scene {
  18717. /** @hidden */
  18718. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18719. /** @hidden */
  18720. _processLateAnimationBindingsForMatrices(holder: {
  18721. totalWeight: number;
  18722. animations: RuntimeAnimation[];
  18723. originalValue: Matrix;
  18724. }): any;
  18725. /** @hidden */
  18726. _processLateAnimationBindingsForQuaternions(holder: {
  18727. totalWeight: number;
  18728. animations: RuntimeAnimation[];
  18729. originalValue: Quaternion;
  18730. }, refQuaternion: Quaternion): Quaternion;
  18731. /** @hidden */
  18732. _processLateAnimationBindings(): void;
  18733. /**
  18734. * Will start the animation sequence of a given target
  18735. * @param target defines the target
  18736. * @param from defines from which frame should animation start
  18737. * @param to defines until which frame should animation run.
  18738. * @param weight defines the weight to apply to the animation (1.0 by default)
  18739. * @param loop defines if the animation loops
  18740. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18741. * @param onAnimationEnd defines the function to be executed when the animation ends
  18742. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18743. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18744. * @param onAnimationLoop defines the callback to call when an animation loops
  18745. * @returns the animatable object created for this animation
  18746. */
  18747. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18748. /**
  18749. * Will start the animation sequence of a given target
  18750. * @param target defines the target
  18751. * @param from defines from which frame should animation start
  18752. * @param to defines until which frame should animation run.
  18753. * @param loop defines if the animation loops
  18754. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18755. * @param onAnimationEnd defines the function to be executed when the animation ends
  18756. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18757. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18758. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18759. * @param onAnimationLoop defines the callback to call when an animation loops
  18760. * @returns the animatable object created for this animation
  18761. */
  18762. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18763. /**
  18764. * Will start the animation sequence of a given target and its hierarchy
  18765. * @param target defines the target
  18766. * @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.
  18767. * @param from defines from which frame should animation start
  18768. * @param to defines until which frame should animation run.
  18769. * @param loop defines if the animation loops
  18770. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18771. * @param onAnimationEnd defines the function to be executed when the animation ends
  18772. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18773. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18774. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18775. * @param onAnimationLoop defines the callback to call when an animation loops
  18776. * @returns the list of created animatables
  18777. */
  18778. 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[];
  18779. /**
  18780. * Begin a new animation on a given node
  18781. * @param target defines the target where the animation will take place
  18782. * @param animations defines the list of animations to start
  18783. * @param from defines the initial value
  18784. * @param to defines the final value
  18785. * @param loop defines if you want animation to loop (off by default)
  18786. * @param speedRatio defines the speed ratio to apply to all animations
  18787. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18788. * @param onAnimationLoop defines the callback to call when an animation loops
  18789. * @returns the list of created animatables
  18790. */
  18791. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18792. /**
  18793. * Begin a new animation on a given node and its hierarchy
  18794. * @param target defines the root node where the animation will take place
  18795. * @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.
  18796. * @param animations defines the list of animations to start
  18797. * @param from defines the initial value
  18798. * @param to defines the final value
  18799. * @param loop defines if you want animation to loop (off by default)
  18800. * @param speedRatio defines the speed ratio to apply to all animations
  18801. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18802. * @param onAnimationLoop defines the callback to call when an animation loops
  18803. * @returns the list of animatables created for all nodes
  18804. */
  18805. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18806. /**
  18807. * Gets the animatable associated with a specific target
  18808. * @param target defines the target of the animatable
  18809. * @returns the required animatable if found
  18810. */
  18811. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18812. /**
  18813. * Gets all animatables associated with a given target
  18814. * @param target defines the target to look animatables for
  18815. * @returns an array of Animatables
  18816. */
  18817. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18818. /**
  18819. * Will stop the animation of the given target
  18820. * @param target - the target
  18821. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18822. * @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)
  18823. */
  18824. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18825. /**
  18826. * Stops and removes all animations that have been applied to the scene
  18827. */
  18828. stopAllAnimations(): void;
  18829. }
  18830. }
  18831. module "babylonjs/Bones/bone" {
  18832. interface Bone {
  18833. /**
  18834. * Copy an animation range from another bone
  18835. * @param source defines the source bone
  18836. * @param rangeName defines the range name to copy
  18837. * @param frameOffset defines the frame offset
  18838. * @param rescaleAsRequired defines if rescaling must be applied if required
  18839. * @param skelDimensionsRatio defines the scaling ratio
  18840. * @returns true if operation was successful
  18841. */
  18842. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18843. }
  18844. }
  18845. }
  18846. declare module "babylonjs/Bones/skeleton" {
  18847. import { Bone } from "babylonjs/Bones/bone";
  18848. import { IAnimatable } from "babylonjs/Misc/tools";
  18849. import { Observable } from "babylonjs/Misc/observable";
  18850. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18851. import { Scene } from "babylonjs/scene";
  18852. import { Nullable } from "babylonjs/types";
  18853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18854. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18855. import { Animatable } from "babylonjs/Animations/animatable";
  18856. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18857. import { Animation } from "babylonjs/Animations/animation";
  18858. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18859. /**
  18860. * Class used to handle skinning animations
  18861. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18862. */
  18863. export class Skeleton implements IAnimatable {
  18864. /** defines the skeleton name */
  18865. name: string;
  18866. /** defines the skeleton Id */
  18867. id: string;
  18868. /**
  18869. * Defines the list of child bones
  18870. */
  18871. bones: Bone[];
  18872. /**
  18873. * Defines an estimate of the dimension of the skeleton at rest
  18874. */
  18875. dimensionsAtRest: Vector3;
  18876. /**
  18877. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18878. */
  18879. needInitialSkinMatrix: boolean;
  18880. /**
  18881. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18882. */
  18883. overrideMesh: Nullable<AbstractMesh>;
  18884. /**
  18885. * Gets the list of animations attached to this skeleton
  18886. */
  18887. animations: Array<Animation>;
  18888. private _scene;
  18889. private _isDirty;
  18890. private _transformMatrices;
  18891. private _transformMatrixTexture;
  18892. private _meshesWithPoseMatrix;
  18893. private _animatables;
  18894. private _identity;
  18895. private _synchronizedWithMesh;
  18896. private _ranges;
  18897. private _lastAbsoluteTransformsUpdateId;
  18898. private _canUseTextureForBones;
  18899. /** @hidden */
  18900. _numBonesWithLinkedTransformNode: number;
  18901. /**
  18902. * Specifies if the skeleton should be serialized
  18903. */
  18904. doNotSerialize: boolean;
  18905. /**
  18906. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18907. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18908. */
  18909. useTextureToStoreBoneMatrices: boolean;
  18910. private _animationPropertiesOverride;
  18911. /**
  18912. * Gets or sets the animation properties override
  18913. */
  18914. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18915. /**
  18916. * An observable triggered before computing the skeleton's matrices
  18917. */
  18918. onBeforeComputeObservable: Observable<Skeleton>;
  18919. /**
  18920. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18921. */
  18922. readonly isUsingTextureForMatrices: boolean;
  18923. /**
  18924. * Creates a new skeleton
  18925. * @param name defines the skeleton name
  18926. * @param id defines the skeleton Id
  18927. * @param scene defines the hosting scene
  18928. */
  18929. constructor(
  18930. /** defines the skeleton name */
  18931. name: string,
  18932. /** defines the skeleton Id */
  18933. id: string, scene: Scene);
  18934. /**
  18935. * Gets the current object class name.
  18936. * @return the class name
  18937. */
  18938. getClassName(): string;
  18939. /**
  18940. * Returns an array containing the root bones
  18941. * @returns an array containing the root bones
  18942. */
  18943. getChildren(): Array<Bone>;
  18944. /**
  18945. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18946. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18947. * @returns a Float32Array containing matrices data
  18948. */
  18949. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18950. /**
  18951. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18952. * @returns a raw texture containing the data
  18953. */
  18954. getTransformMatrixTexture(): Nullable<RawTexture>;
  18955. /**
  18956. * Gets the current hosting scene
  18957. * @returns a scene object
  18958. */
  18959. getScene(): Scene;
  18960. /**
  18961. * Gets a string representing the current skeleton data
  18962. * @param fullDetails defines a boolean indicating if we want a verbose version
  18963. * @returns a string representing the current skeleton data
  18964. */
  18965. toString(fullDetails?: boolean): string;
  18966. /**
  18967. * Get bone's index searching by name
  18968. * @param name defines bone's name to search for
  18969. * @return the indice of the bone. Returns -1 if not found
  18970. */
  18971. getBoneIndexByName(name: string): number;
  18972. /**
  18973. * Creater a new animation range
  18974. * @param name defines the name of the range
  18975. * @param from defines the start key
  18976. * @param to defines the end key
  18977. */
  18978. createAnimationRange(name: string, from: number, to: number): void;
  18979. /**
  18980. * Delete a specific animation range
  18981. * @param name defines the name of the range
  18982. * @param deleteFrames defines if frames must be removed as well
  18983. */
  18984. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18985. /**
  18986. * Gets a specific animation range
  18987. * @param name defines the name of the range to look for
  18988. * @returns the requested animation range or null if not found
  18989. */
  18990. getAnimationRange(name: string): Nullable<AnimationRange>;
  18991. /**
  18992. * Gets the list of all animation ranges defined on this skeleton
  18993. * @returns an array
  18994. */
  18995. getAnimationRanges(): Nullable<AnimationRange>[];
  18996. /**
  18997. * Copy animation range from a source skeleton.
  18998. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18999. * @param source defines the source skeleton
  19000. * @param name defines the name of the range to copy
  19001. * @param rescaleAsRequired defines if rescaling must be applied if required
  19002. * @returns true if operation was successful
  19003. */
  19004. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19005. /**
  19006. * Forces the skeleton to go to rest pose
  19007. */
  19008. returnToRest(): void;
  19009. private _getHighestAnimationFrame;
  19010. /**
  19011. * Begin a specific animation range
  19012. * @param name defines the name of the range to start
  19013. * @param loop defines if looping must be turned on (false by default)
  19014. * @param speedRatio defines the speed ratio to apply (1 by default)
  19015. * @param onAnimationEnd defines a callback which will be called when animation will end
  19016. * @returns a new animatable
  19017. */
  19018. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19019. /** @hidden */
  19020. _markAsDirty(): void;
  19021. /** @hidden */
  19022. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19023. /** @hidden */
  19024. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19025. private _computeTransformMatrices;
  19026. /**
  19027. * Build all resources required to render a skeleton
  19028. */
  19029. prepare(): void;
  19030. /**
  19031. * Gets the list of animatables currently running for this skeleton
  19032. * @returns an array of animatables
  19033. */
  19034. getAnimatables(): IAnimatable[];
  19035. /**
  19036. * Clone the current skeleton
  19037. * @param name defines the name of the new skeleton
  19038. * @param id defines the id of the enw skeleton
  19039. * @returns the new skeleton
  19040. */
  19041. clone(name: string, id: string): Skeleton;
  19042. /**
  19043. * Enable animation blending for this skeleton
  19044. * @param blendingSpeed defines the blending speed to apply
  19045. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19046. */
  19047. enableBlending(blendingSpeed?: number): void;
  19048. /**
  19049. * Releases all resources associated with the current skeleton
  19050. */
  19051. dispose(): void;
  19052. /**
  19053. * Serialize the skeleton in a JSON object
  19054. * @returns a JSON object
  19055. */
  19056. serialize(): any;
  19057. /**
  19058. * Creates a new skeleton from serialized data
  19059. * @param parsedSkeleton defines the serialized data
  19060. * @param scene defines the hosting scene
  19061. * @returns a new skeleton
  19062. */
  19063. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19064. /**
  19065. * Compute all node absolute transforms
  19066. * @param forceUpdate defines if computation must be done even if cache is up to date
  19067. */
  19068. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19069. /**
  19070. * Gets the root pose matrix
  19071. * @returns a matrix
  19072. */
  19073. getPoseMatrix(): Nullable<Matrix>;
  19074. /**
  19075. * Sorts bones per internal index
  19076. */
  19077. sortBones(): void;
  19078. private _sortBones;
  19079. }
  19080. }
  19081. declare module "babylonjs/Morph/morphTarget" {
  19082. import { IAnimatable } from "babylonjs/Misc/tools";
  19083. import { Observable } from "babylonjs/Misc/observable";
  19084. import { Nullable, FloatArray } from "babylonjs/types";
  19085. import { Scene } from "babylonjs/scene";
  19086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19087. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19088. /**
  19089. * Defines a target to use with MorphTargetManager
  19090. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19091. */
  19092. export class MorphTarget implements IAnimatable {
  19093. /** defines the name of the target */
  19094. name: string;
  19095. /**
  19096. * Gets or sets the list of animations
  19097. */
  19098. animations: import("babylonjs/Animations/animation").Animation[];
  19099. private _scene;
  19100. private _positions;
  19101. private _normals;
  19102. private _tangents;
  19103. private _influence;
  19104. /**
  19105. * Observable raised when the influence changes
  19106. */
  19107. onInfluenceChanged: Observable<boolean>;
  19108. /** @hidden */
  19109. _onDataLayoutChanged: Observable<void>;
  19110. /**
  19111. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19112. */
  19113. influence: number;
  19114. /**
  19115. * Gets or sets the id of the morph Target
  19116. */
  19117. id: string;
  19118. private _animationPropertiesOverride;
  19119. /**
  19120. * Gets or sets the animation properties override
  19121. */
  19122. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19123. /**
  19124. * Creates a new MorphTarget
  19125. * @param name defines the name of the target
  19126. * @param influence defines the influence to use
  19127. * @param scene defines the scene the morphtarget belongs to
  19128. */
  19129. constructor(
  19130. /** defines the name of the target */
  19131. name: string, influence?: number, scene?: Nullable<Scene>);
  19132. /**
  19133. * Gets a boolean defining if the target contains position data
  19134. */
  19135. readonly hasPositions: boolean;
  19136. /**
  19137. * Gets a boolean defining if the target contains normal data
  19138. */
  19139. readonly hasNormals: boolean;
  19140. /**
  19141. * Gets a boolean defining if the target contains tangent data
  19142. */
  19143. readonly hasTangents: boolean;
  19144. /**
  19145. * Affects position data to this target
  19146. * @param data defines the position data to use
  19147. */
  19148. setPositions(data: Nullable<FloatArray>): void;
  19149. /**
  19150. * Gets the position data stored in this target
  19151. * @returns a FloatArray containing the position data (or null if not present)
  19152. */
  19153. getPositions(): Nullable<FloatArray>;
  19154. /**
  19155. * Affects normal data to this target
  19156. * @param data defines the normal data to use
  19157. */
  19158. setNormals(data: Nullable<FloatArray>): void;
  19159. /**
  19160. * Gets the normal data stored in this target
  19161. * @returns a FloatArray containing the normal data (or null if not present)
  19162. */
  19163. getNormals(): Nullable<FloatArray>;
  19164. /**
  19165. * Affects tangent data to this target
  19166. * @param data defines the tangent data to use
  19167. */
  19168. setTangents(data: Nullable<FloatArray>): void;
  19169. /**
  19170. * Gets the tangent data stored in this target
  19171. * @returns a FloatArray containing the tangent data (or null if not present)
  19172. */
  19173. getTangents(): Nullable<FloatArray>;
  19174. /**
  19175. * Serializes the current target into a Serialization object
  19176. * @returns the serialized object
  19177. */
  19178. serialize(): any;
  19179. /**
  19180. * Returns the string "MorphTarget"
  19181. * @returns "MorphTarget"
  19182. */
  19183. getClassName(): string;
  19184. /**
  19185. * Creates a new target from serialized data
  19186. * @param serializationObject defines the serialized data to use
  19187. * @returns a new MorphTarget
  19188. */
  19189. static Parse(serializationObject: any): MorphTarget;
  19190. /**
  19191. * Creates a MorphTarget from mesh data
  19192. * @param mesh defines the source mesh
  19193. * @param name defines the name to use for the new target
  19194. * @param influence defines the influence to attach to the target
  19195. * @returns a new MorphTarget
  19196. */
  19197. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19198. }
  19199. }
  19200. declare module "babylonjs/Morph/morphTargetManager" {
  19201. import { Nullable } from "babylonjs/types";
  19202. import { Scene } from "babylonjs/scene";
  19203. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19204. /**
  19205. * This class is used to deform meshes using morphing between different targets
  19206. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19207. */
  19208. export class MorphTargetManager {
  19209. private _targets;
  19210. private _targetInfluenceChangedObservers;
  19211. private _targetDataLayoutChangedObservers;
  19212. private _activeTargets;
  19213. private _scene;
  19214. private _influences;
  19215. private _supportsNormals;
  19216. private _supportsTangents;
  19217. private _vertexCount;
  19218. private _uniqueId;
  19219. private _tempInfluences;
  19220. /**
  19221. * Creates a new MorphTargetManager
  19222. * @param scene defines the current scene
  19223. */
  19224. constructor(scene?: Nullable<Scene>);
  19225. /**
  19226. * Gets the unique ID of this manager
  19227. */
  19228. readonly uniqueId: number;
  19229. /**
  19230. * Gets the number of vertices handled by this manager
  19231. */
  19232. readonly vertexCount: number;
  19233. /**
  19234. * Gets a boolean indicating if this manager supports morphing of normals
  19235. */
  19236. readonly supportsNormals: boolean;
  19237. /**
  19238. * Gets a boolean indicating if this manager supports morphing of tangents
  19239. */
  19240. readonly supportsTangents: boolean;
  19241. /**
  19242. * Gets the number of targets stored in this manager
  19243. */
  19244. readonly numTargets: number;
  19245. /**
  19246. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19247. */
  19248. readonly numInfluencers: number;
  19249. /**
  19250. * Gets the list of influences (one per target)
  19251. */
  19252. readonly influences: Float32Array;
  19253. /**
  19254. * Gets the active target at specified index. An active target is a target with an influence > 0
  19255. * @param index defines the index to check
  19256. * @returns the requested target
  19257. */
  19258. getActiveTarget(index: number): MorphTarget;
  19259. /**
  19260. * Gets the target at specified index
  19261. * @param index defines the index to check
  19262. * @returns the requested target
  19263. */
  19264. getTarget(index: number): MorphTarget;
  19265. /**
  19266. * Add a new target to this manager
  19267. * @param target defines the target to add
  19268. */
  19269. addTarget(target: MorphTarget): void;
  19270. /**
  19271. * Removes a target from the manager
  19272. * @param target defines the target to remove
  19273. */
  19274. removeTarget(target: MorphTarget): void;
  19275. /**
  19276. * Serializes the current manager into a Serialization object
  19277. * @returns the serialized object
  19278. */
  19279. serialize(): any;
  19280. private _syncActiveTargets;
  19281. /**
  19282. * Syncrhonize the targets with all the meshes using this morph target manager
  19283. */
  19284. synchronize(): void;
  19285. /**
  19286. * Creates a new MorphTargetManager from serialized data
  19287. * @param serializationObject defines the serialized data
  19288. * @param scene defines the hosting scene
  19289. * @returns the new MorphTargetManager
  19290. */
  19291. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19292. }
  19293. }
  19294. declare module "babylonjs/Meshes/groundMesh" {
  19295. import { Scene } from "babylonjs/scene";
  19296. import { Vector3 } from "babylonjs/Maths/math";
  19297. import { Mesh } from "babylonjs/Meshes/mesh";
  19298. /**
  19299. * Mesh representing the gorund
  19300. */
  19301. export class GroundMesh extends Mesh {
  19302. /** If octree should be generated */
  19303. generateOctree: boolean;
  19304. private _heightQuads;
  19305. /** @hidden */
  19306. _subdivisionsX: number;
  19307. /** @hidden */
  19308. _subdivisionsY: number;
  19309. /** @hidden */
  19310. _width: number;
  19311. /** @hidden */
  19312. _height: number;
  19313. /** @hidden */
  19314. _minX: number;
  19315. /** @hidden */
  19316. _maxX: number;
  19317. /** @hidden */
  19318. _minZ: number;
  19319. /** @hidden */
  19320. _maxZ: number;
  19321. constructor(name: string, scene: Scene);
  19322. /**
  19323. * "GroundMesh"
  19324. * @returns "GroundMesh"
  19325. */
  19326. getClassName(): string;
  19327. /**
  19328. * The minimum of x and y subdivisions
  19329. */
  19330. readonly subdivisions: number;
  19331. /**
  19332. * X subdivisions
  19333. */
  19334. readonly subdivisionsX: number;
  19335. /**
  19336. * Y subdivisions
  19337. */
  19338. readonly subdivisionsY: number;
  19339. /**
  19340. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19341. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19342. * @param chunksCount the number of subdivisions for x and y
  19343. * @param octreeBlocksSize (Default: 32)
  19344. */
  19345. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19346. /**
  19347. * Returns a height (y) value in the Worl system :
  19348. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19349. * @param x x coordinate
  19350. * @param z z coordinate
  19351. * @returns the ground y position if (x, z) are outside the ground surface.
  19352. */
  19353. getHeightAtCoordinates(x: number, z: number): number;
  19354. /**
  19355. * Returns a normalized vector (Vector3) orthogonal to the ground
  19356. * at the ground coordinates (x, z) expressed in the World system.
  19357. * @param x x coordinate
  19358. * @param z z coordinate
  19359. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19360. */
  19361. getNormalAtCoordinates(x: number, z: number): Vector3;
  19362. /**
  19363. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19364. * at the ground coordinates (x, z) expressed in the World system.
  19365. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19366. * @param x x coordinate
  19367. * @param z z coordinate
  19368. * @param ref vector to store the result
  19369. * @returns the GroundMesh.
  19370. */
  19371. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19372. /**
  19373. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19374. * if the ground has been updated.
  19375. * This can be used in the render loop.
  19376. * @returns the GroundMesh.
  19377. */
  19378. updateCoordinateHeights(): GroundMesh;
  19379. private _getFacetAt;
  19380. private _initHeightQuads;
  19381. private _computeHeightQuads;
  19382. /**
  19383. * Serializes this ground mesh
  19384. * @param serializationObject object to write serialization to
  19385. */
  19386. serialize(serializationObject: any): void;
  19387. /**
  19388. * Parses a serialized ground mesh
  19389. * @param parsedMesh the serialized mesh
  19390. * @param scene the scene to create the ground mesh in
  19391. * @returns the created ground mesh
  19392. */
  19393. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19394. }
  19395. }
  19396. declare module "babylonjs/Physics/physicsJoint" {
  19397. import { Vector3 } from "babylonjs/Maths/math";
  19398. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19399. /**
  19400. * Interface for Physics-Joint data
  19401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19402. */
  19403. export interface PhysicsJointData {
  19404. /**
  19405. * The main pivot of the joint
  19406. */
  19407. mainPivot?: Vector3;
  19408. /**
  19409. * The connected pivot of the joint
  19410. */
  19411. connectedPivot?: Vector3;
  19412. /**
  19413. * The main axis of the joint
  19414. */
  19415. mainAxis?: Vector3;
  19416. /**
  19417. * The connected axis of the joint
  19418. */
  19419. connectedAxis?: Vector3;
  19420. /**
  19421. * The collision of the joint
  19422. */
  19423. collision?: boolean;
  19424. /**
  19425. * Native Oimo/Cannon/Energy data
  19426. */
  19427. nativeParams?: any;
  19428. }
  19429. /**
  19430. * This is a holder class for the physics joint created by the physics plugin
  19431. * It holds a set of functions to control the underlying joint
  19432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19433. */
  19434. export class PhysicsJoint {
  19435. /**
  19436. * The type of the physics joint
  19437. */
  19438. type: number;
  19439. /**
  19440. * The data for the physics joint
  19441. */
  19442. jointData: PhysicsJointData;
  19443. private _physicsJoint;
  19444. protected _physicsPlugin: IPhysicsEnginePlugin;
  19445. /**
  19446. * Initializes the physics joint
  19447. * @param type The type of the physics joint
  19448. * @param jointData The data for the physics joint
  19449. */
  19450. constructor(
  19451. /**
  19452. * The type of the physics joint
  19453. */
  19454. type: number,
  19455. /**
  19456. * The data for the physics joint
  19457. */
  19458. jointData: PhysicsJointData);
  19459. /**
  19460. * Gets the physics joint
  19461. */
  19462. /**
  19463. * Sets the physics joint
  19464. */
  19465. physicsJoint: any;
  19466. /**
  19467. * Sets the physics plugin
  19468. */
  19469. physicsPlugin: IPhysicsEnginePlugin;
  19470. /**
  19471. * Execute a function that is physics-plugin specific.
  19472. * @param {Function} func the function that will be executed.
  19473. * It accepts two parameters: the physics world and the physics joint
  19474. */
  19475. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19476. /**
  19477. * Distance-Joint type
  19478. */
  19479. static DistanceJoint: number;
  19480. /**
  19481. * Hinge-Joint type
  19482. */
  19483. static HingeJoint: number;
  19484. /**
  19485. * Ball-and-Socket joint type
  19486. */
  19487. static BallAndSocketJoint: number;
  19488. /**
  19489. * Wheel-Joint type
  19490. */
  19491. static WheelJoint: number;
  19492. /**
  19493. * Slider-Joint type
  19494. */
  19495. static SliderJoint: number;
  19496. /**
  19497. * Prismatic-Joint type
  19498. */
  19499. static PrismaticJoint: number;
  19500. /**
  19501. * Universal-Joint type
  19502. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19503. */
  19504. static UniversalJoint: number;
  19505. /**
  19506. * Hinge-Joint 2 type
  19507. */
  19508. static Hinge2Joint: number;
  19509. /**
  19510. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19511. */
  19512. static PointToPointJoint: number;
  19513. /**
  19514. * Spring-Joint type
  19515. */
  19516. static SpringJoint: number;
  19517. /**
  19518. * Lock-Joint type
  19519. */
  19520. static LockJoint: number;
  19521. }
  19522. /**
  19523. * A class representing a physics distance joint
  19524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19525. */
  19526. export class DistanceJoint extends PhysicsJoint {
  19527. /**
  19528. *
  19529. * @param jointData The data for the Distance-Joint
  19530. */
  19531. constructor(jointData: DistanceJointData);
  19532. /**
  19533. * Update the predefined distance.
  19534. * @param maxDistance The maximum preferred distance
  19535. * @param minDistance The minimum preferred distance
  19536. */
  19537. updateDistance(maxDistance: number, minDistance?: number): void;
  19538. }
  19539. /**
  19540. * Represents a Motor-Enabled Joint
  19541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19542. */
  19543. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19544. /**
  19545. * Initializes the Motor-Enabled Joint
  19546. * @param type The type of the joint
  19547. * @param jointData The physica joint data for the joint
  19548. */
  19549. constructor(type: number, jointData: PhysicsJointData);
  19550. /**
  19551. * Set the motor values.
  19552. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19553. * @param force the force to apply
  19554. * @param maxForce max force for this motor.
  19555. */
  19556. setMotor(force?: number, maxForce?: number): void;
  19557. /**
  19558. * Set the motor's limits.
  19559. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19560. * @param upperLimit The upper limit of the motor
  19561. * @param lowerLimit The lower limit of the motor
  19562. */
  19563. setLimit(upperLimit: number, lowerLimit?: number): void;
  19564. }
  19565. /**
  19566. * This class represents a single physics Hinge-Joint
  19567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19568. */
  19569. export class HingeJoint extends MotorEnabledJoint {
  19570. /**
  19571. * Initializes the Hinge-Joint
  19572. * @param jointData The joint data for the Hinge-Joint
  19573. */
  19574. constructor(jointData: PhysicsJointData);
  19575. /**
  19576. * Set the motor values.
  19577. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19578. * @param {number} force the force to apply
  19579. * @param {number} maxForce max force for this motor.
  19580. */
  19581. setMotor(force?: number, maxForce?: number): void;
  19582. /**
  19583. * Set the motor's limits.
  19584. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19585. * @param upperLimit The upper limit of the motor
  19586. * @param lowerLimit The lower limit of the motor
  19587. */
  19588. setLimit(upperLimit: number, lowerLimit?: number): void;
  19589. }
  19590. /**
  19591. * This class represents a dual hinge physics joint (same as wheel joint)
  19592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19593. */
  19594. export class Hinge2Joint extends MotorEnabledJoint {
  19595. /**
  19596. * Initializes the Hinge2-Joint
  19597. * @param jointData The joint data for the Hinge2-Joint
  19598. */
  19599. constructor(jointData: PhysicsJointData);
  19600. /**
  19601. * Set the motor values.
  19602. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19603. * @param {number} targetSpeed the speed the motor is to reach
  19604. * @param {number} maxForce max force for this motor.
  19605. * @param {motorIndex} the motor's index, 0 or 1.
  19606. */
  19607. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19608. /**
  19609. * Set the motor limits.
  19610. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19611. * @param {number} upperLimit the upper limit
  19612. * @param {number} lowerLimit lower limit
  19613. * @param {motorIndex} the motor's index, 0 or 1.
  19614. */
  19615. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19616. }
  19617. /**
  19618. * Interface for a motor enabled joint
  19619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19620. */
  19621. export interface IMotorEnabledJoint {
  19622. /**
  19623. * Physics joint
  19624. */
  19625. physicsJoint: any;
  19626. /**
  19627. * Sets the motor of the motor-enabled joint
  19628. * @param force The force of the motor
  19629. * @param maxForce The maximum force of the motor
  19630. * @param motorIndex The index of the motor
  19631. */
  19632. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19633. /**
  19634. * Sets the limit of the motor
  19635. * @param upperLimit The upper limit of the motor
  19636. * @param lowerLimit The lower limit of the motor
  19637. * @param motorIndex The index of the motor
  19638. */
  19639. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19640. }
  19641. /**
  19642. * Joint data for a Distance-Joint
  19643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19644. */
  19645. export interface DistanceJointData extends PhysicsJointData {
  19646. /**
  19647. * Max distance the 2 joint objects can be apart
  19648. */
  19649. maxDistance: number;
  19650. }
  19651. /**
  19652. * Joint data from a spring joint
  19653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19654. */
  19655. export interface SpringJointData extends PhysicsJointData {
  19656. /**
  19657. * Length of the spring
  19658. */
  19659. length: number;
  19660. /**
  19661. * Stiffness of the spring
  19662. */
  19663. stiffness: number;
  19664. /**
  19665. * Damping of the spring
  19666. */
  19667. damping: number;
  19668. /** this callback will be called when applying the force to the impostors. */
  19669. forceApplicationCallback: () => void;
  19670. }
  19671. }
  19672. declare module "babylonjs/Physics/IPhysicsEngine" {
  19673. import { Nullable } from "babylonjs/types";
  19674. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19676. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19677. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19678. /**
  19679. * Interface used to describe a physics joint
  19680. */
  19681. export interface PhysicsImpostorJoint {
  19682. /** Defines the main impostor to which the joint is linked */
  19683. mainImpostor: PhysicsImpostor;
  19684. /** Defines the impostor that is connected to the main impostor using this joint */
  19685. connectedImpostor: PhysicsImpostor;
  19686. /** Defines the joint itself */
  19687. joint: PhysicsJoint;
  19688. }
  19689. /** @hidden */
  19690. export interface IPhysicsEnginePlugin {
  19691. world: any;
  19692. name: string;
  19693. setGravity(gravity: Vector3): void;
  19694. setTimeStep(timeStep: number): void;
  19695. getTimeStep(): number;
  19696. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19697. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19698. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19699. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19700. removePhysicsBody(impostor: PhysicsImpostor): void;
  19701. generateJoint(joint: PhysicsImpostorJoint): void;
  19702. removeJoint(joint: PhysicsImpostorJoint): void;
  19703. isSupported(): boolean;
  19704. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19705. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19706. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19707. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19708. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19709. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19710. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19711. getBodyMass(impostor: PhysicsImpostor): number;
  19712. getBodyFriction(impostor: PhysicsImpostor): number;
  19713. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19714. getBodyRestitution(impostor: PhysicsImpostor): number;
  19715. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19716. sleepBody(impostor: PhysicsImpostor): void;
  19717. wakeUpBody(impostor: PhysicsImpostor): void;
  19718. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19719. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19720. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19721. getRadius(impostor: PhysicsImpostor): number;
  19722. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19723. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19724. dispose(): void;
  19725. }
  19726. /**
  19727. * Interface used to define a physics engine
  19728. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19729. */
  19730. export interface IPhysicsEngine {
  19731. /**
  19732. * Gets the gravity vector used by the simulation
  19733. */
  19734. gravity: Vector3;
  19735. /**
  19736. * Sets the gravity vector used by the simulation
  19737. * @param gravity defines the gravity vector to use
  19738. */
  19739. setGravity(gravity: Vector3): void;
  19740. /**
  19741. * Set the time step of the physics engine.
  19742. * Default is 1/60.
  19743. * To slow it down, enter 1/600 for example.
  19744. * To speed it up, 1/30
  19745. * @param newTimeStep the new timestep to apply to this world.
  19746. */
  19747. setTimeStep(newTimeStep: number): void;
  19748. /**
  19749. * Get the time step of the physics engine.
  19750. * @returns the current time step
  19751. */
  19752. getTimeStep(): number;
  19753. /**
  19754. * Release all resources
  19755. */
  19756. dispose(): void;
  19757. /**
  19758. * Gets the name of the current physics plugin
  19759. * @returns the name of the plugin
  19760. */
  19761. getPhysicsPluginName(): string;
  19762. /**
  19763. * Adding a new impostor for the impostor tracking.
  19764. * This will be done by the impostor itself.
  19765. * @param impostor the impostor to add
  19766. */
  19767. addImpostor(impostor: PhysicsImpostor): void;
  19768. /**
  19769. * Remove an impostor from the engine.
  19770. * This impostor and its mesh will not longer be updated by the physics engine.
  19771. * @param impostor the impostor to remove
  19772. */
  19773. removeImpostor(impostor: PhysicsImpostor): void;
  19774. /**
  19775. * Add a joint to the physics engine
  19776. * @param mainImpostor defines the main impostor to which the joint is added.
  19777. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19778. * @param joint defines the joint that will connect both impostors.
  19779. */
  19780. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19781. /**
  19782. * Removes a joint from the simulation
  19783. * @param mainImpostor defines the impostor used with the joint
  19784. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19785. * @param joint defines the joint to remove
  19786. */
  19787. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19788. /**
  19789. * Gets the current plugin used to run the simulation
  19790. * @returns current plugin
  19791. */
  19792. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19793. /**
  19794. * Gets the list of physic impostors
  19795. * @returns an array of PhysicsImpostor
  19796. */
  19797. getImpostors(): Array<PhysicsImpostor>;
  19798. /**
  19799. * Gets the impostor for a physics enabled object
  19800. * @param object defines the object impersonated by the impostor
  19801. * @returns the PhysicsImpostor or null if not found
  19802. */
  19803. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19804. /**
  19805. * Gets the impostor for a physics body object
  19806. * @param body defines physics body used by the impostor
  19807. * @returns the PhysicsImpostor or null if not found
  19808. */
  19809. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19810. /**
  19811. * Called by the scene. No need to call it.
  19812. * @param delta defines the timespam between frames
  19813. */
  19814. _step(delta: number): void;
  19815. }
  19816. }
  19817. declare module "babylonjs/Physics/physicsImpostor" {
  19818. import { Nullable, IndicesArray } from "babylonjs/types";
  19819. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19820. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19822. import { Scene } from "babylonjs/scene";
  19823. import { Bone } from "babylonjs/Bones/bone";
  19824. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19825. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19826. /**
  19827. * The interface for the physics imposter parameters
  19828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19829. */
  19830. export interface PhysicsImpostorParameters {
  19831. /**
  19832. * The mass of the physics imposter
  19833. */
  19834. mass: number;
  19835. /**
  19836. * The friction of the physics imposter
  19837. */
  19838. friction?: number;
  19839. /**
  19840. * The coefficient of restitution of the physics imposter
  19841. */
  19842. restitution?: number;
  19843. /**
  19844. * The native options of the physics imposter
  19845. */
  19846. nativeOptions?: any;
  19847. /**
  19848. * Specifies if the parent should be ignored
  19849. */
  19850. ignoreParent?: boolean;
  19851. /**
  19852. * Specifies if bi-directional transformations should be disabled
  19853. */
  19854. disableBidirectionalTransformation?: boolean;
  19855. }
  19856. /**
  19857. * Interface for a physics-enabled object
  19858. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19859. */
  19860. export interface IPhysicsEnabledObject {
  19861. /**
  19862. * The position of the physics-enabled object
  19863. */
  19864. position: Vector3;
  19865. /**
  19866. * The rotation of the physics-enabled object
  19867. */
  19868. rotationQuaternion: Nullable<Quaternion>;
  19869. /**
  19870. * The scale of the physics-enabled object
  19871. */
  19872. scaling: Vector3;
  19873. /**
  19874. * The rotation of the physics-enabled object
  19875. */
  19876. rotation?: Vector3;
  19877. /**
  19878. * The parent of the physics-enabled object
  19879. */
  19880. parent?: any;
  19881. /**
  19882. * The bounding info of the physics-enabled object
  19883. * @returns The bounding info of the physics-enabled object
  19884. */
  19885. getBoundingInfo(): BoundingInfo;
  19886. /**
  19887. * Computes the world matrix
  19888. * @param force Specifies if the world matrix should be computed by force
  19889. * @returns A world matrix
  19890. */
  19891. computeWorldMatrix(force: boolean): Matrix;
  19892. /**
  19893. * Gets the world matrix
  19894. * @returns A world matrix
  19895. */
  19896. getWorldMatrix?(): Matrix;
  19897. /**
  19898. * Gets the child meshes
  19899. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19900. * @returns An array of abstract meshes
  19901. */
  19902. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19903. /**
  19904. * Gets the vertex data
  19905. * @param kind The type of vertex data
  19906. * @returns A nullable array of numbers, or a float32 array
  19907. */
  19908. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19909. /**
  19910. * Gets the indices from the mesh
  19911. * @returns A nullable array of index arrays
  19912. */
  19913. getIndices?(): Nullable<IndicesArray>;
  19914. /**
  19915. * Gets the scene from the mesh
  19916. * @returns the indices array or null
  19917. */
  19918. getScene?(): Scene;
  19919. /**
  19920. * Gets the absolute position from the mesh
  19921. * @returns the absolute position
  19922. */
  19923. getAbsolutePosition(): Vector3;
  19924. /**
  19925. * Gets the absolute pivot point from the mesh
  19926. * @returns the absolute pivot point
  19927. */
  19928. getAbsolutePivotPoint(): Vector3;
  19929. /**
  19930. * Rotates the mesh
  19931. * @param axis The axis of rotation
  19932. * @param amount The amount of rotation
  19933. * @param space The space of the rotation
  19934. * @returns The rotation transform node
  19935. */
  19936. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19937. /**
  19938. * Translates the mesh
  19939. * @param axis The axis of translation
  19940. * @param distance The distance of translation
  19941. * @param space The space of the translation
  19942. * @returns The transform node
  19943. */
  19944. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19945. /**
  19946. * Sets the absolute position of the mesh
  19947. * @param absolutePosition The absolute position of the mesh
  19948. * @returns The transform node
  19949. */
  19950. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19951. /**
  19952. * Gets the class name of the mesh
  19953. * @returns The class name
  19954. */
  19955. getClassName(): string;
  19956. }
  19957. /**
  19958. * Represents a physics imposter
  19959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19960. */
  19961. export class PhysicsImpostor {
  19962. /**
  19963. * The physics-enabled object used as the physics imposter
  19964. */
  19965. object: IPhysicsEnabledObject;
  19966. /**
  19967. * The type of the physics imposter
  19968. */
  19969. type: number;
  19970. private _options;
  19971. private _scene?;
  19972. /**
  19973. * The default object size of the imposter
  19974. */
  19975. static DEFAULT_OBJECT_SIZE: Vector3;
  19976. /**
  19977. * The identity quaternion of the imposter
  19978. */
  19979. static IDENTITY_QUATERNION: Quaternion;
  19980. /** @hidden */
  19981. _pluginData: any;
  19982. private _physicsEngine;
  19983. private _physicsBody;
  19984. private _bodyUpdateRequired;
  19985. private _onBeforePhysicsStepCallbacks;
  19986. private _onAfterPhysicsStepCallbacks;
  19987. /** @hidden */
  19988. _onPhysicsCollideCallbacks: Array<{
  19989. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19990. otherImpostors: Array<PhysicsImpostor>;
  19991. }>;
  19992. private _deltaPosition;
  19993. private _deltaRotation;
  19994. private _deltaRotationConjugated;
  19995. private _parent;
  19996. private _isDisposed;
  19997. private static _tmpVecs;
  19998. private static _tmpQuat;
  19999. /**
  20000. * Specifies if the physics imposter is disposed
  20001. */
  20002. readonly isDisposed: boolean;
  20003. /**
  20004. * Gets the mass of the physics imposter
  20005. */
  20006. mass: number;
  20007. /**
  20008. * Gets the coefficient of friction
  20009. */
  20010. /**
  20011. * Sets the coefficient of friction
  20012. */
  20013. friction: number;
  20014. /**
  20015. * Gets the coefficient of restitution
  20016. */
  20017. /**
  20018. * Sets the coefficient of restitution
  20019. */
  20020. restitution: number;
  20021. /**
  20022. * The unique id of the physics imposter
  20023. * set by the physics engine when adding this impostor to the array
  20024. */
  20025. uniqueId: number;
  20026. private _joints;
  20027. /**
  20028. * Initializes the physics imposter
  20029. * @param object The physics-enabled object used as the physics imposter
  20030. * @param type The type of the physics imposter
  20031. * @param _options The options for the physics imposter
  20032. * @param _scene The Babylon scene
  20033. */
  20034. constructor(
  20035. /**
  20036. * The physics-enabled object used as the physics imposter
  20037. */
  20038. object: IPhysicsEnabledObject,
  20039. /**
  20040. * The type of the physics imposter
  20041. */
  20042. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20043. /**
  20044. * This function will completly initialize this impostor.
  20045. * It will create a new body - but only if this mesh has no parent.
  20046. * If it has, this impostor will not be used other than to define the impostor
  20047. * of the child mesh.
  20048. * @hidden
  20049. */
  20050. _init(): void;
  20051. private _getPhysicsParent;
  20052. /**
  20053. * Should a new body be generated.
  20054. * @returns boolean specifying if body initialization is required
  20055. */
  20056. isBodyInitRequired(): boolean;
  20057. /**
  20058. * Sets the updated scaling
  20059. * @param updated Specifies if the scaling is updated
  20060. */
  20061. setScalingUpdated(): void;
  20062. /**
  20063. * Force a regeneration of this or the parent's impostor's body.
  20064. * Use under cautious - This will remove all joints already implemented.
  20065. */
  20066. forceUpdate(): void;
  20067. /**
  20068. * Gets the body that holds this impostor. Either its own, or its parent.
  20069. */
  20070. /**
  20071. * Set the physics body. Used mainly by the physics engine/plugin
  20072. */
  20073. physicsBody: any;
  20074. /**
  20075. * Get the parent of the physics imposter
  20076. * @returns Physics imposter or null
  20077. */
  20078. /**
  20079. * Sets the parent of the physics imposter
  20080. */
  20081. parent: Nullable<PhysicsImpostor>;
  20082. /**
  20083. * Resets the update flags
  20084. */
  20085. resetUpdateFlags(): void;
  20086. /**
  20087. * Gets the object extend size
  20088. * @returns the object extend size
  20089. */
  20090. getObjectExtendSize(): Vector3;
  20091. /**
  20092. * Gets the object center
  20093. * @returns The object center
  20094. */
  20095. getObjectCenter(): Vector3;
  20096. /**
  20097. * Get a specific parametes from the options parameter
  20098. * @param paramName The object parameter name
  20099. * @returns The object parameter
  20100. */
  20101. getParam(paramName: string): any;
  20102. /**
  20103. * Sets a specific parameter in the options given to the physics plugin
  20104. * @param paramName The parameter name
  20105. * @param value The value of the parameter
  20106. */
  20107. setParam(paramName: string, value: number): void;
  20108. /**
  20109. * Specifically change the body's mass option. Won't recreate the physics body object
  20110. * @param mass The mass of the physics imposter
  20111. */
  20112. setMass(mass: number): void;
  20113. /**
  20114. * Gets the linear velocity
  20115. * @returns linear velocity or null
  20116. */
  20117. getLinearVelocity(): Nullable<Vector3>;
  20118. /**
  20119. * Sets the linear velocity
  20120. * @param velocity linear velocity or null
  20121. */
  20122. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20123. /**
  20124. * Gets the angular velocity
  20125. * @returns angular velocity or null
  20126. */
  20127. getAngularVelocity(): Nullable<Vector3>;
  20128. /**
  20129. * Sets the angular velocity
  20130. * @param velocity The velocity or null
  20131. */
  20132. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20133. /**
  20134. * Execute a function with the physics plugin native code
  20135. * Provide a function the will have two variables - the world object and the physics body object
  20136. * @param func The function to execute with the physics plugin native code
  20137. */
  20138. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20139. /**
  20140. * Register a function that will be executed before the physics world is stepping forward
  20141. * @param func The function to execute before the physics world is stepped forward
  20142. */
  20143. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20144. /**
  20145. * Unregister a function that will be executed before the physics world is stepping forward
  20146. * @param func The function to execute before the physics world is stepped forward
  20147. */
  20148. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20149. /**
  20150. * Register a function that will be executed after the physics step
  20151. * @param func The function to execute after physics step
  20152. */
  20153. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20154. /**
  20155. * Unregisters a function that will be executed after the physics step
  20156. * @param func The function to execute after physics step
  20157. */
  20158. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20159. /**
  20160. * register a function that will be executed when this impostor collides against a different body
  20161. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20162. * @param func Callback that is executed on collision
  20163. */
  20164. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20165. /**
  20166. * Unregisters the physics imposter on contact
  20167. * @param collideAgainst The physics object to collide against
  20168. * @param func Callback to execute on collision
  20169. */
  20170. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20171. private _tmpQuat;
  20172. private _tmpQuat2;
  20173. /**
  20174. * Get the parent rotation
  20175. * @returns The parent rotation
  20176. */
  20177. getParentsRotation(): Quaternion;
  20178. /**
  20179. * this function is executed by the physics engine.
  20180. */
  20181. beforeStep: () => void;
  20182. /**
  20183. * this function is executed by the physics engine
  20184. */
  20185. afterStep: () => void;
  20186. /**
  20187. * Legacy collision detection event support
  20188. */
  20189. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20190. /**
  20191. * event and body object due to cannon's event-based architecture.
  20192. */
  20193. onCollide: (e: {
  20194. body: any;
  20195. }) => void;
  20196. /**
  20197. * Apply a force
  20198. * @param force The force to apply
  20199. * @param contactPoint The contact point for the force
  20200. * @returns The physics imposter
  20201. */
  20202. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20203. /**
  20204. * Apply an impulse
  20205. * @param force The impulse force
  20206. * @param contactPoint The contact point for the impulse force
  20207. * @returns The physics imposter
  20208. */
  20209. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20210. /**
  20211. * A help function to create a joint
  20212. * @param otherImpostor A physics imposter used to create a joint
  20213. * @param jointType The type of joint
  20214. * @param jointData The data for the joint
  20215. * @returns The physics imposter
  20216. */
  20217. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20218. /**
  20219. * Add a joint to this impostor with a different impostor
  20220. * @param otherImpostor A physics imposter used to add a joint
  20221. * @param joint The joint to add
  20222. * @returns The physics imposter
  20223. */
  20224. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20225. /**
  20226. * Will keep this body still, in a sleep mode.
  20227. * @returns the physics imposter
  20228. */
  20229. sleep(): PhysicsImpostor;
  20230. /**
  20231. * Wake the body up.
  20232. * @returns The physics imposter
  20233. */
  20234. wakeUp(): PhysicsImpostor;
  20235. /**
  20236. * Clones the physics imposter
  20237. * @param newObject The physics imposter clones to this physics-enabled object
  20238. * @returns A nullable physics imposter
  20239. */
  20240. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20241. /**
  20242. * Disposes the physics imposter
  20243. */
  20244. dispose(): void;
  20245. /**
  20246. * Sets the delta position
  20247. * @param position The delta position amount
  20248. */
  20249. setDeltaPosition(position: Vector3): void;
  20250. /**
  20251. * Sets the delta rotation
  20252. * @param rotation The delta rotation amount
  20253. */
  20254. setDeltaRotation(rotation: Quaternion): void;
  20255. /**
  20256. * Gets the box size of the physics imposter and stores the result in the input parameter
  20257. * @param result Stores the box size
  20258. * @returns The physics imposter
  20259. */
  20260. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20261. /**
  20262. * Gets the radius of the physics imposter
  20263. * @returns Radius of the physics imposter
  20264. */
  20265. getRadius(): number;
  20266. /**
  20267. * Sync a bone with this impostor
  20268. * @param bone The bone to sync to the impostor.
  20269. * @param boneMesh The mesh that the bone is influencing.
  20270. * @param jointPivot The pivot of the joint / bone in local space.
  20271. * @param distToJoint Optional distance from the impostor to the joint.
  20272. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20273. */
  20274. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20275. /**
  20276. * Sync impostor to a bone
  20277. * @param bone The bone that the impostor will be synced to.
  20278. * @param boneMesh The mesh that the bone is influencing.
  20279. * @param jointPivot The pivot of the joint / bone in local space.
  20280. * @param distToJoint Optional distance from the impostor to the joint.
  20281. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20282. * @param boneAxis Optional vector3 axis the bone is aligned with
  20283. */
  20284. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20285. /**
  20286. * No-Imposter type
  20287. */
  20288. static NoImpostor: number;
  20289. /**
  20290. * Sphere-Imposter type
  20291. */
  20292. static SphereImpostor: number;
  20293. /**
  20294. * Box-Imposter type
  20295. */
  20296. static BoxImpostor: number;
  20297. /**
  20298. * Plane-Imposter type
  20299. */
  20300. static PlaneImpostor: number;
  20301. /**
  20302. * Mesh-imposter type
  20303. */
  20304. static MeshImpostor: number;
  20305. /**
  20306. * Cylinder-Imposter type
  20307. */
  20308. static CylinderImpostor: number;
  20309. /**
  20310. * Particle-Imposter type
  20311. */
  20312. static ParticleImpostor: number;
  20313. /**
  20314. * Heightmap-Imposter type
  20315. */
  20316. static HeightmapImpostor: number;
  20317. }
  20318. }
  20319. declare module "babylonjs/Meshes/mesh" {
  20320. import { Observable } from "babylonjs/Misc/observable";
  20321. import { IAnimatable } from "babylonjs/Misc/tools";
  20322. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20323. import { Camera } from "babylonjs/Cameras/camera";
  20324. import { Scene } from "babylonjs/scene";
  20325. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20326. import { Engine } from "babylonjs/Engines/engine";
  20327. import { Node } from "babylonjs/node";
  20328. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20329. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20330. import { Buffer } from "babylonjs/Meshes/buffer";
  20331. import { Geometry } from "babylonjs/Meshes/geometry";
  20332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20333. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20334. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20335. import { Effect } from "babylonjs/Materials/effect";
  20336. import { Material } from "babylonjs/Materials/material";
  20337. import { Skeleton } from "babylonjs/Bones/skeleton";
  20338. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20339. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20340. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20341. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20342. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20343. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20344. /**
  20345. * Class used to represent a specific level of detail of a mesh
  20346. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20347. */
  20348. export class MeshLODLevel {
  20349. /** Defines the distance where this level should star being displayed */
  20350. distance: number;
  20351. /** Defines the mesh to use to render this level */
  20352. mesh: Nullable<Mesh>;
  20353. /**
  20354. * Creates a new LOD level
  20355. * @param distance defines the distance where this level should star being displayed
  20356. * @param mesh defines the mesh to use to render this level
  20357. */
  20358. constructor(
  20359. /** Defines the distance where this level should star being displayed */
  20360. distance: number,
  20361. /** Defines the mesh to use to render this level */
  20362. mesh: Nullable<Mesh>);
  20363. }
  20364. /**
  20365. * @hidden
  20366. **/
  20367. export class _CreationDataStorage {
  20368. closePath?: boolean;
  20369. closeArray?: boolean;
  20370. idx: number[];
  20371. dashSize: number;
  20372. gapSize: number;
  20373. path3D: Path3D;
  20374. pathArray: Vector3[][];
  20375. arc: number;
  20376. radius: number;
  20377. cap: number;
  20378. tessellation: number;
  20379. }
  20380. /**
  20381. * @hidden
  20382. **/
  20383. class _InstanceDataStorage {
  20384. visibleInstances: any;
  20385. renderIdForInstances: number[];
  20386. batchCache: _InstancesBatch;
  20387. instancesBufferSize: number;
  20388. instancesBuffer: Nullable<Buffer>;
  20389. instancesData: Float32Array;
  20390. overridenInstanceCount: number;
  20391. }
  20392. /**
  20393. * @hidden
  20394. **/
  20395. export class _InstancesBatch {
  20396. mustReturn: boolean;
  20397. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20398. renderSelf: boolean[];
  20399. }
  20400. /**
  20401. * Class used to represent renderable models
  20402. */
  20403. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20404. /**
  20405. * Mesh side orientation : usually the external or front surface
  20406. */
  20407. static readonly FRONTSIDE: number;
  20408. /**
  20409. * Mesh side orientation : usually the internal or back surface
  20410. */
  20411. static readonly BACKSIDE: number;
  20412. /**
  20413. * Mesh side orientation : both internal and external or front and back surfaces
  20414. */
  20415. static readonly DOUBLESIDE: number;
  20416. /**
  20417. * Mesh side orientation : by default, `FRONTSIDE`
  20418. */
  20419. static readonly DEFAULTSIDE: number;
  20420. /**
  20421. * Mesh cap setting : no cap
  20422. */
  20423. static readonly NO_CAP: number;
  20424. /**
  20425. * Mesh cap setting : one cap at the beginning of the mesh
  20426. */
  20427. static readonly CAP_START: number;
  20428. /**
  20429. * Mesh cap setting : one cap at the end of the mesh
  20430. */
  20431. static readonly CAP_END: number;
  20432. /**
  20433. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20434. */
  20435. static readonly CAP_ALL: number;
  20436. /**
  20437. * Gets the default side orientation.
  20438. * @param orientation the orientation to value to attempt to get
  20439. * @returns the default orientation
  20440. * @hidden
  20441. */
  20442. static _GetDefaultSideOrientation(orientation?: number): number;
  20443. private _onBeforeRenderObservable;
  20444. private _onBeforeBindObservable;
  20445. private _onAfterRenderObservable;
  20446. private _onBeforeDrawObservable;
  20447. /**
  20448. * An event triggered before rendering the mesh
  20449. */
  20450. readonly onBeforeRenderObservable: Observable<Mesh>;
  20451. /**
  20452. * An event triggered before binding the mesh
  20453. */
  20454. readonly onBeforeBindObservable: Observable<Mesh>;
  20455. /**
  20456. * An event triggered after rendering the mesh
  20457. */
  20458. readonly onAfterRenderObservable: Observable<Mesh>;
  20459. /**
  20460. * An event triggered before drawing the mesh
  20461. */
  20462. readonly onBeforeDrawObservable: Observable<Mesh>;
  20463. private _onBeforeDrawObserver;
  20464. /**
  20465. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20466. */
  20467. onBeforeDraw: () => void;
  20468. /**
  20469. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20470. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20471. */
  20472. delayLoadState: number;
  20473. /**
  20474. * Gets the list of instances created from this mesh
  20475. * it is not supposed to be modified manually.
  20476. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20477. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20478. */
  20479. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20480. /**
  20481. * Gets the file containing delay loading data for this mesh
  20482. */
  20483. delayLoadingFile: string;
  20484. /** @hidden */
  20485. _binaryInfo: any;
  20486. private _LODLevels;
  20487. /**
  20488. * User defined function used to change how LOD level selection is done
  20489. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20490. */
  20491. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20492. private _morphTargetManager;
  20493. /**
  20494. * Gets or sets the morph target manager
  20495. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20496. */
  20497. morphTargetManager: Nullable<MorphTargetManager>;
  20498. /** @hidden */
  20499. _creationDataStorage: Nullable<_CreationDataStorage>;
  20500. /** @hidden */
  20501. _geometry: Nullable<Geometry>;
  20502. /** @hidden */
  20503. _delayInfo: Array<string>;
  20504. /** @hidden */
  20505. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20506. /** @hidden */
  20507. _instanceDataStorage: _InstanceDataStorage;
  20508. private _effectiveMaterial;
  20509. /** @hidden */
  20510. _shouldGenerateFlatShading: boolean;
  20511. private _preActivateId;
  20512. /** @hidden */
  20513. _originalBuilderSideOrientation: number;
  20514. /**
  20515. * Use this property to change the original side orientation defined at construction time
  20516. */
  20517. overrideMaterialSideOrientation: Nullable<number>;
  20518. private _areNormalsFrozen;
  20519. private _sourcePositions;
  20520. private _sourceNormals;
  20521. private _source;
  20522. private meshMap;
  20523. /**
  20524. * Gets the source mesh (the one used to clone this one from)
  20525. */
  20526. readonly source: Nullable<Mesh>;
  20527. /**
  20528. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20529. */
  20530. isUnIndexed: boolean;
  20531. /**
  20532. * @constructor
  20533. * @param name The value used by scene.getMeshByName() to do a lookup.
  20534. * @param scene The scene to add this mesh to.
  20535. * @param parent The parent of this mesh, if it has one
  20536. * @param source An optional Mesh from which geometry is shared, cloned.
  20537. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20538. * When false, achieved by calling a clone(), also passing False.
  20539. * This will make creation of children, recursive.
  20540. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20541. */
  20542. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20543. /**
  20544. * Gets the class name
  20545. * @returns the string "Mesh".
  20546. */
  20547. getClassName(): string;
  20548. /** @hidden */
  20549. readonly _isMesh: boolean;
  20550. /**
  20551. * Returns a description of this mesh
  20552. * @param fullDetails define if full details about this mesh must be used
  20553. * @returns a descriptive string representing this mesh
  20554. */
  20555. toString(fullDetails?: boolean): string;
  20556. /** @hidden */
  20557. _unBindEffect(): void;
  20558. /**
  20559. * Gets a boolean indicating if this mesh has LOD
  20560. */
  20561. readonly hasLODLevels: boolean;
  20562. /**
  20563. * Gets the list of MeshLODLevel associated with the current mesh
  20564. * @returns an array of MeshLODLevel
  20565. */
  20566. getLODLevels(): MeshLODLevel[];
  20567. private _sortLODLevels;
  20568. /**
  20569. * Add a mesh as LOD level triggered at the given distance.
  20570. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20571. * @param distance The distance from the center of the object to show this level
  20572. * @param mesh The mesh to be added as LOD level (can be null)
  20573. * @return This mesh (for chaining)
  20574. */
  20575. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20576. /**
  20577. * Returns the LOD level mesh at the passed distance or null if not found.
  20578. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20579. * @param distance The distance from the center of the object to show this level
  20580. * @returns a Mesh or `null`
  20581. */
  20582. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20583. /**
  20584. * Remove a mesh from the LOD array
  20585. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20586. * @param mesh defines the mesh to be removed
  20587. * @return This mesh (for chaining)
  20588. */
  20589. removeLODLevel(mesh: Mesh): Mesh;
  20590. /**
  20591. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20592. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20593. * @param camera defines the camera to use to compute distance
  20594. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20595. * @return This mesh (for chaining)
  20596. */
  20597. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20598. /**
  20599. * Gets the mesh internal Geometry object
  20600. */
  20601. readonly geometry: Nullable<Geometry>;
  20602. /**
  20603. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20604. * @returns the total number of vertices
  20605. */
  20606. getTotalVertices(): number;
  20607. /**
  20608. * Returns the content of an associated vertex buffer
  20609. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20610. * - VertexBuffer.PositionKind
  20611. * - VertexBuffer.UVKind
  20612. * - VertexBuffer.UV2Kind
  20613. * - VertexBuffer.UV3Kind
  20614. * - VertexBuffer.UV4Kind
  20615. * - VertexBuffer.UV5Kind
  20616. * - VertexBuffer.UV6Kind
  20617. * - VertexBuffer.ColorKind
  20618. * - VertexBuffer.MatricesIndicesKind
  20619. * - VertexBuffer.MatricesIndicesExtraKind
  20620. * - VertexBuffer.MatricesWeightsKind
  20621. * - VertexBuffer.MatricesWeightsExtraKind
  20622. * @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
  20623. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20624. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20625. */
  20626. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20627. /**
  20628. * Returns the mesh VertexBuffer object from the requested `kind`
  20629. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20630. * - VertexBuffer.PositionKind
  20631. * - VertexBuffer.UVKind
  20632. * - VertexBuffer.UV2Kind
  20633. * - VertexBuffer.UV3Kind
  20634. * - VertexBuffer.UV4Kind
  20635. * - VertexBuffer.UV5Kind
  20636. * - VertexBuffer.UV6Kind
  20637. * - VertexBuffer.ColorKind
  20638. * - VertexBuffer.MatricesIndicesKind
  20639. * - VertexBuffer.MatricesIndicesExtraKind
  20640. * - VertexBuffer.MatricesWeightsKind
  20641. * - VertexBuffer.MatricesWeightsExtraKind
  20642. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20643. */
  20644. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20645. /**
  20646. * Tests if a specific vertex buffer is associated with this mesh
  20647. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20648. * - VertexBuffer.PositionKind
  20649. * - VertexBuffer.UVKind
  20650. * - VertexBuffer.UV2Kind
  20651. * - VertexBuffer.UV3Kind
  20652. * - VertexBuffer.UV4Kind
  20653. * - VertexBuffer.UV5Kind
  20654. * - VertexBuffer.UV6Kind
  20655. * - VertexBuffer.ColorKind
  20656. * - VertexBuffer.MatricesIndicesKind
  20657. * - VertexBuffer.MatricesIndicesExtraKind
  20658. * - VertexBuffer.MatricesWeightsKind
  20659. * - VertexBuffer.MatricesWeightsExtraKind
  20660. * @returns a boolean
  20661. */
  20662. isVerticesDataPresent(kind: string): boolean;
  20663. /**
  20664. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20665. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20666. * - VertexBuffer.PositionKind
  20667. * - VertexBuffer.UVKind
  20668. * - VertexBuffer.UV2Kind
  20669. * - VertexBuffer.UV3Kind
  20670. * - VertexBuffer.UV4Kind
  20671. * - VertexBuffer.UV5Kind
  20672. * - VertexBuffer.UV6Kind
  20673. * - VertexBuffer.ColorKind
  20674. * - VertexBuffer.MatricesIndicesKind
  20675. * - VertexBuffer.MatricesIndicesExtraKind
  20676. * - VertexBuffer.MatricesWeightsKind
  20677. * - VertexBuffer.MatricesWeightsExtraKind
  20678. * @returns a boolean
  20679. */
  20680. isVertexBufferUpdatable(kind: string): boolean;
  20681. /**
  20682. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20683. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20684. * - VertexBuffer.PositionKind
  20685. * - VertexBuffer.UVKind
  20686. * - VertexBuffer.UV2Kind
  20687. * - VertexBuffer.UV3Kind
  20688. * - VertexBuffer.UV4Kind
  20689. * - VertexBuffer.UV5Kind
  20690. * - VertexBuffer.UV6Kind
  20691. * - VertexBuffer.ColorKind
  20692. * - VertexBuffer.MatricesIndicesKind
  20693. * - VertexBuffer.MatricesIndicesExtraKind
  20694. * - VertexBuffer.MatricesWeightsKind
  20695. * - VertexBuffer.MatricesWeightsExtraKind
  20696. * @returns an array of strings
  20697. */
  20698. getVerticesDataKinds(): string[];
  20699. /**
  20700. * Returns a positive integer : the total number of indices in this mesh geometry.
  20701. * @returns the numner of indices or zero if the mesh has no geometry.
  20702. */
  20703. getTotalIndices(): number;
  20704. /**
  20705. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20706. * @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.
  20707. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20708. * @returns the indices array or an empty array if the mesh has no geometry
  20709. */
  20710. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20711. readonly isBlocked: boolean;
  20712. /**
  20713. * Determine if the current mesh is ready to be rendered
  20714. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20715. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20716. * @returns true if all associated assets are ready (material, textures, shaders)
  20717. */
  20718. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20719. /**
  20720. * 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.
  20721. */
  20722. readonly areNormalsFrozen: boolean;
  20723. /**
  20724. * 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.
  20725. * @returns the current mesh
  20726. */
  20727. freezeNormals(): Mesh;
  20728. /**
  20729. * 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
  20730. * @returns the current mesh
  20731. */
  20732. unfreezeNormals(): Mesh;
  20733. /**
  20734. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20735. */
  20736. overridenInstanceCount: number;
  20737. /** @hidden */
  20738. _preActivate(): Mesh;
  20739. /** @hidden */
  20740. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20741. /** @hidden */
  20742. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20743. /**
  20744. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20745. * This means the mesh underlying bounding box and sphere are recomputed.
  20746. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20747. * @returns the current mesh
  20748. */
  20749. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20750. /** @hidden */
  20751. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20752. /**
  20753. * This function will subdivide the mesh into multiple submeshes
  20754. * @param count defines the expected number of submeshes
  20755. */
  20756. subdivide(count: number): void;
  20757. /**
  20758. * Copy a FloatArray into a specific associated vertex buffer
  20759. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20760. * - VertexBuffer.PositionKind
  20761. * - VertexBuffer.UVKind
  20762. * - VertexBuffer.UV2Kind
  20763. * - VertexBuffer.UV3Kind
  20764. * - VertexBuffer.UV4Kind
  20765. * - VertexBuffer.UV5Kind
  20766. * - VertexBuffer.UV6Kind
  20767. * - VertexBuffer.ColorKind
  20768. * - VertexBuffer.MatricesIndicesKind
  20769. * - VertexBuffer.MatricesIndicesExtraKind
  20770. * - VertexBuffer.MatricesWeightsKind
  20771. * - VertexBuffer.MatricesWeightsExtraKind
  20772. * @param data defines the data source
  20773. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20774. * @param stride defines the data stride size (can be null)
  20775. * @returns the current mesh
  20776. */
  20777. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20778. /**
  20779. * Flags an associated vertex buffer as updatable
  20780. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20781. * - VertexBuffer.PositionKind
  20782. * - VertexBuffer.UVKind
  20783. * - VertexBuffer.UV2Kind
  20784. * - VertexBuffer.UV3Kind
  20785. * - VertexBuffer.UV4Kind
  20786. * - VertexBuffer.UV5Kind
  20787. * - VertexBuffer.UV6Kind
  20788. * - VertexBuffer.ColorKind
  20789. * - VertexBuffer.MatricesIndicesKind
  20790. * - VertexBuffer.MatricesIndicesExtraKind
  20791. * - VertexBuffer.MatricesWeightsKind
  20792. * - VertexBuffer.MatricesWeightsExtraKind
  20793. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20794. */
  20795. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20796. /**
  20797. * Sets the mesh global Vertex Buffer
  20798. * @param buffer defines the buffer to use
  20799. * @returns the current mesh
  20800. */
  20801. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20802. /**
  20803. * Update a specific associated vertex buffer
  20804. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20805. * - VertexBuffer.PositionKind
  20806. * - VertexBuffer.UVKind
  20807. * - VertexBuffer.UV2Kind
  20808. * - VertexBuffer.UV3Kind
  20809. * - VertexBuffer.UV4Kind
  20810. * - VertexBuffer.UV5Kind
  20811. * - VertexBuffer.UV6Kind
  20812. * - VertexBuffer.ColorKind
  20813. * - VertexBuffer.MatricesIndicesKind
  20814. * - VertexBuffer.MatricesIndicesExtraKind
  20815. * - VertexBuffer.MatricesWeightsKind
  20816. * - VertexBuffer.MatricesWeightsExtraKind
  20817. * @param data defines the data source
  20818. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20819. * @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)
  20820. * @returns the current mesh
  20821. */
  20822. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20823. /**
  20824. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20825. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20826. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20827. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20828. * @returns the current mesh
  20829. */
  20830. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20831. /**
  20832. * Creates a un-shared specific occurence of the geometry for the mesh.
  20833. * @returns the current mesh
  20834. */
  20835. makeGeometryUnique(): Mesh;
  20836. /**
  20837. * Set the index buffer of this mesh
  20838. * @param indices defines the source data
  20839. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20840. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20841. * @returns the current mesh
  20842. */
  20843. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20844. /**
  20845. * Update the current index buffer
  20846. * @param indices defines the source data
  20847. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20848. * @returns the current mesh
  20849. */
  20850. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20851. /**
  20852. * Invert the geometry to move from a right handed system to a left handed one.
  20853. * @returns the current mesh
  20854. */
  20855. toLeftHanded(): Mesh;
  20856. /** @hidden */
  20857. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20858. /** @hidden */
  20859. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20860. /**
  20861. * Registers for this mesh a javascript function called just before the rendering process
  20862. * @param func defines the function to call before rendering this mesh
  20863. * @returns the current mesh
  20864. */
  20865. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20866. /**
  20867. * Disposes a previously registered javascript function called before the rendering
  20868. * @param func defines the function to remove
  20869. * @returns the current mesh
  20870. */
  20871. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20872. /**
  20873. * Registers for this mesh a javascript function called just after the rendering is complete
  20874. * @param func defines the function to call after rendering this mesh
  20875. * @returns the current mesh
  20876. */
  20877. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20878. /**
  20879. * Disposes a previously registered javascript function called after the rendering.
  20880. * @param func defines the function to remove
  20881. * @returns the current mesh
  20882. */
  20883. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20884. /** @hidden */
  20885. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20886. /** @hidden */
  20887. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20888. /** @hidden */
  20889. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20890. /**
  20891. * 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
  20892. * @param subMesh defines the subMesh to render
  20893. * @param enableAlphaMode defines if alpha mode can be changed
  20894. * @returns the current mesh
  20895. */
  20896. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20897. private _onBeforeDraw;
  20898. /**
  20899. * Renormalize the mesh and patch it up if there are no weights
  20900. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20901. * However in the case of zero weights then we set just a single influence to 1.
  20902. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20903. */
  20904. cleanMatrixWeights(): void;
  20905. private normalizeSkinFourWeights;
  20906. private normalizeSkinWeightsAndExtra;
  20907. /**
  20908. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20909. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20910. * the user know there was an issue with importing the mesh
  20911. * @returns a validation object with skinned, valid and report string
  20912. */
  20913. validateSkinning(): {
  20914. skinned: boolean;
  20915. valid: boolean;
  20916. report: string;
  20917. };
  20918. /** @hidden */
  20919. _checkDelayState(): Mesh;
  20920. private _queueLoad;
  20921. /**
  20922. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20923. * A mesh is in the frustum if its bounding box intersects the frustum
  20924. * @param frustumPlanes defines the frustum to test
  20925. * @returns true if the mesh is in the frustum planes
  20926. */
  20927. isInFrustum(frustumPlanes: Plane[]): boolean;
  20928. /**
  20929. * Sets the mesh material by the material or multiMaterial `id` property
  20930. * @param id is a string identifying the material or the multiMaterial
  20931. * @returns the current mesh
  20932. */
  20933. setMaterialByID(id: string): Mesh;
  20934. /**
  20935. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20936. * @returns an array of IAnimatable
  20937. */
  20938. getAnimatables(): IAnimatable[];
  20939. /**
  20940. * Modifies the mesh geometry according to the passed transformation matrix.
  20941. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20942. * The mesh normals are modified using the same transformation.
  20943. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20944. * @param transform defines the transform matrix to use
  20945. * @see http://doc.babylonjs.com/resources/baking_transformations
  20946. * @returns the current mesh
  20947. */
  20948. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20949. /**
  20950. * Modifies the mesh geometry according to its own current World Matrix.
  20951. * The mesh World Matrix is then reset.
  20952. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20953. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20954. * @see http://doc.babylonjs.com/resources/baking_transformations
  20955. * @returns the current mesh
  20956. */
  20957. bakeCurrentTransformIntoVertices(): Mesh;
  20958. /** @hidden */
  20959. readonly _positions: Nullable<Vector3[]>;
  20960. /** @hidden */
  20961. _resetPointsArrayCache(): Mesh;
  20962. /** @hidden */
  20963. _generatePointsArray(): boolean;
  20964. /**
  20965. * Returns a new Mesh object generated from the current mesh properties.
  20966. * This method must not get confused with createInstance()
  20967. * @param name is a string, the name given to the new mesh
  20968. * @param newParent can be any Node object (default `null`)
  20969. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20970. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20971. * @returns a new mesh
  20972. */
  20973. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20974. /**
  20975. * Releases resources associated with this mesh.
  20976. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20977. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20978. */
  20979. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20980. /**
  20981. * Modifies the mesh geometry according to a displacement map.
  20982. * 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.
  20983. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20984. * @param url is a string, the URL from the image file is to be downloaded.
  20985. * @param minHeight is the lower limit of the displacement.
  20986. * @param maxHeight is the upper limit of the displacement.
  20987. * @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.
  20988. * @param uvOffset is an optional vector2 used to offset UV.
  20989. * @param uvScale is an optional vector2 used to scale UV.
  20990. * @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.
  20991. * @returns the Mesh.
  20992. */
  20993. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20994. /**
  20995. * Modifies the mesh geometry according to a displacementMap buffer.
  20996. * 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.
  20997. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20998. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20999. * @param heightMapWidth is the width of the buffer image.
  21000. * @param heightMapHeight is the height of the buffer image.
  21001. * @param minHeight is the lower limit of the displacement.
  21002. * @param maxHeight is the upper limit of the displacement.
  21003. * @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.
  21004. * @param uvOffset is an optional vector2 used to offset UV.
  21005. * @param uvScale is an optional vector2 used to scale UV.
  21006. * @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.
  21007. * @returns the Mesh.
  21008. */
  21009. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21010. /**
  21011. * Modify the mesh to get a flat shading rendering.
  21012. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21013. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21014. * @returns current mesh
  21015. */
  21016. convertToFlatShadedMesh(): Mesh;
  21017. /**
  21018. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21019. * In other words, more vertices, no more indices and a single bigger VBO.
  21020. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21021. * @returns current mesh
  21022. */
  21023. convertToUnIndexedMesh(): Mesh;
  21024. /**
  21025. * Inverses facet orientations.
  21026. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21027. * @param flipNormals will also inverts the normals
  21028. * @returns current mesh
  21029. */
  21030. flipFaces(flipNormals?: boolean): Mesh;
  21031. /** @hidden */
  21032. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21033. /** @hidden */
  21034. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21035. /**
  21036. * Creates a new InstancedMesh object from the mesh model.
  21037. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21038. * @param name defines the name of the new instance
  21039. * @returns a new InstancedMesh
  21040. */
  21041. createInstance(name: string): InstancedMesh;
  21042. /**
  21043. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21044. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21045. * @returns the current mesh
  21046. */
  21047. synchronizeInstances(): Mesh;
  21048. /**
  21049. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21050. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21051. * This should be used together with the simplification to avoid disappearing triangles.
  21052. * @param successCallback an optional success callback to be called after the optimization finished.
  21053. * @returns the current mesh
  21054. */
  21055. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21056. /**
  21057. * Serialize current mesh
  21058. * @param serializationObject defines the object which will receive the serialization data
  21059. */
  21060. serialize(serializationObject: any): void;
  21061. /** @hidden */
  21062. _syncGeometryWithMorphTargetManager(): void;
  21063. /** @hidden */
  21064. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21065. /**
  21066. * Returns a new Mesh object parsed from the source provided.
  21067. * @param parsedMesh is the source
  21068. * @param scene defines the hosting scene
  21069. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21070. * @returns a new Mesh
  21071. */
  21072. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21073. /**
  21074. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21075. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21076. * @param name defines the name of the mesh to create
  21077. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21078. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21079. * @param closePath creates a seam between the first and the last points of each path of the path array
  21080. * @param offset is taken in account only if the `pathArray` is containing a single path
  21081. * @param scene defines the hosting scene
  21082. * @param updatable defines if the mesh must be flagged as updatable
  21083. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21084. * @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)
  21085. * @returns a new Mesh
  21086. */
  21087. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21088. /**
  21089. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21090. * @param name defines the name of the mesh to create
  21091. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21092. * @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
  21093. * @param scene defines the hosting scene
  21094. * @param updatable defines if the mesh must be flagged as updatable
  21095. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21096. * @returns a new Mesh
  21097. */
  21098. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21099. /**
  21100. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21101. * @param name defines the name of the mesh to create
  21102. * @param size sets the size (float) of each box side (default 1)
  21103. * @param scene defines the hosting scene
  21104. * @param updatable defines if the mesh must be flagged as updatable
  21105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21106. * @returns a new Mesh
  21107. */
  21108. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21109. /**
  21110. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21111. * @param name defines the name of the mesh to create
  21112. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21113. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21114. * @param scene defines the hosting scene
  21115. * @param updatable defines if the mesh must be flagged as updatable
  21116. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21117. * @returns a new Mesh
  21118. */
  21119. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21120. /**
  21121. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21122. * @param name defines the name of the mesh to create
  21123. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21124. * @param diameterTop set the top cap diameter (floats, default 1)
  21125. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21126. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21127. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21128. * @param scene defines the hosting scene
  21129. * @param updatable defines if the mesh must be flagged as updatable
  21130. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21131. * @returns a new Mesh
  21132. */
  21133. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21134. /**
  21135. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21136. * @param name defines the name of the mesh to create
  21137. * @param diameter sets the diameter size (float) of the torus (default 1)
  21138. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21139. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21140. * @param scene defines the hosting scene
  21141. * @param updatable defines if the mesh must be flagged as updatable
  21142. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21143. * @returns a new Mesh
  21144. */
  21145. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21146. /**
  21147. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21148. * @param name defines the name of the mesh to create
  21149. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21150. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21151. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21152. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21153. * @param p the number of windings on X axis (positive integers, default 2)
  21154. * @param q the number of windings on Y axis (positive integers, default 3)
  21155. * @param scene defines the hosting scene
  21156. * @param updatable defines if the mesh must be flagged as updatable
  21157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21158. * @returns a new Mesh
  21159. */
  21160. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21161. /**
  21162. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21163. * @param name defines the name of the mesh to create
  21164. * @param points is an array successive Vector3
  21165. * @param scene defines the hosting scene
  21166. * @param updatable defines if the mesh must be flagged as updatable
  21167. * @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).
  21168. * @returns a new Mesh
  21169. */
  21170. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21171. /**
  21172. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21173. * @param name defines the name of the mesh to create
  21174. * @param points is an array successive Vector3
  21175. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21176. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21177. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21178. * @param scene defines the hosting scene
  21179. * @param updatable defines if the mesh must be flagged as updatable
  21180. * @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)
  21181. * @returns a new Mesh
  21182. */
  21183. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21184. /**
  21185. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21186. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21187. * 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.
  21188. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21189. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21190. * Remember you can only change the shape positions, not their number when updating a polygon.
  21191. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21192. * @param name defines the name of the mesh to create
  21193. * @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
  21194. * @param scene defines the hosting scene
  21195. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21196. * @param updatable defines if the mesh must be flagged as updatable
  21197. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21198. * @param earcutInjection can be used to inject your own earcut reference
  21199. * @returns a new Mesh
  21200. */
  21201. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21202. /**
  21203. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21204. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21205. * @param name defines the name of the mesh to create
  21206. * @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
  21207. * @param depth defines the height of extrusion
  21208. * @param scene defines the hosting scene
  21209. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21210. * @param updatable defines if the mesh must be flagged as updatable
  21211. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21212. * @param earcutInjection can be used to inject your own earcut reference
  21213. * @returns a new Mesh
  21214. */
  21215. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21216. /**
  21217. * Creates an extruded shape mesh.
  21218. * 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
  21219. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21220. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21221. * @param name defines the name of the mesh to create
  21222. * @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
  21223. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21224. * @param scale is the value to scale the shape
  21225. * @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
  21226. * @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
  21227. * @param scene defines the hosting scene
  21228. * @param updatable defines if the mesh must be flagged as updatable
  21229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21230. * @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)
  21231. * @returns a new Mesh
  21232. */
  21233. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21234. /**
  21235. * Creates an custom extruded shape mesh.
  21236. * The custom extrusion is a parametric shape.
  21237. * It has no predefined shape. Its final shape will depend on the input parameters.
  21238. * Please consider using the same method from the MeshBuilder class instead
  21239. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21240. * @param name defines the name of the mesh to create
  21241. * @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
  21242. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21243. * @param scaleFunction is a custom Javascript function called on each path point
  21244. * @param rotationFunction is a custom Javascript function called on each path point
  21245. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21246. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21247. * @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
  21248. * @param scene defines the hosting scene
  21249. * @param updatable defines if the mesh must be flagged as updatable
  21250. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21251. * @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)
  21252. * @returns a new Mesh
  21253. */
  21254. 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;
  21255. /**
  21256. * Creates lathe mesh.
  21257. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21258. * Please consider using the same method from the MeshBuilder class instead
  21259. * @param name defines the name of the mesh to create
  21260. * @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
  21261. * @param radius is the radius value of the lathe
  21262. * @param tessellation is the side number of the lathe.
  21263. * @param scene defines the hosting scene
  21264. * @param updatable defines if the mesh must be flagged as updatable
  21265. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21266. * @returns a new Mesh
  21267. */
  21268. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21269. /**
  21270. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21271. * @param name defines the name of the mesh to create
  21272. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21273. * @param scene defines the hosting scene
  21274. * @param updatable defines if the mesh must be flagged as updatable
  21275. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21276. * @returns a new Mesh
  21277. */
  21278. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21279. /**
  21280. * Creates a ground mesh.
  21281. * Please consider using the same method from the MeshBuilder class instead
  21282. * @param name defines the name of the mesh to create
  21283. * @param width set the width of the ground
  21284. * @param height set the height of the ground
  21285. * @param subdivisions sets the number of subdivisions per side
  21286. * @param scene defines the hosting scene
  21287. * @param updatable defines if the mesh must be flagged as updatable
  21288. * @returns a new Mesh
  21289. */
  21290. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21291. /**
  21292. * Creates a tiled ground mesh.
  21293. * Please consider using the same method from the MeshBuilder class instead
  21294. * @param name defines the name of the mesh to create
  21295. * @param xmin set the ground minimum X coordinate
  21296. * @param zmin set the ground minimum Y coordinate
  21297. * @param xmax set the ground maximum X coordinate
  21298. * @param zmax set the ground maximum Z coordinate
  21299. * @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
  21300. * @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
  21301. * @param scene defines the hosting scene
  21302. * @param updatable defines if the mesh must be flagged as updatable
  21303. * @returns a new Mesh
  21304. */
  21305. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21306. w: number;
  21307. h: number;
  21308. }, precision: {
  21309. w: number;
  21310. h: number;
  21311. }, scene: Scene, updatable?: boolean): Mesh;
  21312. /**
  21313. * Creates a ground mesh from a height map.
  21314. * Please consider using the same method from the MeshBuilder class instead
  21315. * @see http://doc.babylonjs.com/babylon101/height_map
  21316. * @param name defines the name of the mesh to create
  21317. * @param url sets the URL of the height map image resource
  21318. * @param width set the ground width size
  21319. * @param height set the ground height size
  21320. * @param subdivisions sets the number of subdivision per side
  21321. * @param minHeight is the minimum altitude on the ground
  21322. * @param maxHeight is the maximum altitude on the ground
  21323. * @param scene defines the hosting scene
  21324. * @param updatable defines if the mesh must be flagged as updatable
  21325. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21326. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21327. * @returns a new Mesh
  21328. */
  21329. 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;
  21330. /**
  21331. * Creates a tube mesh.
  21332. * The tube is a parametric shape.
  21333. * It has no predefined shape. Its final shape will depend on the input parameters.
  21334. * Please consider using the same method from the MeshBuilder class instead
  21335. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21336. * @param name defines the name of the mesh to create
  21337. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21338. * @param radius sets the tube radius size
  21339. * @param tessellation is the number of sides on the tubular surface
  21340. * @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
  21341. * @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
  21342. * @param scene defines the hosting scene
  21343. * @param updatable defines if the mesh must be flagged as updatable
  21344. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21345. * @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)
  21346. * @returns a new Mesh
  21347. */
  21348. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21349. (i: number, distance: number): number;
  21350. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21351. /**
  21352. * Creates a polyhedron mesh.
  21353. * Please consider using the same method from the MeshBuilder class instead.
  21354. * * 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
  21355. * * The parameter `size` (positive float, default 1) sets the polygon size
  21356. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21357. * * 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`
  21358. * * 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
  21359. * * 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)`)
  21360. * * 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
  21361. * * 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
  21362. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21363. * * If you create a double-sided mesh, you can choose what parts of 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
  21364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21365. * @param name defines the name of the mesh to create
  21366. * @param options defines the options used to create the mesh
  21367. * @param scene defines the hosting scene
  21368. * @returns a new Mesh
  21369. */
  21370. static CreatePolyhedron(name: string, options: {
  21371. type?: number;
  21372. size?: number;
  21373. sizeX?: number;
  21374. sizeY?: number;
  21375. sizeZ?: number;
  21376. custom?: any;
  21377. faceUV?: Vector4[];
  21378. faceColors?: Color4[];
  21379. updatable?: boolean;
  21380. sideOrientation?: number;
  21381. }, scene: Scene): Mesh;
  21382. /**
  21383. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21384. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21385. * * 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`)
  21386. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21387. * * 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
  21388. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21389. * * If you create a double-sided mesh, you can choose what parts of 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
  21390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21391. * @param name defines the name of the mesh
  21392. * @param options defines the options used to create the mesh
  21393. * @param scene defines the hosting scene
  21394. * @returns a new Mesh
  21395. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21396. */
  21397. static CreateIcoSphere(name: string, options: {
  21398. radius?: number;
  21399. flat?: boolean;
  21400. subdivisions?: number;
  21401. sideOrientation?: number;
  21402. updatable?: boolean;
  21403. }, scene: Scene): Mesh;
  21404. /**
  21405. * Creates a decal mesh.
  21406. * Please consider using the same method from the MeshBuilder class instead.
  21407. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21408. * @param name defines the name of the mesh
  21409. * @param sourceMesh defines the mesh receiving the decal
  21410. * @param position sets the position of the decal in world coordinates
  21411. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21412. * @param size sets the decal scaling
  21413. * @param angle sets the angle to rotate the decal
  21414. * @returns a new Mesh
  21415. */
  21416. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21417. /**
  21418. * Prepare internal position array for software CPU skinning
  21419. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21420. */
  21421. setPositionsForCPUSkinning(): Float32Array;
  21422. /**
  21423. * Prepare internal normal array for software CPU skinning
  21424. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21425. */
  21426. setNormalsForCPUSkinning(): Float32Array;
  21427. /**
  21428. * Updates the vertex buffer by applying transformation from the bones
  21429. * @param skeleton defines the skeleton to apply to current mesh
  21430. * @returns the current mesh
  21431. */
  21432. applySkeleton(skeleton: Skeleton): Mesh;
  21433. /**
  21434. * 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
  21435. * @param meshes defines the list of meshes to scan
  21436. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21437. */
  21438. static MinMax(meshes: AbstractMesh[]): {
  21439. min: Vector3;
  21440. max: Vector3;
  21441. };
  21442. /**
  21443. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21444. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21445. * @returns a vector3
  21446. */
  21447. static Center(meshesOrMinMaxVector: {
  21448. min: Vector3;
  21449. max: Vector3;
  21450. } | AbstractMesh[]): Vector3;
  21451. /**
  21452. * Merge the array of meshes into a single mesh for performance reasons.
  21453. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21454. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21455. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21456. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21457. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21458. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21459. * @returns a new mesh
  21460. */
  21461. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21462. /** @hidden */
  21463. addInstance(instance: InstancedMesh): void;
  21464. /** @hidden */
  21465. removeInstance(instance: InstancedMesh): void;
  21466. }
  21467. }
  21468. declare module "babylonjs/Materials/material" {
  21469. import { IAnimatable } from "babylonjs/Misc/tools";
  21470. import { SmartArray } from "babylonjs/Misc/smartArray";
  21471. import { Observable } from "babylonjs/Misc/observable";
  21472. import { Nullable } from "babylonjs/types";
  21473. import { Scene } from "babylonjs/scene";
  21474. import { Matrix } from "babylonjs/Maths/math";
  21475. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21477. import { Mesh } from "babylonjs/Meshes/mesh";
  21478. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21479. import { Effect } from "babylonjs/Materials/effect";
  21480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21481. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21482. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21483. import { Animation } from "babylonjs/Animations/animation";
  21484. /**
  21485. * Base class for the main features of a material in Babylon.js
  21486. */
  21487. export class Material implements IAnimatable {
  21488. /**
  21489. * Returns the triangle fill mode
  21490. */
  21491. static readonly TriangleFillMode: number;
  21492. /**
  21493. * Returns the wireframe mode
  21494. */
  21495. static readonly WireFrameFillMode: number;
  21496. /**
  21497. * Returns the point fill mode
  21498. */
  21499. static readonly PointFillMode: number;
  21500. /**
  21501. * Returns the point list draw mode
  21502. */
  21503. static readonly PointListDrawMode: number;
  21504. /**
  21505. * Returns the line list draw mode
  21506. */
  21507. static readonly LineListDrawMode: number;
  21508. /**
  21509. * Returns the line loop draw mode
  21510. */
  21511. static readonly LineLoopDrawMode: number;
  21512. /**
  21513. * Returns the line strip draw mode
  21514. */
  21515. static readonly LineStripDrawMode: number;
  21516. /**
  21517. * Returns the triangle strip draw mode
  21518. */
  21519. static readonly TriangleStripDrawMode: number;
  21520. /**
  21521. * Returns the triangle fan draw mode
  21522. */
  21523. static readonly TriangleFanDrawMode: number;
  21524. /**
  21525. * Stores the clock-wise side orientation
  21526. */
  21527. static readonly ClockWiseSideOrientation: number;
  21528. /**
  21529. * Stores the counter clock-wise side orientation
  21530. */
  21531. static readonly CounterClockWiseSideOrientation: number;
  21532. /**
  21533. * The dirty texture flag value
  21534. */
  21535. static readonly TextureDirtyFlag: number;
  21536. /**
  21537. * The dirty light flag value
  21538. */
  21539. static readonly LightDirtyFlag: number;
  21540. /**
  21541. * The dirty fresnel flag value
  21542. */
  21543. static readonly FresnelDirtyFlag: number;
  21544. /**
  21545. * The dirty attribute flag value
  21546. */
  21547. static readonly AttributesDirtyFlag: number;
  21548. /**
  21549. * The dirty misc flag value
  21550. */
  21551. static readonly MiscDirtyFlag: number;
  21552. /**
  21553. * The all dirty flag value
  21554. */
  21555. static readonly AllDirtyFlag: number;
  21556. /**
  21557. * The ID of the material
  21558. */
  21559. id: string;
  21560. /**
  21561. * Gets or sets the unique id of the material
  21562. */
  21563. uniqueId: number;
  21564. /**
  21565. * The name of the material
  21566. */
  21567. name: string;
  21568. /**
  21569. * Gets or sets user defined metadata
  21570. */
  21571. metadata: any;
  21572. /**
  21573. * For internal use only. Please do not use.
  21574. */
  21575. reservedDataStore: any;
  21576. /**
  21577. * Specifies if the ready state should be checked on each call
  21578. */
  21579. checkReadyOnEveryCall: boolean;
  21580. /**
  21581. * Specifies if the ready state should be checked once
  21582. */
  21583. checkReadyOnlyOnce: boolean;
  21584. /**
  21585. * The state of the material
  21586. */
  21587. state: string;
  21588. /**
  21589. * The alpha value of the material
  21590. */
  21591. protected _alpha: number;
  21592. /**
  21593. * Sets the alpha value of the material
  21594. */
  21595. /**
  21596. * Gets the alpha value of the material
  21597. */
  21598. alpha: number;
  21599. /**
  21600. * Specifies if back face culling is enabled
  21601. */
  21602. protected _backFaceCulling: boolean;
  21603. /**
  21604. * Sets the back-face culling state
  21605. */
  21606. /**
  21607. * Gets the back-face culling state
  21608. */
  21609. backFaceCulling: boolean;
  21610. /**
  21611. * Stores the value for side orientation
  21612. */
  21613. sideOrientation: number;
  21614. /**
  21615. * Callback triggered when the material is compiled
  21616. */
  21617. onCompiled: (effect: Effect) => void;
  21618. /**
  21619. * Callback triggered when an error occurs
  21620. */
  21621. onError: (effect: Effect, errors: string) => void;
  21622. /**
  21623. * Callback triggered to get the render target textures
  21624. */
  21625. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21626. /**
  21627. * Gets a boolean indicating that current material needs to register RTT
  21628. */
  21629. readonly hasRenderTargetTextures: boolean;
  21630. /**
  21631. * Specifies if the material should be serialized
  21632. */
  21633. doNotSerialize: boolean;
  21634. /**
  21635. * @hidden
  21636. */
  21637. _storeEffectOnSubMeshes: boolean;
  21638. /**
  21639. * Stores the animations for the material
  21640. */
  21641. animations: Array<Animation>;
  21642. /**
  21643. * An event triggered when the material is disposed
  21644. */
  21645. onDisposeObservable: Observable<Material>;
  21646. /**
  21647. * An observer which watches for dispose events
  21648. */
  21649. private _onDisposeObserver;
  21650. private _onUnBindObservable;
  21651. /**
  21652. * Called during a dispose event
  21653. */
  21654. onDispose: () => void;
  21655. private _onBindObservable;
  21656. /**
  21657. * An event triggered when the material is bound
  21658. */
  21659. readonly onBindObservable: Observable<AbstractMesh>;
  21660. /**
  21661. * An observer which watches for bind events
  21662. */
  21663. private _onBindObserver;
  21664. /**
  21665. * Called during a bind event
  21666. */
  21667. onBind: (Mesh: AbstractMesh) => void;
  21668. /**
  21669. * An event triggered when the material is unbound
  21670. */
  21671. readonly onUnBindObservable: Observable<Material>;
  21672. /**
  21673. * Stores the value of the alpha mode
  21674. */
  21675. private _alphaMode;
  21676. /**
  21677. * Sets the value of the alpha mode.
  21678. *
  21679. * | Value | Type | Description |
  21680. * | --- | --- | --- |
  21681. * | 0 | ALPHA_DISABLE | |
  21682. * | 1 | ALPHA_ADD | |
  21683. * | 2 | ALPHA_COMBINE | |
  21684. * | 3 | ALPHA_SUBTRACT | |
  21685. * | 4 | ALPHA_MULTIPLY | |
  21686. * | 5 | ALPHA_MAXIMIZED | |
  21687. * | 6 | ALPHA_ONEONE | |
  21688. * | 7 | ALPHA_PREMULTIPLIED | |
  21689. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21690. * | 9 | ALPHA_INTERPOLATE | |
  21691. * | 10 | ALPHA_SCREENMODE | |
  21692. *
  21693. */
  21694. /**
  21695. * Gets the value of the alpha mode
  21696. */
  21697. alphaMode: number;
  21698. /**
  21699. * Stores the state of the need depth pre-pass value
  21700. */
  21701. private _needDepthPrePass;
  21702. /**
  21703. * Sets the need depth pre-pass value
  21704. */
  21705. /**
  21706. * Gets the depth pre-pass value
  21707. */
  21708. needDepthPrePass: boolean;
  21709. /**
  21710. * Specifies if depth writing should be disabled
  21711. */
  21712. disableDepthWrite: boolean;
  21713. /**
  21714. * Specifies if depth writing should be forced
  21715. */
  21716. forceDepthWrite: boolean;
  21717. /**
  21718. * Specifies if there should be a separate pass for culling
  21719. */
  21720. separateCullingPass: boolean;
  21721. /**
  21722. * Stores the state specifing if fog should be enabled
  21723. */
  21724. private _fogEnabled;
  21725. /**
  21726. * Sets the state for enabling fog
  21727. */
  21728. /**
  21729. * Gets the value of the fog enabled state
  21730. */
  21731. fogEnabled: boolean;
  21732. /**
  21733. * Stores the size of points
  21734. */
  21735. pointSize: number;
  21736. /**
  21737. * Stores the z offset value
  21738. */
  21739. zOffset: number;
  21740. /**
  21741. * Gets a value specifying if wireframe mode is enabled
  21742. */
  21743. /**
  21744. * Sets the state of wireframe mode
  21745. */
  21746. wireframe: boolean;
  21747. /**
  21748. * Gets the value specifying if point clouds are enabled
  21749. */
  21750. /**
  21751. * Sets the state of point cloud mode
  21752. */
  21753. pointsCloud: boolean;
  21754. /**
  21755. * Gets the material fill mode
  21756. */
  21757. /**
  21758. * Sets the material fill mode
  21759. */
  21760. fillMode: number;
  21761. /**
  21762. * @hidden
  21763. * Stores the effects for the material
  21764. */
  21765. _effect: Nullable<Effect>;
  21766. /**
  21767. * @hidden
  21768. * Specifies if the material was previously ready
  21769. */
  21770. _wasPreviouslyReady: boolean;
  21771. /**
  21772. * Specifies if uniform buffers should be used
  21773. */
  21774. private _useUBO;
  21775. /**
  21776. * Stores a reference to the scene
  21777. */
  21778. private _scene;
  21779. /**
  21780. * Stores the fill mode state
  21781. */
  21782. private _fillMode;
  21783. /**
  21784. * Specifies if the depth write state should be cached
  21785. */
  21786. private _cachedDepthWriteState;
  21787. /**
  21788. * Stores the uniform buffer
  21789. */
  21790. protected _uniformBuffer: UniformBuffer;
  21791. /** @hidden */
  21792. _indexInSceneMaterialArray: number;
  21793. /** @hidden */
  21794. meshMap: Nullable<{
  21795. [id: string]: AbstractMesh | undefined;
  21796. }>;
  21797. /**
  21798. * Creates a material instance
  21799. * @param name defines the name of the material
  21800. * @param scene defines the scene to reference
  21801. * @param doNotAdd specifies if the material should be added to the scene
  21802. */
  21803. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21804. /**
  21805. * Returns a string representation of the current material
  21806. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21807. * @returns a string with material information
  21808. */
  21809. toString(fullDetails?: boolean): string;
  21810. /**
  21811. * Gets the class name of the material
  21812. * @returns a string with the class name of the material
  21813. */
  21814. getClassName(): string;
  21815. /**
  21816. * Specifies if updates for the material been locked
  21817. */
  21818. readonly isFrozen: boolean;
  21819. /**
  21820. * Locks updates for the material
  21821. */
  21822. freeze(): void;
  21823. /**
  21824. * Unlocks updates for the material
  21825. */
  21826. unfreeze(): void;
  21827. /**
  21828. * Specifies if the material is ready to be used
  21829. * @param mesh defines the mesh to check
  21830. * @param useInstances specifies if instances should be used
  21831. * @returns a boolean indicating if the material is ready to be used
  21832. */
  21833. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21834. /**
  21835. * Specifies that the submesh is ready to be used
  21836. * @param mesh defines the mesh to check
  21837. * @param subMesh defines which submesh to check
  21838. * @param useInstances specifies that instances should be used
  21839. * @returns a boolean indicating that the submesh is ready or not
  21840. */
  21841. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21842. /**
  21843. * Returns the material effect
  21844. * @returns the effect associated with the material
  21845. */
  21846. getEffect(): Nullable<Effect>;
  21847. /**
  21848. * Returns the current scene
  21849. * @returns a Scene
  21850. */
  21851. getScene(): Scene;
  21852. /**
  21853. * Specifies if the material will require alpha blending
  21854. * @returns a boolean specifying if alpha blending is needed
  21855. */
  21856. needAlphaBlending(): boolean;
  21857. /**
  21858. * Specifies if the mesh will require alpha blending
  21859. * @param mesh defines the mesh to check
  21860. * @returns a boolean specifying if alpha blending is needed for the mesh
  21861. */
  21862. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21863. /**
  21864. * Specifies if this material should be rendered in alpha test mode
  21865. * @returns a boolean specifying if an alpha test is needed.
  21866. */
  21867. needAlphaTesting(): boolean;
  21868. /**
  21869. * Gets the texture used for the alpha test
  21870. * @returns the texture to use for alpha testing
  21871. */
  21872. getAlphaTestTexture(): Nullable<BaseTexture>;
  21873. /**
  21874. * Marks the material to indicate that it needs to be re-calculated
  21875. */
  21876. markDirty(): void;
  21877. /** @hidden */
  21878. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21879. /**
  21880. * Binds the material to the mesh
  21881. * @param world defines the world transformation matrix
  21882. * @param mesh defines the mesh to bind the material to
  21883. */
  21884. bind(world: Matrix, mesh?: Mesh): void;
  21885. /**
  21886. * Binds the submesh to the material
  21887. * @param world defines the world transformation matrix
  21888. * @param mesh defines the mesh containing the submesh
  21889. * @param subMesh defines the submesh to bind the material to
  21890. */
  21891. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21892. /**
  21893. * Binds the world matrix to the material
  21894. * @param world defines the world transformation matrix
  21895. */
  21896. bindOnlyWorldMatrix(world: Matrix): void;
  21897. /**
  21898. * Binds the scene's uniform buffer to the effect.
  21899. * @param effect defines the effect to bind to the scene uniform buffer
  21900. * @param sceneUbo defines the uniform buffer storing scene data
  21901. */
  21902. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21903. /**
  21904. * Binds the view matrix to the effect
  21905. * @param effect defines the effect to bind the view matrix to
  21906. */
  21907. bindView(effect: Effect): void;
  21908. /**
  21909. * Binds the view projection matrix to the effect
  21910. * @param effect defines the effect to bind the view projection matrix to
  21911. */
  21912. bindViewProjection(effect: Effect): void;
  21913. /**
  21914. * Specifies if material alpha testing should be turned on for the mesh
  21915. * @param mesh defines the mesh to check
  21916. */
  21917. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21918. /**
  21919. * Processes to execute after binding the material to a mesh
  21920. * @param mesh defines the rendered mesh
  21921. */
  21922. protected _afterBind(mesh?: Mesh): void;
  21923. /**
  21924. * Unbinds the material from the mesh
  21925. */
  21926. unbind(): void;
  21927. /**
  21928. * Gets the active textures from the material
  21929. * @returns an array of textures
  21930. */
  21931. getActiveTextures(): BaseTexture[];
  21932. /**
  21933. * Specifies if the material uses a texture
  21934. * @param texture defines the texture to check against the material
  21935. * @returns a boolean specifying if the material uses the texture
  21936. */
  21937. hasTexture(texture: BaseTexture): boolean;
  21938. /**
  21939. * Makes a duplicate of the material, and gives it a new name
  21940. * @param name defines the new name for the duplicated material
  21941. * @returns the cloned material
  21942. */
  21943. clone(name: string): Nullable<Material>;
  21944. /**
  21945. * Gets the meshes bound to the material
  21946. * @returns an array of meshes bound to the material
  21947. */
  21948. getBindedMeshes(): AbstractMesh[];
  21949. /**
  21950. * Force shader compilation
  21951. * @param mesh defines the mesh associated with this material
  21952. * @param onCompiled defines a function to execute once the material is compiled
  21953. * @param options defines the options to configure the compilation
  21954. */
  21955. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21956. clipPlane: boolean;
  21957. }>): void;
  21958. /**
  21959. * Force shader compilation
  21960. * @param mesh defines the mesh that will use this material
  21961. * @param options defines additional options for compiling the shaders
  21962. * @returns a promise that resolves when the compilation completes
  21963. */
  21964. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21965. clipPlane: boolean;
  21966. }>): Promise<void>;
  21967. private static readonly _ImageProcessingDirtyCallBack;
  21968. private static readonly _TextureDirtyCallBack;
  21969. private static readonly _FresnelDirtyCallBack;
  21970. private static readonly _MiscDirtyCallBack;
  21971. private static readonly _LightsDirtyCallBack;
  21972. private static readonly _AttributeDirtyCallBack;
  21973. private static _FresnelAndMiscDirtyCallBack;
  21974. private static _TextureAndMiscDirtyCallBack;
  21975. private static readonly _DirtyCallbackArray;
  21976. private static readonly _RunDirtyCallBacks;
  21977. /**
  21978. * Marks a define in the material to indicate that it needs to be re-computed
  21979. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21980. */
  21981. markAsDirty(flag: number): void;
  21982. /**
  21983. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21984. * @param func defines a function which checks material defines against the submeshes
  21985. */
  21986. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21987. /**
  21988. * Indicates that image processing needs to be re-calculated for all submeshes
  21989. */
  21990. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21991. /**
  21992. * Indicates that textures need to be re-calculated for all submeshes
  21993. */
  21994. protected _markAllSubMeshesAsTexturesDirty(): void;
  21995. /**
  21996. * Indicates that fresnel needs to be re-calculated for all submeshes
  21997. */
  21998. protected _markAllSubMeshesAsFresnelDirty(): void;
  21999. /**
  22000. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22001. */
  22002. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22003. /**
  22004. * Indicates that lights need to be re-calculated for all submeshes
  22005. */
  22006. protected _markAllSubMeshesAsLightsDirty(): void;
  22007. /**
  22008. * Indicates that attributes need to be re-calculated for all submeshes
  22009. */
  22010. protected _markAllSubMeshesAsAttributesDirty(): void;
  22011. /**
  22012. * Indicates that misc needs to be re-calculated for all submeshes
  22013. */
  22014. protected _markAllSubMeshesAsMiscDirty(): void;
  22015. /**
  22016. * Indicates that textures and misc need to be re-calculated for all submeshes
  22017. */
  22018. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22019. /**
  22020. * Disposes the material
  22021. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22022. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22023. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22024. */
  22025. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22026. /** @hidden */
  22027. private releaseVertexArrayObject;
  22028. /**
  22029. * Serializes this material
  22030. * @returns the serialized material object
  22031. */
  22032. serialize(): any;
  22033. /**
  22034. * Creates a material from parsed material data
  22035. * @param parsedMaterial defines parsed material data
  22036. * @param scene defines the hosting scene
  22037. * @param rootUrl defines the root URL to use to load textures
  22038. * @returns a new material
  22039. */
  22040. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22041. }
  22042. }
  22043. declare module "babylonjs/Meshes/subMesh" {
  22044. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22045. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22046. import { Engine } from "babylonjs/Engines/engine";
  22047. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22048. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22049. import { Effect } from "babylonjs/Materials/effect";
  22050. import { Collider } from "babylonjs/Collisions/collider";
  22051. import { Material } from "babylonjs/Materials/material";
  22052. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22054. import { Mesh } from "babylonjs/Meshes/mesh";
  22055. import { Ray } from "babylonjs/Culling/ray";
  22056. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22057. /**
  22058. * Base class for submeshes
  22059. */
  22060. export class BaseSubMesh {
  22061. /** @hidden */
  22062. _materialDefines: Nullable<MaterialDefines>;
  22063. /** @hidden */
  22064. _materialEffect: Nullable<Effect>;
  22065. /**
  22066. * Gets associated effect
  22067. */
  22068. readonly effect: Nullable<Effect>;
  22069. /**
  22070. * Sets associated effect (effect used to render this submesh)
  22071. * @param effect defines the effect to associate with
  22072. * @param defines defines the set of defines used to compile this effect
  22073. */
  22074. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22075. }
  22076. /**
  22077. * Defines a subdivision inside a mesh
  22078. */
  22079. export class SubMesh extends BaseSubMesh implements ICullable {
  22080. /** the material index to use */
  22081. materialIndex: number;
  22082. /** vertex index start */
  22083. verticesStart: number;
  22084. /** vertices count */
  22085. verticesCount: number;
  22086. /** index start */
  22087. indexStart: number;
  22088. /** indices count */
  22089. indexCount: number;
  22090. /** @hidden */
  22091. _linesIndexCount: number;
  22092. private _mesh;
  22093. private _renderingMesh;
  22094. private _boundingInfo;
  22095. private _linesIndexBuffer;
  22096. /** @hidden */
  22097. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22098. /** @hidden */
  22099. _trianglePlanes: Plane[];
  22100. /** @hidden */
  22101. _lastColliderTransformMatrix: Matrix;
  22102. /** @hidden */
  22103. _renderId: number;
  22104. /** @hidden */
  22105. _alphaIndex: number;
  22106. /** @hidden */
  22107. _distanceToCamera: number;
  22108. /** @hidden */
  22109. _id: number;
  22110. private _currentMaterial;
  22111. /**
  22112. * Add a new submesh to a mesh
  22113. * @param materialIndex defines the material index to use
  22114. * @param verticesStart defines vertex index start
  22115. * @param verticesCount defines vertices count
  22116. * @param indexStart defines index start
  22117. * @param indexCount defines indices count
  22118. * @param mesh defines the parent mesh
  22119. * @param renderingMesh defines an optional rendering mesh
  22120. * @param createBoundingBox defines if bounding box should be created for this submesh
  22121. * @returns the new submesh
  22122. */
  22123. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22124. /**
  22125. * Creates a new submesh
  22126. * @param materialIndex defines the material index to use
  22127. * @param verticesStart defines vertex index start
  22128. * @param verticesCount defines vertices count
  22129. * @param indexStart defines index start
  22130. * @param indexCount defines indices count
  22131. * @param mesh defines the parent mesh
  22132. * @param renderingMesh defines an optional rendering mesh
  22133. * @param createBoundingBox defines if bounding box should be created for this submesh
  22134. */
  22135. constructor(
  22136. /** the material index to use */
  22137. materialIndex: number,
  22138. /** vertex index start */
  22139. verticesStart: number,
  22140. /** vertices count */
  22141. verticesCount: number,
  22142. /** index start */
  22143. indexStart: number,
  22144. /** indices count */
  22145. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22146. /**
  22147. * Returns true if this submesh covers the entire parent mesh
  22148. * @ignorenaming
  22149. */
  22150. readonly IsGlobal: boolean;
  22151. /**
  22152. * Returns the submesh BoudingInfo object
  22153. * @returns current bounding info (or mesh's one if the submesh is global)
  22154. */
  22155. getBoundingInfo(): BoundingInfo;
  22156. /**
  22157. * Sets the submesh BoundingInfo
  22158. * @param boundingInfo defines the new bounding info to use
  22159. * @returns the SubMesh
  22160. */
  22161. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22162. /**
  22163. * Returns the mesh of the current submesh
  22164. * @return the parent mesh
  22165. */
  22166. getMesh(): AbstractMesh;
  22167. /**
  22168. * Returns the rendering mesh of the submesh
  22169. * @returns the rendering mesh (could be different from parent mesh)
  22170. */
  22171. getRenderingMesh(): Mesh;
  22172. /**
  22173. * Returns the submesh material
  22174. * @returns null or the current material
  22175. */
  22176. getMaterial(): Nullable<Material>;
  22177. /**
  22178. * Sets a new updated BoundingInfo object to the submesh
  22179. * @returns the SubMesh
  22180. */
  22181. refreshBoundingInfo(): SubMesh;
  22182. /** @hidden */
  22183. _checkCollision(collider: Collider): boolean;
  22184. /**
  22185. * Updates the submesh BoundingInfo
  22186. * @param world defines the world matrix to use to update the bounding info
  22187. * @returns the submesh
  22188. */
  22189. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22190. /**
  22191. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22192. * @param frustumPlanes defines the frustum planes
  22193. * @returns true if the submesh is intersecting with the frustum
  22194. */
  22195. isInFrustum(frustumPlanes: Plane[]): boolean;
  22196. /**
  22197. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22198. * @param frustumPlanes defines the frustum planes
  22199. * @returns true if the submesh is inside the frustum
  22200. */
  22201. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22202. /**
  22203. * Renders the submesh
  22204. * @param enableAlphaMode defines if alpha needs to be used
  22205. * @returns the submesh
  22206. */
  22207. render(enableAlphaMode: boolean): SubMesh;
  22208. /**
  22209. * @hidden
  22210. */
  22211. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22212. /**
  22213. * Checks if the submesh intersects with a ray
  22214. * @param ray defines the ray to test
  22215. * @returns true is the passed ray intersects the submesh bounding box
  22216. */
  22217. canIntersects(ray: Ray): boolean;
  22218. /**
  22219. * Intersects current submesh with a ray
  22220. * @param ray defines the ray to test
  22221. * @param positions defines mesh's positions array
  22222. * @param indices defines mesh's indices array
  22223. * @param fastCheck defines if only bounding info should be used
  22224. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22225. * @returns intersection info or null if no intersection
  22226. */
  22227. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22228. /** @hidden */
  22229. private _intersectLines;
  22230. /** @hidden */
  22231. private _intersectTriangles;
  22232. /** @hidden */
  22233. _rebuild(): void;
  22234. /**
  22235. * Creates a new submesh from the passed mesh
  22236. * @param newMesh defines the new hosting mesh
  22237. * @param newRenderingMesh defines an optional rendering mesh
  22238. * @returns the new submesh
  22239. */
  22240. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22241. /**
  22242. * Release associated resources
  22243. */
  22244. dispose(): void;
  22245. /**
  22246. * Gets the class name
  22247. * @returns the string "SubMesh".
  22248. */
  22249. getClassName(): string;
  22250. /**
  22251. * Creates a new submesh from indices data
  22252. * @param materialIndex the index of the main mesh material
  22253. * @param startIndex the index where to start the copy in the mesh indices array
  22254. * @param indexCount the number of indices to copy then from the startIndex
  22255. * @param mesh the main mesh to create the submesh from
  22256. * @param renderingMesh the optional rendering mesh
  22257. * @returns a new submesh
  22258. */
  22259. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22260. }
  22261. }
  22262. declare module "babylonjs/Meshes/geometry" {
  22263. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22264. import { Scene } from "babylonjs/scene";
  22265. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22266. import { Engine } from "babylonjs/Engines/engine";
  22267. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22268. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22269. import { Effect } from "babylonjs/Materials/effect";
  22270. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22271. import { Mesh } from "babylonjs/Meshes/mesh";
  22272. /**
  22273. * Class used to store geometry data (vertex buffers + index buffer)
  22274. */
  22275. export class Geometry implements IGetSetVerticesData {
  22276. /**
  22277. * Gets or sets the ID of the geometry
  22278. */
  22279. id: string;
  22280. /**
  22281. * Gets or sets the unique ID of the geometry
  22282. */
  22283. uniqueId: number;
  22284. /**
  22285. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22286. */
  22287. delayLoadState: number;
  22288. /**
  22289. * Gets the file containing the data to load when running in delay load state
  22290. */
  22291. delayLoadingFile: Nullable<string>;
  22292. /**
  22293. * Callback called when the geometry is updated
  22294. */
  22295. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22296. private _scene;
  22297. private _engine;
  22298. private _meshes;
  22299. private _totalVertices;
  22300. /** @hidden */
  22301. _indices: IndicesArray;
  22302. /** @hidden */
  22303. _vertexBuffers: {
  22304. [key: string]: VertexBuffer;
  22305. };
  22306. private _isDisposed;
  22307. private _extend;
  22308. private _boundingBias;
  22309. /** @hidden */
  22310. _delayInfo: Array<string>;
  22311. private _indexBuffer;
  22312. private _indexBufferIsUpdatable;
  22313. /** @hidden */
  22314. _boundingInfo: Nullable<BoundingInfo>;
  22315. /** @hidden */
  22316. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22317. /** @hidden */
  22318. _softwareSkinningFrameId: number;
  22319. private _vertexArrayObjects;
  22320. private _updatable;
  22321. /** @hidden */
  22322. _positions: Nullable<Vector3[]>;
  22323. /**
  22324. * 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
  22325. */
  22326. /**
  22327. * 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
  22328. */
  22329. boundingBias: Vector2;
  22330. /**
  22331. * Static function used to attach a new empty geometry to a mesh
  22332. * @param mesh defines the mesh to attach the geometry to
  22333. * @returns the new Geometry
  22334. */
  22335. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22336. /**
  22337. * Creates a new geometry
  22338. * @param id defines the unique ID
  22339. * @param scene defines the hosting scene
  22340. * @param vertexData defines the VertexData used to get geometry data
  22341. * @param updatable defines if geometry must be updatable (false by default)
  22342. * @param mesh defines the mesh that will be associated with the geometry
  22343. */
  22344. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22345. /**
  22346. * Gets the current extend of the geometry
  22347. */
  22348. readonly extend: {
  22349. minimum: Vector3;
  22350. maximum: Vector3;
  22351. };
  22352. /**
  22353. * Gets the hosting scene
  22354. * @returns the hosting Scene
  22355. */
  22356. getScene(): Scene;
  22357. /**
  22358. * Gets the hosting engine
  22359. * @returns the hosting Engine
  22360. */
  22361. getEngine(): Engine;
  22362. /**
  22363. * Defines if the geometry is ready to use
  22364. * @returns true if the geometry is ready to be used
  22365. */
  22366. isReady(): boolean;
  22367. /**
  22368. * Gets a value indicating that the geometry should not be serialized
  22369. */
  22370. readonly doNotSerialize: boolean;
  22371. /** @hidden */
  22372. _rebuild(): void;
  22373. /**
  22374. * Affects all geometry data in one call
  22375. * @param vertexData defines the geometry data
  22376. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22377. */
  22378. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22379. /**
  22380. * Set specific vertex data
  22381. * @param kind defines the data kind (Position, normal, etc...)
  22382. * @param data defines the vertex data to use
  22383. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22384. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22385. */
  22386. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22387. /**
  22388. * Removes a specific vertex data
  22389. * @param kind defines the data kind (Position, normal, etc...)
  22390. */
  22391. removeVerticesData(kind: string): void;
  22392. /**
  22393. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22394. * @param buffer defines the vertex buffer to use
  22395. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22396. */
  22397. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22398. /**
  22399. * Update a specific vertex buffer
  22400. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22401. * It will do nothing if the buffer is not updatable
  22402. * @param kind defines the data kind (Position, normal, etc...)
  22403. * @param data defines the data to use
  22404. * @param offset defines the offset in the target buffer where to store the data
  22405. * @param useBytes set to true if the offset is in bytes
  22406. */
  22407. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22408. /**
  22409. * Update a specific vertex buffer
  22410. * This function will create a new buffer if the current one is not updatable
  22411. * @param kind defines the data kind (Position, normal, etc...)
  22412. * @param data defines the data to use
  22413. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22414. */
  22415. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22416. private _updateBoundingInfo;
  22417. /** @hidden */
  22418. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22419. /**
  22420. * Gets total number of vertices
  22421. * @returns the total number of vertices
  22422. */
  22423. getTotalVertices(): number;
  22424. /**
  22425. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22426. * @param kind defines the data kind (Position, normal, etc...)
  22427. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22428. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22429. * @returns a float array containing vertex data
  22430. */
  22431. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22432. /**
  22433. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22434. * @param kind defines the data kind (Position, normal, etc...)
  22435. * @returns true if the vertex buffer with the specified kind is updatable
  22436. */
  22437. isVertexBufferUpdatable(kind: string): boolean;
  22438. /**
  22439. * Gets a specific vertex buffer
  22440. * @param kind defines the data kind (Position, normal, etc...)
  22441. * @returns a VertexBuffer
  22442. */
  22443. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22444. /**
  22445. * Returns all vertex buffers
  22446. * @return an object holding all vertex buffers indexed by kind
  22447. */
  22448. getVertexBuffers(): Nullable<{
  22449. [key: string]: VertexBuffer;
  22450. }>;
  22451. /**
  22452. * Gets a boolean indicating if specific vertex buffer is present
  22453. * @param kind defines the data kind (Position, normal, etc...)
  22454. * @returns true if data is present
  22455. */
  22456. isVerticesDataPresent(kind: string): boolean;
  22457. /**
  22458. * Gets a list of all attached data kinds (Position, normal, etc...)
  22459. * @returns a list of string containing all kinds
  22460. */
  22461. getVerticesDataKinds(): string[];
  22462. /**
  22463. * Update index buffer
  22464. * @param indices defines the indices to store in the index buffer
  22465. * @param offset defines the offset in the target buffer where to store the data
  22466. */
  22467. updateIndices(indices: IndicesArray, offset?: number): void;
  22468. /**
  22469. * Creates a new index buffer
  22470. * @param indices defines the indices to store in the index buffer
  22471. * @param totalVertices defines the total number of vertices (could be null)
  22472. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22473. */
  22474. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22475. /**
  22476. * Return the total number of indices
  22477. * @returns the total number of indices
  22478. */
  22479. getTotalIndices(): number;
  22480. /**
  22481. * Gets the index buffer array
  22482. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22483. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22484. * @returns the index buffer array
  22485. */
  22486. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22487. /**
  22488. * Gets the index buffer
  22489. * @return the index buffer
  22490. */
  22491. getIndexBuffer(): Nullable<WebGLBuffer>;
  22492. /** @hidden */
  22493. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22494. /**
  22495. * Release the associated resources for a specific mesh
  22496. * @param mesh defines the source mesh
  22497. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22498. */
  22499. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22500. /**
  22501. * Apply current geometry to a given mesh
  22502. * @param mesh defines the mesh to apply geometry to
  22503. */
  22504. applyToMesh(mesh: Mesh): void;
  22505. private _updateExtend;
  22506. private _applyToMesh;
  22507. private notifyUpdate;
  22508. /**
  22509. * Load the geometry if it was flagged as delay loaded
  22510. * @param scene defines the hosting scene
  22511. * @param onLoaded defines a callback called when the geometry is loaded
  22512. */
  22513. load(scene: Scene, onLoaded?: () => void): void;
  22514. private _queueLoad;
  22515. /**
  22516. * Invert the geometry to move from a right handed system to a left handed one.
  22517. */
  22518. toLeftHanded(): void;
  22519. /** @hidden */
  22520. _resetPointsArrayCache(): void;
  22521. /** @hidden */
  22522. _generatePointsArray(): boolean;
  22523. /**
  22524. * Gets a value indicating if the geometry is disposed
  22525. * @returns true if the geometry was disposed
  22526. */
  22527. isDisposed(): boolean;
  22528. private _disposeVertexArrayObjects;
  22529. /**
  22530. * Free all associated resources
  22531. */
  22532. dispose(): void;
  22533. /**
  22534. * Clone the current geometry into a new geometry
  22535. * @param id defines the unique ID of the new geometry
  22536. * @returns a new geometry object
  22537. */
  22538. copy(id: string): Geometry;
  22539. /**
  22540. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22541. * @return a JSON representation of the current geometry data (without the vertices data)
  22542. */
  22543. serialize(): any;
  22544. private toNumberArray;
  22545. /**
  22546. * Serialize all vertices data into a JSON oject
  22547. * @returns a JSON representation of the current geometry data
  22548. */
  22549. serializeVerticeData(): any;
  22550. /**
  22551. * Extracts a clone of a mesh geometry
  22552. * @param mesh defines the source mesh
  22553. * @param id defines the unique ID of the new geometry object
  22554. * @returns the new geometry object
  22555. */
  22556. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22557. /**
  22558. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22559. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22560. * Be aware Math.random() could cause collisions, but:
  22561. * "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"
  22562. * @returns a string containing a new GUID
  22563. */
  22564. static RandomId(): string;
  22565. /** @hidden */
  22566. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22567. private static _CleanMatricesWeights;
  22568. /**
  22569. * Create a new geometry from persisted data (Using .babylon file format)
  22570. * @param parsedVertexData defines the persisted data
  22571. * @param scene defines the hosting scene
  22572. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22573. * @returns the new geometry object
  22574. */
  22575. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22576. }
  22577. }
  22578. declare module "babylonjs/Meshes/mesh.vertexData" {
  22579. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22580. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22581. import { Geometry } from "babylonjs/Meshes/geometry";
  22582. import { Mesh } from "babylonjs/Meshes/mesh";
  22583. /**
  22584. * Define an interface for all classes that will get and set the data on vertices
  22585. */
  22586. export interface IGetSetVerticesData {
  22587. /**
  22588. * Gets a boolean indicating if specific vertex data is present
  22589. * @param kind defines the vertex data kind to use
  22590. * @returns true is data kind is present
  22591. */
  22592. isVerticesDataPresent(kind: string): boolean;
  22593. /**
  22594. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22595. * @param kind defines the data kind (Position, normal, etc...)
  22596. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22597. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22598. * @returns a float array containing vertex data
  22599. */
  22600. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22601. /**
  22602. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22603. * @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.
  22604. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22605. * @returns the indices array or an empty array if the mesh has no geometry
  22606. */
  22607. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22608. /**
  22609. * Set specific vertex data
  22610. * @param kind defines the data kind (Position, normal, etc...)
  22611. * @param data defines the vertex data to use
  22612. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22613. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22614. */
  22615. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22616. /**
  22617. * Update a specific associated vertex buffer
  22618. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22619. * - VertexBuffer.PositionKind
  22620. * - VertexBuffer.UVKind
  22621. * - VertexBuffer.UV2Kind
  22622. * - VertexBuffer.UV3Kind
  22623. * - VertexBuffer.UV4Kind
  22624. * - VertexBuffer.UV5Kind
  22625. * - VertexBuffer.UV6Kind
  22626. * - VertexBuffer.ColorKind
  22627. * - VertexBuffer.MatricesIndicesKind
  22628. * - VertexBuffer.MatricesIndicesExtraKind
  22629. * - VertexBuffer.MatricesWeightsKind
  22630. * - VertexBuffer.MatricesWeightsExtraKind
  22631. * @param data defines the data source
  22632. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22633. * @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)
  22634. */
  22635. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22636. /**
  22637. * Creates a new index buffer
  22638. * @param indices defines the indices to store in the index buffer
  22639. * @param totalVertices defines the total number of vertices (could be null)
  22640. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22641. */
  22642. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22643. }
  22644. /**
  22645. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22646. */
  22647. export class VertexData {
  22648. /**
  22649. * Mesh side orientation : usually the external or front surface
  22650. */
  22651. static readonly FRONTSIDE: number;
  22652. /**
  22653. * Mesh side orientation : usually the internal or back surface
  22654. */
  22655. static readonly BACKSIDE: number;
  22656. /**
  22657. * Mesh side orientation : both internal and external or front and back surfaces
  22658. */
  22659. static readonly DOUBLESIDE: number;
  22660. /**
  22661. * Mesh side orientation : by default, `FRONTSIDE`
  22662. */
  22663. static readonly DEFAULTSIDE: number;
  22664. /**
  22665. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22666. */
  22667. positions: Nullable<FloatArray>;
  22668. /**
  22669. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22670. */
  22671. normals: Nullable<FloatArray>;
  22672. /**
  22673. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22674. */
  22675. tangents: Nullable<FloatArray>;
  22676. /**
  22677. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22678. */
  22679. uvs: Nullable<FloatArray>;
  22680. /**
  22681. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22682. */
  22683. uvs2: Nullable<FloatArray>;
  22684. /**
  22685. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22686. */
  22687. uvs3: Nullable<FloatArray>;
  22688. /**
  22689. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22690. */
  22691. uvs4: Nullable<FloatArray>;
  22692. /**
  22693. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22694. */
  22695. uvs5: Nullable<FloatArray>;
  22696. /**
  22697. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22698. */
  22699. uvs6: Nullable<FloatArray>;
  22700. /**
  22701. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22702. */
  22703. colors: Nullable<FloatArray>;
  22704. /**
  22705. * 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).
  22706. */
  22707. matricesIndices: Nullable<FloatArray>;
  22708. /**
  22709. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22710. */
  22711. matricesWeights: Nullable<FloatArray>;
  22712. /**
  22713. * An array extending the number of possible indices
  22714. */
  22715. matricesIndicesExtra: Nullable<FloatArray>;
  22716. /**
  22717. * An array extending the number of possible weights when the number of indices is extended
  22718. */
  22719. matricesWeightsExtra: Nullable<FloatArray>;
  22720. /**
  22721. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22722. */
  22723. indices: Nullable<IndicesArray>;
  22724. /**
  22725. * Uses the passed data array to set the set the values for the specified kind of data
  22726. * @param data a linear array of floating numbers
  22727. * @param kind the type of data that is being set, eg positions, colors etc
  22728. */
  22729. set(data: FloatArray, kind: string): void;
  22730. /**
  22731. * Associates the vertexData to the passed Mesh.
  22732. * Sets it as updatable or not (default `false`)
  22733. * @param mesh the mesh the vertexData is applied to
  22734. * @param updatable when used and having the value true allows new data to update the vertexData
  22735. * @returns the VertexData
  22736. */
  22737. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22738. /**
  22739. * Associates the vertexData to the passed Geometry.
  22740. * Sets it as updatable or not (default `false`)
  22741. * @param geometry the geometry the vertexData is applied to
  22742. * @param updatable when used and having the value true allows new data to update the vertexData
  22743. * @returns VertexData
  22744. */
  22745. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22746. /**
  22747. * Updates the associated mesh
  22748. * @param mesh the mesh to be updated
  22749. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22750. * @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
  22751. * @returns VertexData
  22752. */
  22753. updateMesh(mesh: Mesh): VertexData;
  22754. /**
  22755. * Updates the associated geometry
  22756. * @param geometry the geometry to be updated
  22757. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22758. * @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
  22759. * @returns VertexData.
  22760. */
  22761. updateGeometry(geometry: Geometry): VertexData;
  22762. private _applyTo;
  22763. private _update;
  22764. /**
  22765. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22766. * @param matrix the transforming matrix
  22767. * @returns the VertexData
  22768. */
  22769. transform(matrix: Matrix): VertexData;
  22770. /**
  22771. * Merges the passed VertexData into the current one
  22772. * @param other the VertexData to be merged into the current one
  22773. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22774. * @returns the modified VertexData
  22775. */
  22776. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22777. private _mergeElement;
  22778. private _validate;
  22779. /**
  22780. * Serializes the VertexData
  22781. * @returns a serialized object
  22782. */
  22783. serialize(): any;
  22784. /**
  22785. * Extracts the vertexData from a mesh
  22786. * @param mesh the mesh from which to extract the VertexData
  22787. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22788. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22789. * @returns the object VertexData associated to the passed mesh
  22790. */
  22791. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22792. /**
  22793. * Extracts the vertexData from the geometry
  22794. * @param geometry the geometry from which to extract the VertexData
  22795. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22796. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22797. * @returns the object VertexData associated to the passed mesh
  22798. */
  22799. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22800. private static _ExtractFrom;
  22801. /**
  22802. * Creates the VertexData for a Ribbon
  22803. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22804. * * pathArray array of paths, each of which an array of successive Vector3
  22805. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22806. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22807. * * 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
  22808. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22809. * * 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)
  22810. * * 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)
  22811. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22812. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22813. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22814. * @returns the VertexData of the ribbon
  22815. */
  22816. static CreateRibbon(options: {
  22817. pathArray: Vector3[][];
  22818. closeArray?: boolean;
  22819. closePath?: boolean;
  22820. offset?: number;
  22821. sideOrientation?: number;
  22822. frontUVs?: Vector4;
  22823. backUVs?: Vector4;
  22824. invertUV?: boolean;
  22825. uvs?: Vector2[];
  22826. colors?: Color4[];
  22827. }): VertexData;
  22828. /**
  22829. * Creates the VertexData for a box
  22830. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22831. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22832. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22833. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22834. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22835. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22836. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22837. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22838. * * 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)
  22839. * * 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)
  22840. * @returns the VertexData of the box
  22841. */
  22842. static CreateBox(options: {
  22843. size?: number;
  22844. width?: number;
  22845. height?: number;
  22846. depth?: number;
  22847. faceUV?: Vector4[];
  22848. faceColors?: Color4[];
  22849. sideOrientation?: number;
  22850. frontUVs?: Vector4;
  22851. backUVs?: Vector4;
  22852. }): VertexData;
  22853. /**
  22854. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22855. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22856. * * segments sets the number of horizontal strips optional, default 32
  22857. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22858. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22859. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22860. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22861. * * 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
  22862. * * 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
  22863. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22864. * * 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)
  22865. * * 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)
  22866. * @returns the VertexData of the ellipsoid
  22867. */
  22868. static CreateSphere(options: {
  22869. segments?: number;
  22870. diameter?: number;
  22871. diameterX?: number;
  22872. diameterY?: number;
  22873. diameterZ?: number;
  22874. arc?: number;
  22875. slice?: number;
  22876. sideOrientation?: number;
  22877. frontUVs?: Vector4;
  22878. backUVs?: Vector4;
  22879. }): VertexData;
  22880. /**
  22881. * Creates the VertexData for a cylinder, cone or prism
  22882. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22883. * * height sets the height (y direction) of the cylinder, optional, default 2
  22884. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22885. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22886. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22887. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22888. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22889. * * 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
  22890. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22891. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22892. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22893. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22894. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22895. * * 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)
  22896. * * 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)
  22897. * @returns the VertexData of the cylinder, cone or prism
  22898. */
  22899. static CreateCylinder(options: {
  22900. height?: number;
  22901. diameterTop?: number;
  22902. diameterBottom?: number;
  22903. diameter?: number;
  22904. tessellation?: number;
  22905. subdivisions?: number;
  22906. arc?: number;
  22907. faceColors?: Color4[];
  22908. faceUV?: Vector4[];
  22909. hasRings?: boolean;
  22910. enclose?: boolean;
  22911. sideOrientation?: number;
  22912. frontUVs?: Vector4;
  22913. backUVs?: Vector4;
  22914. }): VertexData;
  22915. /**
  22916. * Creates the VertexData for a torus
  22917. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22918. * * diameter the diameter of the torus, optional default 1
  22919. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22920. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22921. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22922. * * 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)
  22923. * * 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)
  22924. * @returns the VertexData of the torus
  22925. */
  22926. static CreateTorus(options: {
  22927. diameter?: number;
  22928. thickness?: number;
  22929. tessellation?: number;
  22930. sideOrientation?: number;
  22931. frontUVs?: Vector4;
  22932. backUVs?: Vector4;
  22933. }): VertexData;
  22934. /**
  22935. * Creates the VertexData of the LineSystem
  22936. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22937. * - lines an array of lines, each line being an array of successive Vector3
  22938. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22939. * @returns the VertexData of the LineSystem
  22940. */
  22941. static CreateLineSystem(options: {
  22942. lines: Vector3[][];
  22943. colors?: Nullable<Color4[][]>;
  22944. }): VertexData;
  22945. /**
  22946. * Create the VertexData for a DashedLines
  22947. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22948. * - points an array successive Vector3
  22949. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22950. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22951. * - dashNb the intended total number of dashes, optional, default 200
  22952. * @returns the VertexData for the DashedLines
  22953. */
  22954. static CreateDashedLines(options: {
  22955. points: Vector3[];
  22956. dashSize?: number;
  22957. gapSize?: number;
  22958. dashNb?: number;
  22959. }): VertexData;
  22960. /**
  22961. * Creates the VertexData for a Ground
  22962. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22963. * - width the width (x direction) of the ground, optional, default 1
  22964. * - height the height (z direction) of the ground, optional, default 1
  22965. * - subdivisions the number of subdivisions per side, optional, default 1
  22966. * @returns the VertexData of the Ground
  22967. */
  22968. static CreateGround(options: {
  22969. width?: number;
  22970. height?: number;
  22971. subdivisions?: number;
  22972. subdivisionsX?: number;
  22973. subdivisionsY?: number;
  22974. }): VertexData;
  22975. /**
  22976. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22977. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22978. * * xmin the ground minimum X coordinate, optional, default -1
  22979. * * zmin the ground minimum Z coordinate, optional, default -1
  22980. * * xmax the ground maximum X coordinate, optional, default 1
  22981. * * zmax the ground maximum Z coordinate, optional, default 1
  22982. * * 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}
  22983. * * 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}
  22984. * @returns the VertexData of the TiledGround
  22985. */
  22986. static CreateTiledGround(options: {
  22987. xmin: number;
  22988. zmin: number;
  22989. xmax: number;
  22990. zmax: number;
  22991. subdivisions?: {
  22992. w: number;
  22993. h: number;
  22994. };
  22995. precision?: {
  22996. w: number;
  22997. h: number;
  22998. };
  22999. }): VertexData;
  23000. /**
  23001. * Creates the VertexData of the Ground designed from a heightmap
  23002. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23003. * * width the width (x direction) of the ground
  23004. * * height the height (z direction) of the ground
  23005. * * subdivisions the number of subdivisions per side
  23006. * * minHeight the minimum altitude on the ground, optional, default 0
  23007. * * maxHeight the maximum altitude on the ground, optional default 1
  23008. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23009. * * buffer the array holding the image color data
  23010. * * bufferWidth the width of image
  23011. * * bufferHeight the height of image
  23012. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23013. * @returns the VertexData of the Ground designed from a heightmap
  23014. */
  23015. static CreateGroundFromHeightMap(options: {
  23016. width: number;
  23017. height: number;
  23018. subdivisions: number;
  23019. minHeight: number;
  23020. maxHeight: number;
  23021. colorFilter: Color3;
  23022. buffer: Uint8Array;
  23023. bufferWidth: number;
  23024. bufferHeight: number;
  23025. alphaFilter: number;
  23026. }): VertexData;
  23027. /**
  23028. * Creates the VertexData for a Plane
  23029. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23030. * * size sets the width and height of the plane to the value of size, optional default 1
  23031. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23032. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23033. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23034. * * 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)
  23035. * * 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)
  23036. * @returns the VertexData of the box
  23037. */
  23038. static CreatePlane(options: {
  23039. size?: number;
  23040. width?: number;
  23041. height?: number;
  23042. sideOrientation?: number;
  23043. frontUVs?: Vector4;
  23044. backUVs?: Vector4;
  23045. }): VertexData;
  23046. /**
  23047. * Creates the VertexData of the Disc or regular Polygon
  23048. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23049. * * radius the radius of the disc, optional default 0.5
  23050. * * tessellation the number of polygon sides, optional, default 64
  23051. * * 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
  23052. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23053. * * 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)
  23054. * * 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)
  23055. * @returns the VertexData of the box
  23056. */
  23057. static CreateDisc(options: {
  23058. radius?: number;
  23059. tessellation?: number;
  23060. arc?: number;
  23061. sideOrientation?: number;
  23062. frontUVs?: Vector4;
  23063. backUVs?: Vector4;
  23064. }): VertexData;
  23065. /**
  23066. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23067. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23068. * @param polygon a mesh built from polygonTriangulation.build()
  23069. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23070. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23071. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23072. * @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)
  23073. * @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)
  23074. * @returns the VertexData of the Polygon
  23075. */
  23076. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23077. /**
  23078. * Creates the VertexData of the IcoSphere
  23079. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23080. * * radius the radius of the IcoSphere, optional default 1
  23081. * * radiusX allows stretching in the x direction, optional, default radius
  23082. * * radiusY allows stretching in the y direction, optional, default radius
  23083. * * radiusZ allows stretching in the z direction, optional, default radius
  23084. * * flat when true creates a flat shaded mesh, optional, default true
  23085. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23086. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23087. * * 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)
  23088. * * 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)
  23089. * @returns the VertexData of the IcoSphere
  23090. */
  23091. static CreateIcoSphere(options: {
  23092. radius?: number;
  23093. radiusX?: number;
  23094. radiusY?: number;
  23095. radiusZ?: number;
  23096. flat?: boolean;
  23097. subdivisions?: number;
  23098. sideOrientation?: number;
  23099. frontUVs?: Vector4;
  23100. backUVs?: Vector4;
  23101. }): VertexData;
  23102. /**
  23103. * Creates the VertexData for a Polyhedron
  23104. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23105. * * type provided types are:
  23106. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23107. * * 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)
  23108. * * size the size of the IcoSphere, optional default 1
  23109. * * sizeX allows stretching in the x direction, optional, default size
  23110. * * sizeY allows stretching in the y direction, optional, default size
  23111. * * sizeZ allows stretching in the z direction, optional, default size
  23112. * * 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
  23113. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23114. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23115. * * flat when true creates a flat shaded mesh, optional, default true
  23116. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23117. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23118. * * 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)
  23119. * * 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)
  23120. * @returns the VertexData of the Polyhedron
  23121. */
  23122. static CreatePolyhedron(options: {
  23123. type?: number;
  23124. size?: number;
  23125. sizeX?: number;
  23126. sizeY?: number;
  23127. sizeZ?: number;
  23128. custom?: any;
  23129. faceUV?: Vector4[];
  23130. faceColors?: Color4[];
  23131. flat?: boolean;
  23132. sideOrientation?: number;
  23133. frontUVs?: Vector4;
  23134. backUVs?: Vector4;
  23135. }): VertexData;
  23136. /**
  23137. * Creates the VertexData for a TorusKnot
  23138. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23139. * * radius the radius of the torus knot, optional, default 2
  23140. * * tube the thickness of the tube, optional, default 0.5
  23141. * * radialSegments the number of sides on each tube segments, optional, default 32
  23142. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23143. * * p the number of windings around the z axis, optional, default 2
  23144. * * q the number of windings around the x axis, optional, default 3
  23145. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23146. * * 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)
  23147. * * 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)
  23148. * @returns the VertexData of the Torus Knot
  23149. */
  23150. static CreateTorusKnot(options: {
  23151. radius?: number;
  23152. tube?: number;
  23153. radialSegments?: number;
  23154. tubularSegments?: number;
  23155. p?: number;
  23156. q?: number;
  23157. sideOrientation?: number;
  23158. frontUVs?: Vector4;
  23159. backUVs?: Vector4;
  23160. }): VertexData;
  23161. /**
  23162. * Compute normals for given positions and indices
  23163. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23164. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23165. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23166. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23167. * * facetNormals : optional array of facet normals (vector3)
  23168. * * facetPositions : optional array of facet positions (vector3)
  23169. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23170. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23171. * * bInfo : optional bounding info, required for facetPartitioning computation
  23172. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23173. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23174. * * useRightHandedSystem: optional boolean to for right handed system computation
  23175. * * depthSort : optional boolean to enable the facet depth sort computation
  23176. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23177. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23178. */
  23179. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23180. facetNormals?: any;
  23181. facetPositions?: any;
  23182. facetPartitioning?: any;
  23183. ratio?: number;
  23184. bInfo?: any;
  23185. bbSize?: Vector3;
  23186. subDiv?: any;
  23187. useRightHandedSystem?: boolean;
  23188. depthSort?: boolean;
  23189. distanceTo?: Vector3;
  23190. depthSortedFacets?: any;
  23191. }): void;
  23192. /** @hidden */
  23193. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23194. /**
  23195. * Applies VertexData created from the imported parameters to the geometry
  23196. * @param parsedVertexData the parsed data from an imported file
  23197. * @param geometry the geometry to apply the VertexData to
  23198. */
  23199. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23200. }
  23201. }
  23202. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23203. import { Nullable } from "babylonjs/types";
  23204. import { Scene } from "babylonjs/scene";
  23205. import { Vector4 } from "babylonjs/Maths/math";
  23206. import { Mesh } from "babylonjs/Meshes/mesh";
  23207. /**
  23208. * Class containing static functions to help procedurally build meshes
  23209. */
  23210. export class DiscBuilder {
  23211. /**
  23212. * Creates a plane polygonal mesh. By default, this is a disc
  23213. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23214. * * 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
  23215. * * 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
  23216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23219. * @param name defines the name of the mesh
  23220. * @param options defines the options used to create the mesh
  23221. * @param scene defines the hosting scene
  23222. * @returns the plane polygonal mesh
  23223. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23224. */
  23225. static CreateDisc(name: string, options: {
  23226. radius?: number;
  23227. tessellation?: number;
  23228. arc?: number;
  23229. updatable?: boolean;
  23230. sideOrientation?: number;
  23231. frontUVs?: Vector4;
  23232. backUVs?: Vector4;
  23233. }, scene?: Nullable<Scene>): Mesh;
  23234. }
  23235. }
  23236. declare module "babylonjs/Particles/solidParticleSystem" {
  23237. import { Vector3 } from "babylonjs/Maths/math";
  23238. import { Mesh } from "babylonjs/Meshes/mesh";
  23239. import { Scene, IDisposable } from "babylonjs/scene";
  23240. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23241. /**
  23242. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23243. *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.
  23244. * The SPS is also a particle system. It provides some methods to manage the particles.
  23245. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23246. *
  23247. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23248. */
  23249. export class SolidParticleSystem implements IDisposable {
  23250. /**
  23251. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23252. * Example : var p = SPS.particles[i];
  23253. */
  23254. particles: SolidParticle[];
  23255. /**
  23256. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23257. */
  23258. nbParticles: number;
  23259. /**
  23260. * If the particles must ever face the camera (default false). Useful for planar particles.
  23261. */
  23262. billboard: boolean;
  23263. /**
  23264. * Recompute normals when adding a shape
  23265. */
  23266. recomputeNormals: boolean;
  23267. /**
  23268. * This a counter ofr your own usage. It's not set by any SPS functions.
  23269. */
  23270. counter: number;
  23271. /**
  23272. * The SPS name. This name is also given to the underlying mesh.
  23273. */
  23274. name: string;
  23275. /**
  23276. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23277. */
  23278. mesh: Mesh;
  23279. /**
  23280. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23281. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23282. */
  23283. vars: any;
  23284. /**
  23285. * This array is populated when the SPS is set as 'pickable'.
  23286. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23287. * Each element of this array is an object `{idx: int, faceId: int}`.
  23288. * `idx` is the picked particle index in the `SPS.particles` array
  23289. * `faceId` is the picked face index counted within this particle.
  23290. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23291. */
  23292. pickedParticles: {
  23293. idx: number;
  23294. faceId: number;
  23295. }[];
  23296. /**
  23297. * This array is populated when `enableDepthSort` is set to true.
  23298. * Each element of this array is an instance of the class DepthSortedParticle.
  23299. */
  23300. depthSortedParticles: DepthSortedParticle[];
  23301. /**
  23302. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23303. * @hidden
  23304. */
  23305. _bSphereOnly: boolean;
  23306. /**
  23307. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23308. * @hidden
  23309. */
  23310. _bSphereRadiusFactor: number;
  23311. private _scene;
  23312. private _positions;
  23313. private _indices;
  23314. private _normals;
  23315. private _colors;
  23316. private _uvs;
  23317. private _indices32;
  23318. private _positions32;
  23319. private _normals32;
  23320. private _fixedNormal32;
  23321. private _colors32;
  23322. private _uvs32;
  23323. private _index;
  23324. private _updatable;
  23325. private _pickable;
  23326. private _isVisibilityBoxLocked;
  23327. private _alwaysVisible;
  23328. private _depthSort;
  23329. private _shapeCounter;
  23330. private _copy;
  23331. private _color;
  23332. private _computeParticleColor;
  23333. private _computeParticleTexture;
  23334. private _computeParticleRotation;
  23335. private _computeParticleVertex;
  23336. private _computeBoundingBox;
  23337. private _depthSortParticles;
  23338. private _camera;
  23339. private _mustUnrotateFixedNormals;
  23340. private _particlesIntersect;
  23341. private _needs32Bits;
  23342. /**
  23343. * Creates a SPS (Solid Particle System) object.
  23344. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23345. * @param scene (Scene) is the scene in which the SPS is added.
  23346. * @param options defines the options of the sps e.g.
  23347. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23348. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23349. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23350. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23351. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23352. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23353. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23354. */
  23355. constructor(name: string, scene: Scene, options?: {
  23356. updatable?: boolean;
  23357. isPickable?: boolean;
  23358. enableDepthSort?: boolean;
  23359. particleIntersection?: boolean;
  23360. boundingSphereOnly?: boolean;
  23361. bSphereRadiusFactor?: number;
  23362. });
  23363. /**
  23364. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23365. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23366. * @returns the created mesh
  23367. */
  23368. buildMesh(): Mesh;
  23369. /**
  23370. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23371. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23372. * Thus the particles generated from `digest()` have their property `position` set yet.
  23373. * @param mesh ( Mesh ) is the mesh to be digested
  23374. * @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
  23375. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23376. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23377. * @returns the current SPS
  23378. */
  23379. digest(mesh: Mesh, options?: {
  23380. facetNb?: number;
  23381. number?: number;
  23382. delta?: number;
  23383. }): SolidParticleSystem;
  23384. private _unrotateFixedNormals;
  23385. private _resetCopy;
  23386. private _meshBuilder;
  23387. private _posToShape;
  23388. private _uvsToShapeUV;
  23389. private _addParticle;
  23390. /**
  23391. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23392. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23393. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23394. * @param nb (positive integer) the number of particles to be created from this model
  23395. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23396. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23397. * @returns the number of shapes in the system
  23398. */
  23399. addShape(mesh: Mesh, nb: number, options?: {
  23400. positionFunction?: any;
  23401. vertexFunction?: any;
  23402. }): number;
  23403. private _rebuildParticle;
  23404. /**
  23405. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23406. * @returns the SPS.
  23407. */
  23408. rebuildMesh(): SolidParticleSystem;
  23409. /**
  23410. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23411. * This method calls `updateParticle()` for each particle of the SPS.
  23412. * For an animated SPS, it is usually called within the render loop.
  23413. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23414. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23415. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23416. * @returns the SPS.
  23417. */
  23418. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23419. /**
  23420. * Disposes the SPS.
  23421. */
  23422. dispose(): void;
  23423. /**
  23424. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23425. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23426. * @returns the SPS.
  23427. */
  23428. refreshVisibleSize(): SolidParticleSystem;
  23429. /**
  23430. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23431. * @param size the size (float) of the visibility box
  23432. * note : this doesn't lock the SPS mesh bounding box.
  23433. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23434. */
  23435. setVisibilityBox(size: number): void;
  23436. /**
  23437. * Gets whether the SPS as always visible or not
  23438. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23439. */
  23440. /**
  23441. * Sets the SPS as always visible or not
  23442. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23443. */
  23444. isAlwaysVisible: boolean;
  23445. /**
  23446. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23447. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23448. */
  23449. /**
  23450. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23451. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23452. */
  23453. isVisibilityBoxLocked: boolean;
  23454. /**
  23455. * Tells to `setParticles()` to compute the particle rotations or not.
  23456. * Default value : true. The SPS is faster when it's set to false.
  23457. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23458. */
  23459. /**
  23460. * Gets if `setParticles()` computes the particle rotations or not.
  23461. * Default value : true. The SPS is faster when it's set to false.
  23462. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23463. */
  23464. computeParticleRotation: boolean;
  23465. /**
  23466. * Tells to `setParticles()` to compute the particle colors or not.
  23467. * Default value : true. The SPS is faster when it's set to false.
  23468. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23469. */
  23470. /**
  23471. * Gets if `setParticles()` computes the particle colors or not.
  23472. * Default value : true. The SPS is faster when it's set to false.
  23473. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23474. */
  23475. computeParticleColor: boolean;
  23476. /**
  23477. * Gets if `setParticles()` computes the particle textures or not.
  23478. * Default value : true. The SPS is faster when it's set to false.
  23479. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23480. */
  23481. computeParticleTexture: boolean;
  23482. /**
  23483. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23484. * Default value : false. The SPS is faster when it's set to false.
  23485. * Note : the particle custom vertex positions aren't stored values.
  23486. */
  23487. /**
  23488. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23489. * Default value : false. The SPS is faster when it's set to false.
  23490. * Note : the particle custom vertex positions aren't stored values.
  23491. */
  23492. computeParticleVertex: boolean;
  23493. /**
  23494. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23495. */
  23496. /**
  23497. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23498. */
  23499. computeBoundingBox: boolean;
  23500. /**
  23501. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23502. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23503. * Default : `true`
  23504. */
  23505. /**
  23506. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23507. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23508. * Default : `true`
  23509. */
  23510. depthSortParticles: boolean;
  23511. /**
  23512. * This function does nothing. It may be overwritten to set all the particle first values.
  23513. * The SPS doesn't call this function, you may have to call it by your own.
  23514. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23515. */
  23516. initParticles(): void;
  23517. /**
  23518. * This function does nothing. It may be overwritten to recycle a particle.
  23519. * The SPS doesn't call this function, you may have to call it by your own.
  23520. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23521. * @param particle The particle to recycle
  23522. * @returns the recycled particle
  23523. */
  23524. recycleParticle(particle: SolidParticle): SolidParticle;
  23525. /**
  23526. * Updates a particle : this function should be overwritten by the user.
  23527. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23528. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23529. * @example : just set a particle position or velocity and recycle conditions
  23530. * @param particle The particle to update
  23531. * @returns the updated particle
  23532. */
  23533. updateParticle(particle: SolidParticle): SolidParticle;
  23534. /**
  23535. * Updates a vertex of a particle : it can be overwritten by the user.
  23536. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23537. * @param particle the current particle
  23538. * @param vertex the current index of the current particle
  23539. * @param pt the index of the current vertex in the particle shape
  23540. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23541. * @example : just set a vertex particle position
  23542. * @returns the updated vertex
  23543. */
  23544. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23545. /**
  23546. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23547. * This does nothing and may be overwritten by the user.
  23548. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23549. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23550. * @param update the boolean update value actually passed to setParticles()
  23551. */
  23552. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23553. /**
  23554. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23555. * This will be passed three parameters.
  23556. * This does nothing and may be overwritten by the user.
  23557. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23558. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23559. * @param update the boolean update value actually passed to setParticles()
  23560. */
  23561. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23562. }
  23563. }
  23564. declare module "babylonjs/Particles/solidParticle" {
  23565. import { Nullable } from "babylonjs/types";
  23566. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23567. import { Mesh } from "babylonjs/Meshes/mesh";
  23568. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23569. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23570. /**
  23571. * Represents one particle of a solid particle system.
  23572. */
  23573. export class SolidParticle {
  23574. /**
  23575. * particle global index
  23576. */
  23577. idx: number;
  23578. /**
  23579. * The color of the particle
  23580. */
  23581. color: Nullable<Color4>;
  23582. /**
  23583. * The world space position of the particle.
  23584. */
  23585. position: Vector3;
  23586. /**
  23587. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23588. */
  23589. rotation: Vector3;
  23590. /**
  23591. * The world space rotation quaternion of the particle.
  23592. */
  23593. rotationQuaternion: Nullable<Quaternion>;
  23594. /**
  23595. * The scaling of the particle.
  23596. */
  23597. scaling: Vector3;
  23598. /**
  23599. * The uvs of the particle.
  23600. */
  23601. uvs: Vector4;
  23602. /**
  23603. * The current speed of the particle.
  23604. */
  23605. velocity: Vector3;
  23606. /**
  23607. * The pivot point in the particle local space.
  23608. */
  23609. pivot: Vector3;
  23610. /**
  23611. * Must the particle be translated from its pivot point in its local space ?
  23612. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23613. * Default : false
  23614. */
  23615. translateFromPivot: boolean;
  23616. /**
  23617. * Is the particle active or not ?
  23618. */
  23619. alive: boolean;
  23620. /**
  23621. * Is the particle visible or not ?
  23622. */
  23623. isVisible: boolean;
  23624. /**
  23625. * Index of this particle in the global "positions" array (Internal use)
  23626. * @hidden
  23627. */
  23628. _pos: number;
  23629. /**
  23630. * @hidden Index of this particle in the global "indices" array (Internal use)
  23631. */
  23632. _ind: number;
  23633. /**
  23634. * @hidden ModelShape of this particle (Internal use)
  23635. */
  23636. _model: ModelShape;
  23637. /**
  23638. * ModelShape id of this particle
  23639. */
  23640. shapeId: number;
  23641. /**
  23642. * Index of the particle in its shape id (Internal use)
  23643. */
  23644. idxInShape: number;
  23645. /**
  23646. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23647. */
  23648. _modelBoundingInfo: BoundingInfo;
  23649. /**
  23650. * @hidden Particle BoundingInfo object (Internal use)
  23651. */
  23652. _boundingInfo: BoundingInfo;
  23653. /**
  23654. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23655. */
  23656. _sps: SolidParticleSystem;
  23657. /**
  23658. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23659. */
  23660. _stillInvisible: boolean;
  23661. /**
  23662. * @hidden Last computed particle rotation matrix
  23663. */
  23664. _rotationMatrix: number[];
  23665. /**
  23666. * Parent particle Id, if any.
  23667. * Default null.
  23668. */
  23669. parentId: Nullable<number>;
  23670. /**
  23671. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23672. * The possible values are :
  23673. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23674. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23675. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23676. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23677. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23678. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23679. * */
  23680. cullingStrategy: number;
  23681. /**
  23682. * @hidden Internal global position in the SPS.
  23683. */
  23684. _globalPosition: Vector3;
  23685. /**
  23686. * Creates a Solid Particle object.
  23687. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23688. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23689. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23690. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23691. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23692. * @param shapeId (integer) is the model shape identifier in the SPS.
  23693. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23694. * @param sps defines the sps it is associated to
  23695. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23696. */
  23697. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23698. /**
  23699. * Legacy support, changed scale to scaling
  23700. */
  23701. /**
  23702. * Legacy support, changed scale to scaling
  23703. */
  23704. scale: Vector3;
  23705. /**
  23706. * Legacy support, changed quaternion to rotationQuaternion
  23707. */
  23708. /**
  23709. * Legacy support, changed quaternion to rotationQuaternion
  23710. */
  23711. quaternion: Nullable<Quaternion>;
  23712. /**
  23713. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23714. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23715. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23716. * @returns true if it intersects
  23717. */
  23718. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23719. /**
  23720. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23721. * A particle is in the frustum if its bounding box intersects the frustum
  23722. * @param frustumPlanes defines the frustum to test
  23723. * @returns true if the particle is in the frustum planes
  23724. */
  23725. isInFrustum(frustumPlanes: Plane[]): boolean;
  23726. /**
  23727. * get the rotation matrix of the particle
  23728. * @hidden
  23729. */
  23730. getRotationMatrix(m: Matrix): void;
  23731. }
  23732. /**
  23733. * Represents the shape of the model used by one particle of a solid particle system.
  23734. * SPS internal tool, don't use it manually.
  23735. */
  23736. export class ModelShape {
  23737. /**
  23738. * The shape id
  23739. * @hidden
  23740. */
  23741. shapeID: number;
  23742. /**
  23743. * flat array of model positions (internal use)
  23744. * @hidden
  23745. */
  23746. _shape: Vector3[];
  23747. /**
  23748. * flat array of model UVs (internal use)
  23749. * @hidden
  23750. */
  23751. _shapeUV: number[];
  23752. /**
  23753. * length of the shape in the model indices array (internal use)
  23754. * @hidden
  23755. */
  23756. _indicesLength: number;
  23757. /**
  23758. * Custom position function (internal use)
  23759. * @hidden
  23760. */
  23761. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23762. /**
  23763. * Custom vertex function (internal use)
  23764. * @hidden
  23765. */
  23766. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23767. /**
  23768. * 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.
  23769. * SPS internal tool, don't use it manually.
  23770. * @hidden
  23771. */
  23772. 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>);
  23773. }
  23774. /**
  23775. * Represents a Depth Sorted Particle in the solid particle system.
  23776. */
  23777. export class DepthSortedParticle {
  23778. /**
  23779. * Index of the particle in the "indices" array
  23780. */
  23781. ind: number;
  23782. /**
  23783. * Length of the particle shape in the "indices" array
  23784. */
  23785. indicesLength: number;
  23786. /**
  23787. * Squared distance from the particle to the camera
  23788. */
  23789. sqDistance: number;
  23790. }
  23791. }
  23792. declare module "babylonjs/Meshes/abstractMesh" {
  23793. import { Observable } from "babylonjs/Misc/observable";
  23794. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23795. import { Camera } from "babylonjs/Cameras/camera";
  23796. import { Scene, IDisposable } from "babylonjs/scene";
  23797. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23798. import { Node } from "babylonjs/node";
  23799. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23800. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23801. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23802. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23803. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23804. import { Material } from "babylonjs/Materials/material";
  23805. import { Light } from "babylonjs/Lights/light";
  23806. import { Skeleton } from "babylonjs/Bones/skeleton";
  23807. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23808. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23809. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23810. import { Ray } from "babylonjs/Culling/ray";
  23811. import { Collider } from "babylonjs/Collisions/collider";
  23812. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23813. /**
  23814. * Class used to store all common mesh properties
  23815. */
  23816. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23817. /** No occlusion */
  23818. static OCCLUSION_TYPE_NONE: number;
  23819. /** Occlusion set to optimisitic */
  23820. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23821. /** Occlusion set to strict */
  23822. static OCCLUSION_TYPE_STRICT: number;
  23823. /** Use an accurante occlusion algorithm */
  23824. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23825. /** Use a conservative occlusion algorithm */
  23826. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23827. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23828. * Test order :
  23829. * Is the bounding sphere outside the frustum ?
  23830. * If not, are the bounding box vertices outside the frustum ?
  23831. * It not, then the cullable object is in the frustum.
  23832. */
  23833. static readonly CULLINGSTRATEGY_STANDARD: number;
  23834. /** Culling strategy : Bounding Sphere Only.
  23835. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23836. * It's also less accurate than the standard because some not visible objects can still be selected.
  23837. * Test : is the bounding sphere outside the frustum ?
  23838. * If not, then the cullable object is in the frustum.
  23839. */
  23840. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23841. /** Culling strategy : Optimistic Inclusion.
  23842. * This in an inclusion test first, then the standard exclusion test.
  23843. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23844. * 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.
  23845. * Anyway, it's as accurate as the standard strategy.
  23846. * Test :
  23847. * Is the cullable object bounding sphere center in the frustum ?
  23848. * If not, apply the default culling strategy.
  23849. */
  23850. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23851. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23852. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23853. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23854. * 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.
  23855. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23856. * Test :
  23857. * Is the cullable object bounding sphere center in the frustum ?
  23858. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23859. */
  23860. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23861. /**
  23862. * No billboard
  23863. */
  23864. static readonly BILLBOARDMODE_NONE: number;
  23865. /** Billboard on X axis */
  23866. static readonly BILLBOARDMODE_X: number;
  23867. /** Billboard on Y axis */
  23868. static readonly BILLBOARDMODE_Y: number;
  23869. /** Billboard on Z axis */
  23870. static readonly BILLBOARDMODE_Z: number;
  23871. /** Billboard on all axes */
  23872. static readonly BILLBOARDMODE_ALL: number;
  23873. private _facetData;
  23874. /**
  23875. * The culling strategy to use to check whether the mesh must be rendered or not.
  23876. * This value can be changed at any time and will be used on the next render mesh selection.
  23877. * The possible values are :
  23878. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23879. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23880. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23881. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23882. * Please read each static variable documentation to get details about the culling process.
  23883. * */
  23884. cullingStrategy: number;
  23885. /**
  23886. * Gets the number of facets in the mesh
  23887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23888. */
  23889. readonly facetNb: number;
  23890. /**
  23891. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23893. */
  23894. partitioningSubdivisions: number;
  23895. /**
  23896. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23897. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23899. */
  23900. partitioningBBoxRatio: number;
  23901. /**
  23902. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23903. * Works only for updatable meshes.
  23904. * Doesn't work with multi-materials
  23905. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23906. */
  23907. mustDepthSortFacets: boolean;
  23908. /**
  23909. * The location (Vector3) where the facet depth sort must be computed from.
  23910. * By default, the active camera position.
  23911. * Used only when facet depth sort is enabled
  23912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23913. */
  23914. facetDepthSortFrom: Vector3;
  23915. /**
  23916. * gets a boolean indicating if facetData is enabled
  23917. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23918. */
  23919. readonly isFacetDataEnabled: boolean;
  23920. /** @hidden */
  23921. _updateNonUniformScalingState(value: boolean): boolean;
  23922. /**
  23923. * An event triggered when this mesh collides with another one
  23924. */
  23925. onCollideObservable: Observable<AbstractMesh>;
  23926. private _onCollideObserver;
  23927. /** Set a function to call when this mesh collides with another one */
  23928. onCollide: () => void;
  23929. /**
  23930. * An event triggered when the collision's position changes
  23931. */
  23932. onCollisionPositionChangeObservable: Observable<Vector3>;
  23933. private _onCollisionPositionChangeObserver;
  23934. /** Set a function to call when the collision's position changes */
  23935. onCollisionPositionChange: () => void;
  23936. /**
  23937. * An event triggered when material is changed
  23938. */
  23939. onMaterialChangedObservable: Observable<AbstractMesh>;
  23940. /**
  23941. * Gets or sets the orientation for POV movement & rotation
  23942. */
  23943. definedFacingForward: boolean;
  23944. /** @hidden */
  23945. _occlusionQuery: Nullable<WebGLQuery>;
  23946. private _visibility;
  23947. /**
  23948. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23949. */
  23950. /**
  23951. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23952. */
  23953. visibility: number;
  23954. /** Gets or sets the alpha index used to sort transparent meshes
  23955. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23956. */
  23957. alphaIndex: number;
  23958. /**
  23959. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23960. */
  23961. isVisible: boolean;
  23962. /**
  23963. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23964. */
  23965. isPickable: boolean;
  23966. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23967. showSubMeshesBoundingBox: boolean;
  23968. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23969. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23970. */
  23971. isBlocker: boolean;
  23972. /**
  23973. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23974. */
  23975. enablePointerMoveEvents: boolean;
  23976. /**
  23977. * Specifies the rendering group id for this mesh (0 by default)
  23978. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23979. */
  23980. renderingGroupId: number;
  23981. private _material;
  23982. /** Gets or sets current material */
  23983. material: Nullable<Material>;
  23984. private _receiveShadows;
  23985. /**
  23986. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23987. * @see http://doc.babylonjs.com/babylon101/shadows
  23988. */
  23989. receiveShadows: boolean;
  23990. /** Defines color to use when rendering outline */
  23991. outlineColor: Color3;
  23992. /** Define width to use when rendering outline */
  23993. outlineWidth: number;
  23994. /** Defines color to use when rendering overlay */
  23995. overlayColor: Color3;
  23996. /** Defines alpha to use when rendering overlay */
  23997. overlayAlpha: number;
  23998. private _hasVertexAlpha;
  23999. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24000. hasVertexAlpha: boolean;
  24001. private _useVertexColors;
  24002. /** 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) */
  24003. useVertexColors: boolean;
  24004. private _computeBonesUsingShaders;
  24005. /**
  24006. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24007. */
  24008. computeBonesUsingShaders: boolean;
  24009. private _numBoneInfluencers;
  24010. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24011. numBoneInfluencers: number;
  24012. private _applyFog;
  24013. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24014. applyFog: boolean;
  24015. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24016. useOctreeForRenderingSelection: boolean;
  24017. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24018. useOctreeForPicking: boolean;
  24019. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24020. useOctreeForCollisions: boolean;
  24021. private _layerMask;
  24022. /**
  24023. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24024. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24025. */
  24026. layerMask: number;
  24027. /**
  24028. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24029. */
  24030. alwaysSelectAsActiveMesh: boolean;
  24031. /**
  24032. * Gets or sets the current action manager
  24033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24034. */
  24035. actionManager: Nullable<AbstractActionManager>;
  24036. private _checkCollisions;
  24037. private _collisionMask;
  24038. private _collisionGroup;
  24039. /**
  24040. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24041. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24042. */
  24043. ellipsoid: Vector3;
  24044. /**
  24045. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24046. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24047. */
  24048. ellipsoidOffset: Vector3;
  24049. private _collider;
  24050. private _oldPositionForCollisions;
  24051. private _diffPositionForCollisions;
  24052. /**
  24053. * Gets or sets a collision mask used to mask collisions (default is -1).
  24054. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24055. */
  24056. collisionMask: number;
  24057. /**
  24058. * Gets or sets the current collision group mask (-1 by default).
  24059. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24060. */
  24061. collisionGroup: number;
  24062. /**
  24063. * Defines edge width used when edgesRenderer is enabled
  24064. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24065. */
  24066. edgesWidth: number;
  24067. /**
  24068. * Defines edge color used when edgesRenderer is enabled
  24069. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24070. */
  24071. edgesColor: Color4;
  24072. /** @hidden */
  24073. _edgesRenderer: Nullable<IEdgesRenderer>;
  24074. /** @hidden */
  24075. _masterMesh: Nullable<AbstractMesh>;
  24076. /** @hidden */
  24077. _boundingInfo: Nullable<BoundingInfo>;
  24078. /** @hidden */
  24079. _renderId: number;
  24080. /**
  24081. * Gets or sets the list of subMeshes
  24082. * @see http://doc.babylonjs.com/how_to/multi_materials
  24083. */
  24084. subMeshes: SubMesh[];
  24085. /** @hidden */
  24086. _intersectionsInProgress: AbstractMesh[];
  24087. /** @hidden */
  24088. _unIndexed: boolean;
  24089. /** @hidden */
  24090. _lightSources: Light[];
  24091. /** @hidden */
  24092. readonly _positions: Nullable<Vector3[]>;
  24093. /** @hidden */
  24094. _waitingActions: any;
  24095. /** @hidden */
  24096. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24097. private _skeleton;
  24098. /** @hidden */
  24099. _bonesTransformMatrices: Nullable<Float32Array>;
  24100. /**
  24101. * Gets or sets a skeleton to apply skining transformations
  24102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24103. */
  24104. skeleton: Nullable<Skeleton>;
  24105. /**
  24106. * An event triggered when the mesh is rebuilt.
  24107. */
  24108. onRebuildObservable: Observable<AbstractMesh>;
  24109. /**
  24110. * Creates a new AbstractMesh
  24111. * @param name defines the name of the mesh
  24112. * @param scene defines the hosting scene
  24113. */
  24114. constructor(name: string, scene?: Nullable<Scene>);
  24115. /**
  24116. * Returns the string "AbstractMesh"
  24117. * @returns "AbstractMesh"
  24118. */
  24119. getClassName(): string;
  24120. /**
  24121. * Gets a string representation of the current mesh
  24122. * @param fullDetails defines a boolean indicating if full details must be included
  24123. * @returns a string representation of the current mesh
  24124. */
  24125. toString(fullDetails?: boolean): string;
  24126. /** @hidden */
  24127. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24128. /** @hidden */
  24129. _rebuild(): void;
  24130. /** @hidden */
  24131. _resyncLightSources(): void;
  24132. /** @hidden */
  24133. _resyncLighSource(light: Light): void;
  24134. /** @hidden */
  24135. _unBindEffect(): void;
  24136. /** @hidden */
  24137. _removeLightSource(light: Light): void;
  24138. private _markSubMeshesAsDirty;
  24139. /** @hidden */
  24140. _markSubMeshesAsLightDirty(): void;
  24141. /** @hidden */
  24142. _markSubMeshesAsAttributesDirty(): void;
  24143. /** @hidden */
  24144. _markSubMeshesAsMiscDirty(): void;
  24145. /**
  24146. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24147. */
  24148. scaling: Vector3;
  24149. /**
  24150. * Returns true if the mesh is blocked. Implemented by child classes
  24151. */
  24152. readonly isBlocked: boolean;
  24153. /**
  24154. * Returns the mesh itself by default. Implemented by child classes
  24155. * @param camera defines the camera to use to pick the right LOD level
  24156. * @returns the currentAbstractMesh
  24157. */
  24158. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24159. /**
  24160. * Returns 0 by default. Implemented by child classes
  24161. * @returns an integer
  24162. */
  24163. getTotalVertices(): number;
  24164. /**
  24165. * Returns a positive integer : the total number of indices in this mesh geometry.
  24166. * @returns the numner of indices or zero if the mesh has no geometry.
  24167. */
  24168. getTotalIndices(): number;
  24169. /**
  24170. * Returns null by default. Implemented by child classes
  24171. * @returns null
  24172. */
  24173. getIndices(): Nullable<IndicesArray>;
  24174. /**
  24175. * Returns the array of the requested vertex data kind. Implemented by child classes
  24176. * @param kind defines the vertex data kind to use
  24177. * @returns null
  24178. */
  24179. getVerticesData(kind: string): Nullable<FloatArray>;
  24180. /**
  24181. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24182. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24183. * Note that a new underlying VertexBuffer object is created each call.
  24184. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24185. * @param kind defines vertex data kind:
  24186. * * VertexBuffer.PositionKind
  24187. * * VertexBuffer.UVKind
  24188. * * VertexBuffer.UV2Kind
  24189. * * VertexBuffer.UV3Kind
  24190. * * VertexBuffer.UV4Kind
  24191. * * VertexBuffer.UV5Kind
  24192. * * VertexBuffer.UV6Kind
  24193. * * VertexBuffer.ColorKind
  24194. * * VertexBuffer.MatricesIndicesKind
  24195. * * VertexBuffer.MatricesIndicesExtraKind
  24196. * * VertexBuffer.MatricesWeightsKind
  24197. * * VertexBuffer.MatricesWeightsExtraKind
  24198. * @param data defines the data source
  24199. * @param updatable defines if the data must be flagged as updatable (or static)
  24200. * @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
  24201. * @returns the current mesh
  24202. */
  24203. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24204. /**
  24205. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24206. * If the mesh has no geometry, it is simply returned as it is.
  24207. * @param kind defines vertex data kind:
  24208. * * VertexBuffer.PositionKind
  24209. * * VertexBuffer.UVKind
  24210. * * VertexBuffer.UV2Kind
  24211. * * VertexBuffer.UV3Kind
  24212. * * VertexBuffer.UV4Kind
  24213. * * VertexBuffer.UV5Kind
  24214. * * VertexBuffer.UV6Kind
  24215. * * VertexBuffer.ColorKind
  24216. * * VertexBuffer.MatricesIndicesKind
  24217. * * VertexBuffer.MatricesIndicesExtraKind
  24218. * * VertexBuffer.MatricesWeightsKind
  24219. * * VertexBuffer.MatricesWeightsExtraKind
  24220. * @param data defines the data source
  24221. * @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
  24222. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24223. * @returns the current mesh
  24224. */
  24225. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24226. /**
  24227. * Sets the mesh indices,
  24228. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24229. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24230. * @param totalVertices Defines the total number of vertices
  24231. * @returns the current mesh
  24232. */
  24233. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24234. /**
  24235. * Gets a boolean indicating if specific vertex data is present
  24236. * @param kind defines the vertex data kind to use
  24237. * @returns true is data kind is present
  24238. */
  24239. isVerticesDataPresent(kind: string): boolean;
  24240. /**
  24241. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24242. * @returns a BoundingInfo
  24243. */
  24244. getBoundingInfo(): BoundingInfo;
  24245. /**
  24246. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24247. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24248. * @returns the current mesh
  24249. */
  24250. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24251. /**
  24252. * Overwrite the current bounding info
  24253. * @param boundingInfo defines the new bounding info
  24254. * @returns the current mesh
  24255. */
  24256. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24257. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24258. readonly useBones: boolean;
  24259. /** @hidden */
  24260. _preActivate(): void;
  24261. /** @hidden */
  24262. _preActivateForIntermediateRendering(renderId: number): void;
  24263. /** @hidden */
  24264. _activate(renderId: number): void;
  24265. /**
  24266. * Gets the current world matrix
  24267. * @returns a Matrix
  24268. */
  24269. getWorldMatrix(): Matrix;
  24270. /** @hidden */
  24271. _getWorldMatrixDeterminant(): number;
  24272. /**
  24273. * Perform relative position change from the point of view of behind the front of the mesh.
  24274. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24275. * Supports definition of mesh facing forward or backward
  24276. * @param amountRight defines the distance on the right axis
  24277. * @param amountUp defines the distance on the up axis
  24278. * @param amountForward defines the distance on the forward axis
  24279. * @returns the current mesh
  24280. */
  24281. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24282. /**
  24283. * Calculate relative position change from the point of view of behind the front of the mesh.
  24284. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24285. * Supports definition of mesh facing forward or backward
  24286. * @param amountRight defines the distance on the right axis
  24287. * @param amountUp defines the distance on the up axis
  24288. * @param amountForward defines the distance on the forward axis
  24289. * @returns the new displacement vector
  24290. */
  24291. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24292. /**
  24293. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24294. * Supports definition of mesh facing forward or backward
  24295. * @param flipBack defines the flip
  24296. * @param twirlClockwise defines the twirl
  24297. * @param tiltRight defines the tilt
  24298. * @returns the current mesh
  24299. */
  24300. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24301. /**
  24302. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24303. * Supports definition of mesh facing forward or backward.
  24304. * @param flipBack defines the flip
  24305. * @param twirlClockwise defines the twirl
  24306. * @param tiltRight defines the tilt
  24307. * @returns the new rotation vector
  24308. */
  24309. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24310. /**
  24311. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24312. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24313. * @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
  24314. * @returns the new bounding vectors
  24315. */
  24316. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24317. min: Vector3;
  24318. max: Vector3;
  24319. };
  24320. /**
  24321. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24322. * This means the mesh underlying bounding box and sphere are recomputed.
  24323. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24324. * @returns the current mesh
  24325. */
  24326. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24327. /** @hidden */
  24328. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24329. /** @hidden */
  24330. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24331. /** @hidden */
  24332. _updateBoundingInfo(): AbstractMesh;
  24333. /** @hidden */
  24334. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24335. /** @hidden */
  24336. protected _afterComputeWorldMatrix(): void;
  24337. /**
  24338. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24339. * A mesh is in the frustum if its bounding box intersects the frustum
  24340. * @param frustumPlanes defines the frustum to test
  24341. * @returns true if the mesh is in the frustum planes
  24342. */
  24343. isInFrustum(frustumPlanes: Plane[]): boolean;
  24344. /**
  24345. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24346. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24347. * @param frustumPlanes defines the frustum to test
  24348. * @returns true if the mesh is completely in the frustum planes
  24349. */
  24350. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24351. /**
  24352. * True if the mesh intersects another mesh or a SolidParticle object
  24353. * @param mesh defines a target mesh or SolidParticle to test
  24354. * @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)
  24355. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24356. * @returns true if there is an intersection
  24357. */
  24358. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24359. /**
  24360. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24361. * @param point defines the point to test
  24362. * @returns true if there is an intersection
  24363. */
  24364. intersectsPoint(point: Vector3): boolean;
  24365. /**
  24366. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24367. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24368. */
  24369. checkCollisions: boolean;
  24370. /**
  24371. * Gets Collider object used to compute collisions (not physics)
  24372. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24373. */
  24374. readonly collider: Collider;
  24375. /**
  24376. * Move the mesh using collision engine
  24377. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24378. * @param displacement defines the requested displacement vector
  24379. * @returns the current mesh
  24380. */
  24381. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24382. private _onCollisionPositionChange;
  24383. /** @hidden */
  24384. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24385. /** @hidden */
  24386. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24387. /** @hidden */
  24388. _checkCollision(collider: Collider): AbstractMesh;
  24389. /** @hidden */
  24390. _generatePointsArray(): boolean;
  24391. /**
  24392. * Checks if the passed Ray intersects with the mesh
  24393. * @param ray defines the ray to use
  24394. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24395. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24396. * @returns the picking info
  24397. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24398. */
  24399. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24400. /**
  24401. * Clones the current mesh
  24402. * @param name defines the mesh name
  24403. * @param newParent defines the new mesh parent
  24404. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24405. * @returns the new mesh
  24406. */
  24407. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24408. /**
  24409. * Disposes all the submeshes of the current meshnp
  24410. * @returns the current mesh
  24411. */
  24412. releaseSubMeshes(): AbstractMesh;
  24413. /**
  24414. * Releases resources associated with this abstract mesh.
  24415. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24416. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24417. */
  24418. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24419. /**
  24420. * Adds the passed mesh as a child to the current mesh
  24421. * @param mesh defines the child mesh
  24422. * @returns the current mesh
  24423. */
  24424. addChild(mesh: AbstractMesh): AbstractMesh;
  24425. /**
  24426. * Removes the passed mesh from the current mesh children list
  24427. * @param mesh defines the child mesh
  24428. * @returns the current mesh
  24429. */
  24430. removeChild(mesh: AbstractMesh): AbstractMesh;
  24431. /** @hidden */
  24432. private _initFacetData;
  24433. /**
  24434. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24435. * This method can be called within the render loop.
  24436. * 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
  24437. * @returns the current mesh
  24438. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24439. */
  24440. updateFacetData(): AbstractMesh;
  24441. /**
  24442. * Returns the facetLocalNormals array.
  24443. * The normals are expressed in the mesh local spac
  24444. * @returns an array of Vector3
  24445. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24446. */
  24447. getFacetLocalNormals(): Vector3[];
  24448. /**
  24449. * Returns the facetLocalPositions array.
  24450. * The facet positions are expressed in the mesh local space
  24451. * @returns an array of Vector3
  24452. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24453. */
  24454. getFacetLocalPositions(): Vector3[];
  24455. /**
  24456. * Returns the facetLocalPartioning array
  24457. * @returns an array of array of numbers
  24458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24459. */
  24460. getFacetLocalPartitioning(): number[][];
  24461. /**
  24462. * Returns the i-th facet position in the world system.
  24463. * This method allocates a new Vector3 per call
  24464. * @param i defines the facet index
  24465. * @returns a new Vector3
  24466. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24467. */
  24468. getFacetPosition(i: number): Vector3;
  24469. /**
  24470. * Sets the reference Vector3 with the i-th facet position in the world system
  24471. * @param i defines the facet index
  24472. * @param ref defines the target vector
  24473. * @returns the current mesh
  24474. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24475. */
  24476. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24477. /**
  24478. * Returns the i-th facet normal in the world system.
  24479. * This method allocates a new Vector3 per call
  24480. * @param i defines the facet index
  24481. * @returns a new Vector3
  24482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24483. */
  24484. getFacetNormal(i: number): Vector3;
  24485. /**
  24486. * Sets the reference Vector3 with the i-th facet normal in the world system
  24487. * @param i defines the facet index
  24488. * @param ref defines the target vector
  24489. * @returns the current mesh
  24490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24491. */
  24492. getFacetNormalToRef(i: number, ref: Vector3): this;
  24493. /**
  24494. * 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)
  24495. * @param x defines x coordinate
  24496. * @param y defines y coordinate
  24497. * @param z defines z coordinate
  24498. * @returns the array of facet indexes
  24499. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24500. */
  24501. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24502. /**
  24503. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24504. * @param projected sets as the (x,y,z) world projection on the facet
  24505. * @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
  24506. * @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
  24507. * @param x defines x coordinate
  24508. * @param y defines y coordinate
  24509. * @param z defines z coordinate
  24510. * @returns the face index if found (or null instead)
  24511. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24512. */
  24513. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24514. /**
  24515. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24516. * @param projected sets as the (x,y,z) local projection on the facet
  24517. * @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
  24518. * @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
  24519. * @param x defines x coordinate
  24520. * @param y defines y coordinate
  24521. * @param z defines z coordinate
  24522. * @returns the face index if found (or null instead)
  24523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24524. */
  24525. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24526. /**
  24527. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24528. * @returns the parameters
  24529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24530. */
  24531. getFacetDataParameters(): any;
  24532. /**
  24533. * Disables the feature FacetData and frees the related memory
  24534. * @returns the current mesh
  24535. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24536. */
  24537. disableFacetData(): AbstractMesh;
  24538. /**
  24539. * Updates the AbstractMesh indices array
  24540. * @param indices defines the data source
  24541. * @returns the current mesh
  24542. */
  24543. updateIndices(indices: IndicesArray): AbstractMesh;
  24544. /**
  24545. * Creates new normals data for the mesh
  24546. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24547. * @returns the current mesh
  24548. */
  24549. createNormals(updatable: boolean): AbstractMesh;
  24550. /**
  24551. * Align the mesh with a normal
  24552. * @param normal defines the normal to use
  24553. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24554. * @returns the current mesh
  24555. */
  24556. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24557. /** @hidden */
  24558. _checkOcclusionQuery(): boolean;
  24559. }
  24560. }
  24561. declare module "babylonjs/Actions/actionEvent" {
  24562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24563. import { Nullable } from "babylonjs/types";
  24564. import { Sprite } from "babylonjs/Sprites/sprite";
  24565. import { Scene } from "babylonjs/scene";
  24566. import { Vector2 } from "babylonjs/Maths/math";
  24567. /**
  24568. * Interface used to define ActionEvent
  24569. */
  24570. export interface IActionEvent {
  24571. /** The mesh or sprite that triggered the action */
  24572. source: any;
  24573. /** The X mouse cursor position at the time of the event */
  24574. pointerX: number;
  24575. /** The Y mouse cursor position at the time of the event */
  24576. pointerY: number;
  24577. /** The mesh that is currently pointed at (can be null) */
  24578. meshUnderPointer: Nullable<AbstractMesh>;
  24579. /** the original (browser) event that triggered the ActionEvent */
  24580. sourceEvent?: any;
  24581. /** additional data for the event */
  24582. additionalData?: any;
  24583. }
  24584. /**
  24585. * ActionEvent is the event being sent when an action is triggered.
  24586. */
  24587. export class ActionEvent implements IActionEvent {
  24588. /** The mesh or sprite that triggered the action */
  24589. source: any;
  24590. /** The X mouse cursor position at the time of the event */
  24591. pointerX: number;
  24592. /** The Y mouse cursor position at the time of the event */
  24593. pointerY: number;
  24594. /** The mesh that is currently pointed at (can be null) */
  24595. meshUnderPointer: Nullable<AbstractMesh>;
  24596. /** the original (browser) event that triggered the ActionEvent */
  24597. sourceEvent?: any;
  24598. /** additional data for the event */
  24599. additionalData?: any;
  24600. /**
  24601. * Creates a new ActionEvent
  24602. * @param source The mesh or sprite that triggered the action
  24603. * @param pointerX The X mouse cursor position at the time of the event
  24604. * @param pointerY The Y mouse cursor position at the time of the event
  24605. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24606. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24607. * @param additionalData additional data for the event
  24608. */
  24609. constructor(
  24610. /** The mesh or sprite that triggered the action */
  24611. source: any,
  24612. /** The X mouse cursor position at the time of the event */
  24613. pointerX: number,
  24614. /** The Y mouse cursor position at the time of the event */
  24615. pointerY: number,
  24616. /** The mesh that is currently pointed at (can be null) */
  24617. meshUnderPointer: Nullable<AbstractMesh>,
  24618. /** the original (browser) event that triggered the ActionEvent */
  24619. sourceEvent?: any,
  24620. /** additional data for the event */
  24621. additionalData?: any);
  24622. /**
  24623. * Helper function to auto-create an ActionEvent from a source mesh.
  24624. * @param source The source mesh that triggered the event
  24625. * @param evt The original (browser) event
  24626. * @param additionalData additional data for the event
  24627. * @returns the new ActionEvent
  24628. */
  24629. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24630. /**
  24631. * Helper function to auto-create an ActionEvent from a source sprite
  24632. * @param source The source sprite that triggered the event
  24633. * @param scene Scene associated with the sprite
  24634. * @param evt The original (browser) event
  24635. * @param additionalData additional data for the event
  24636. * @returns the new ActionEvent
  24637. */
  24638. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24639. /**
  24640. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24641. * @param scene the scene where the event occurred
  24642. * @param evt The original (browser) event
  24643. * @returns the new ActionEvent
  24644. */
  24645. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24646. /**
  24647. * Helper function to auto-create an ActionEvent from a primitive
  24648. * @param prim defines the target primitive
  24649. * @param pointerPos defines the pointer position
  24650. * @param evt The original (browser) event
  24651. * @param additionalData additional data for the event
  24652. * @returns the new ActionEvent
  24653. */
  24654. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24655. }
  24656. }
  24657. declare module "babylonjs/Actions/abstractActionManager" {
  24658. import { IDisposable } from "babylonjs/scene";
  24659. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24660. import { IAction } from "babylonjs/Actions/action";
  24661. /**
  24662. * Abstract class used to decouple action Manager from scene and meshes.
  24663. * Do not instantiate.
  24664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24665. */
  24666. export abstract class AbstractActionManager implements IDisposable {
  24667. /** Gets the list of active triggers */
  24668. static Triggers: {
  24669. [key: string]: number;
  24670. };
  24671. /** Gets the cursor to use when hovering items */
  24672. hoverCursor: string;
  24673. /** Gets the list of actions */
  24674. actions: IAction[];
  24675. /**
  24676. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24677. */
  24678. isRecursive: boolean;
  24679. /**
  24680. * Releases all associated resources
  24681. */
  24682. abstract dispose(): void;
  24683. /**
  24684. * Does this action manager has pointer triggers
  24685. */
  24686. abstract readonly hasPointerTriggers: boolean;
  24687. /**
  24688. * Does this action manager has pick triggers
  24689. */
  24690. abstract readonly hasPickTriggers: boolean;
  24691. /**
  24692. * Process a specific trigger
  24693. * @param trigger defines the trigger to process
  24694. * @param evt defines the event details to be processed
  24695. */
  24696. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24697. /**
  24698. * Does this action manager handles actions of any of the given triggers
  24699. * @param triggers defines the triggers to be tested
  24700. * @return a boolean indicating whether one (or more) of the triggers is handled
  24701. */
  24702. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24703. /**
  24704. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24705. * speed.
  24706. * @param triggerA defines the trigger to be tested
  24707. * @param triggerB defines the trigger to be tested
  24708. * @return a boolean indicating whether one (or more) of the triggers is handled
  24709. */
  24710. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24711. /**
  24712. * Does this action manager handles actions of a given trigger
  24713. * @param trigger defines the trigger to be tested
  24714. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24715. * @return whether the trigger is handled
  24716. */
  24717. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24718. /**
  24719. * Serialize this manager to a JSON object
  24720. * @param name defines the property name to store this manager
  24721. * @returns a JSON representation of this manager
  24722. */
  24723. abstract serialize(name: string): any;
  24724. /**
  24725. * Does exist one action manager with at least one trigger
  24726. **/
  24727. static readonly HasTriggers: boolean;
  24728. /**
  24729. * Does exist one action manager with at least one pick trigger
  24730. **/
  24731. static readonly HasPickTriggers: boolean;
  24732. /**
  24733. * Does exist one action manager that handles actions of a given trigger
  24734. * @param trigger defines the trigger to be tested
  24735. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24736. **/
  24737. static HasSpecificTrigger(trigger: number): boolean;
  24738. }
  24739. }
  24740. declare module "babylonjs/node" {
  24741. import { Scene } from "babylonjs/scene";
  24742. import { Nullable } from "babylonjs/types";
  24743. import { Matrix } from "babylonjs/Maths/math";
  24744. import { Engine } from "babylonjs/Engines/engine";
  24745. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24746. import { Observable } from "babylonjs/Misc/observable";
  24747. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24748. import { Animatable } from "babylonjs/Animations/animatable";
  24749. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24750. import { Animation } from "babylonjs/Animations/animation";
  24751. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24753. /**
  24754. * Defines how a node can be built from a string name.
  24755. */
  24756. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24757. /**
  24758. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24759. */
  24760. export class Node implements IBehaviorAware<Node> {
  24761. /** @hidden */
  24762. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24763. private static _NodeConstructors;
  24764. /**
  24765. * Add a new node constructor
  24766. * @param type defines the type name of the node to construct
  24767. * @param constructorFunc defines the constructor function
  24768. */
  24769. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24770. /**
  24771. * Returns a node constructor based on type name
  24772. * @param type defines the type name
  24773. * @param name defines the new node name
  24774. * @param scene defines the hosting scene
  24775. * @param options defines optional options to transmit to constructors
  24776. * @returns the new constructor or null
  24777. */
  24778. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24779. /**
  24780. * Gets or sets the name of the node
  24781. */
  24782. name: string;
  24783. /**
  24784. * Gets or sets the id of the node
  24785. */
  24786. id: string;
  24787. /**
  24788. * Gets or sets the unique id of the node
  24789. */
  24790. uniqueId: number;
  24791. /**
  24792. * Gets or sets a string used to store user defined state for the node
  24793. */
  24794. state: string;
  24795. /**
  24796. * Gets or sets an object used to store user defined information for the node
  24797. */
  24798. metadata: any;
  24799. /**
  24800. * For internal use only. Please do not use.
  24801. */
  24802. reservedDataStore: any;
  24803. /**
  24804. * Gets or sets a boolean used to define if the node must be serialized
  24805. */
  24806. doNotSerialize: boolean;
  24807. /** @hidden */
  24808. _isDisposed: boolean;
  24809. /**
  24810. * Gets a list of Animations associated with the node
  24811. */
  24812. animations: import("babylonjs/Animations/animation").Animation[];
  24813. protected _ranges: {
  24814. [name: string]: Nullable<AnimationRange>;
  24815. };
  24816. /**
  24817. * Callback raised when the node is ready to be used
  24818. */
  24819. onReady: (node: Node) => void;
  24820. private _isEnabled;
  24821. private _isParentEnabled;
  24822. private _isReady;
  24823. /** @hidden */
  24824. _currentRenderId: number;
  24825. private _parentRenderId;
  24826. protected _childRenderId: number;
  24827. /** @hidden */
  24828. _waitingParentId: Nullable<string>;
  24829. /** @hidden */
  24830. _scene: Scene;
  24831. /** @hidden */
  24832. _cache: any;
  24833. private _parentNode;
  24834. private _children;
  24835. /** @hidden */
  24836. _worldMatrix: Matrix;
  24837. /** @hidden */
  24838. _worldMatrixDeterminant: number;
  24839. /** @hidden */
  24840. private _sceneRootNodesIndex;
  24841. /**
  24842. * Gets a boolean indicating if the node has been disposed
  24843. * @returns true if the node was disposed
  24844. */
  24845. isDisposed(): boolean;
  24846. /**
  24847. * Gets or sets the parent of the node
  24848. */
  24849. parent: Nullable<Node>;
  24850. private addToSceneRootNodes;
  24851. private removeFromSceneRootNodes;
  24852. private _animationPropertiesOverride;
  24853. /**
  24854. * Gets or sets the animation properties override
  24855. */
  24856. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24857. /**
  24858. * Gets a string idenfifying the name of the class
  24859. * @returns "Node" string
  24860. */
  24861. getClassName(): string;
  24862. /** @hidden */
  24863. readonly _isNode: boolean;
  24864. /**
  24865. * An event triggered when the mesh is disposed
  24866. */
  24867. onDisposeObservable: Observable<Node>;
  24868. private _onDisposeObserver;
  24869. /**
  24870. * Sets a callback that will be raised when the node will be disposed
  24871. */
  24872. onDispose: () => void;
  24873. /**
  24874. * Creates a new Node
  24875. * @param name the name and id to be given to this node
  24876. * @param scene the scene this node will be added to
  24877. * @param addToRootNodes the node will be added to scene.rootNodes
  24878. */
  24879. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24880. /**
  24881. * Gets the scene of the node
  24882. * @returns a scene
  24883. */
  24884. getScene(): Scene;
  24885. /**
  24886. * Gets the engine of the node
  24887. * @returns a Engine
  24888. */
  24889. getEngine(): Engine;
  24890. private _behaviors;
  24891. /**
  24892. * Attach a behavior to the node
  24893. * @see http://doc.babylonjs.com/features/behaviour
  24894. * @param behavior defines the behavior to attach
  24895. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24896. * @returns the current Node
  24897. */
  24898. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24899. /**
  24900. * Remove an attached behavior
  24901. * @see http://doc.babylonjs.com/features/behaviour
  24902. * @param behavior defines the behavior to attach
  24903. * @returns the current Node
  24904. */
  24905. removeBehavior(behavior: Behavior<Node>): Node;
  24906. /**
  24907. * Gets the list of attached behaviors
  24908. * @see http://doc.babylonjs.com/features/behaviour
  24909. */
  24910. readonly behaviors: Behavior<Node>[];
  24911. /**
  24912. * Gets an attached behavior by name
  24913. * @param name defines the name of the behavior to look for
  24914. * @see http://doc.babylonjs.com/features/behaviour
  24915. * @returns null if behavior was not found else the requested behavior
  24916. */
  24917. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24918. /**
  24919. * Returns the latest update of the World matrix
  24920. * @returns a Matrix
  24921. */
  24922. getWorldMatrix(): Matrix;
  24923. /** @hidden */
  24924. _getWorldMatrixDeterminant(): number;
  24925. /**
  24926. * Returns directly the latest state of the mesh World matrix.
  24927. * A Matrix is returned.
  24928. */
  24929. readonly worldMatrixFromCache: Matrix;
  24930. /** @hidden */
  24931. _initCache(): void;
  24932. /** @hidden */
  24933. updateCache(force?: boolean): void;
  24934. /** @hidden */
  24935. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24936. /** @hidden */
  24937. _updateCache(ignoreParentClass?: boolean): void;
  24938. /** @hidden */
  24939. _isSynchronized(): boolean;
  24940. /** @hidden */
  24941. _markSyncedWithParent(): void;
  24942. /** @hidden */
  24943. isSynchronizedWithParent(): boolean;
  24944. /** @hidden */
  24945. isSynchronized(): boolean;
  24946. /**
  24947. * Is this node ready to be used/rendered
  24948. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24949. * @return true if the node is ready
  24950. */
  24951. isReady(completeCheck?: boolean): boolean;
  24952. /**
  24953. * Is this node enabled?
  24954. * 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
  24955. * @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
  24956. * @return whether this node (and its parent) is enabled
  24957. */
  24958. isEnabled(checkAncestors?: boolean): boolean;
  24959. /** @hidden */
  24960. protected _syncParentEnabledState(): void;
  24961. /**
  24962. * Set the enabled state of this node
  24963. * @param value defines the new enabled state
  24964. */
  24965. setEnabled(value: boolean): void;
  24966. /**
  24967. * Is this node a descendant of the given node?
  24968. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24969. * @param ancestor defines the parent node to inspect
  24970. * @returns a boolean indicating if this node is a descendant of the given node
  24971. */
  24972. isDescendantOf(ancestor: Node): boolean;
  24973. /** @hidden */
  24974. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24975. /**
  24976. * Will return all nodes that have this node as ascendant
  24977. * @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
  24978. * @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
  24979. * @return all children nodes of all types
  24980. */
  24981. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24982. /**
  24983. * Get all child-meshes of this node
  24984. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  24985. * @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
  24986. * @returns an array of AbstractMesh
  24987. */
  24988. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24989. /**
  24990. * Get all direct children of this node
  24991. * @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
  24992. * @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)
  24993. * @returns an array of Node
  24994. */
  24995. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24996. /** @hidden */
  24997. _setReady(state: boolean): void;
  24998. /**
  24999. * Get an animation by name
  25000. * @param name defines the name of the animation to look for
  25001. * @returns null if not found else the requested animation
  25002. */
  25003. getAnimationByName(name: string): Nullable<Animation>;
  25004. /**
  25005. * Creates an animation range for this node
  25006. * @param name defines the name of the range
  25007. * @param from defines the starting key
  25008. * @param to defines the end key
  25009. */
  25010. createAnimationRange(name: string, from: number, to: number): void;
  25011. /**
  25012. * Delete a specific animation range
  25013. * @param name defines the name of the range to delete
  25014. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25015. */
  25016. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25017. /**
  25018. * Get an animation range by name
  25019. * @param name defines the name of the animation range to look for
  25020. * @returns null if not found else the requested animation range
  25021. */
  25022. getAnimationRange(name: string): Nullable<AnimationRange>;
  25023. /**
  25024. * Gets the list of all animation ranges defined on this node
  25025. * @returns an array
  25026. */
  25027. getAnimationRanges(): Nullable<AnimationRange>[];
  25028. /**
  25029. * Will start the animation sequence
  25030. * @param name defines the range frames for animation sequence
  25031. * @param loop defines if the animation should loop (false by default)
  25032. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25033. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25034. * @returns the object created for this animation. If range does not exist, it will return null
  25035. */
  25036. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25037. /**
  25038. * Serialize animation ranges into a JSON compatible object
  25039. * @returns serialization object
  25040. */
  25041. serializeAnimationRanges(): any;
  25042. /**
  25043. * Computes the world matrix of the node
  25044. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25045. * @returns the world matrix
  25046. */
  25047. computeWorldMatrix(force?: boolean): Matrix;
  25048. /**
  25049. * Releases resources associated with this node.
  25050. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25051. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25052. */
  25053. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25054. /**
  25055. * Parse animation range data from a serialization object and store them into a given node
  25056. * @param node defines where to store the animation ranges
  25057. * @param parsedNode defines the serialization object to read data from
  25058. * @param scene defines the hosting scene
  25059. */
  25060. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25061. }
  25062. }
  25063. declare module "babylonjs/Animations/animation" {
  25064. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25065. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25066. import { Nullable } from "babylonjs/types";
  25067. import { Scene } from "babylonjs/scene";
  25068. import { IAnimatable } from "babylonjs/Misc/tools";
  25069. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25070. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25071. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25072. import { Node } from "babylonjs/node";
  25073. import { Animatable } from "babylonjs/Animations/animatable";
  25074. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25075. /**
  25076. * Class used to store any kind of animation
  25077. */
  25078. export class Animation {
  25079. /**Name of the animation */
  25080. name: string;
  25081. /**Property to animate */
  25082. targetProperty: string;
  25083. /**The frames per second of the animation */
  25084. framePerSecond: number;
  25085. /**The data type of the animation */
  25086. dataType: number;
  25087. /**The loop mode of the animation */
  25088. loopMode?: number | undefined;
  25089. /**Specifies if blending should be enabled */
  25090. enableBlending?: boolean | undefined;
  25091. /**
  25092. * Use matrix interpolation instead of using direct key value when animating matrices
  25093. */
  25094. static AllowMatricesInterpolation: boolean;
  25095. /**
  25096. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25097. */
  25098. static AllowMatrixDecomposeForInterpolation: boolean;
  25099. /**
  25100. * Stores the key frames of the animation
  25101. */
  25102. private _keys;
  25103. /**
  25104. * Stores the easing function of the animation
  25105. */
  25106. private _easingFunction;
  25107. /**
  25108. * @hidden Internal use only
  25109. */
  25110. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25111. /**
  25112. * The set of event that will be linked to this animation
  25113. */
  25114. private _events;
  25115. /**
  25116. * Stores an array of target property paths
  25117. */
  25118. targetPropertyPath: string[];
  25119. /**
  25120. * Stores the blending speed of the animation
  25121. */
  25122. blendingSpeed: number;
  25123. /**
  25124. * Stores the animation ranges for the animation
  25125. */
  25126. private _ranges;
  25127. /**
  25128. * @hidden Internal use
  25129. */
  25130. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25131. /**
  25132. * Sets up an animation
  25133. * @param property The property to animate
  25134. * @param animationType The animation type to apply
  25135. * @param framePerSecond The frames per second of the animation
  25136. * @param easingFunction The easing function used in the animation
  25137. * @returns The created animation
  25138. */
  25139. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25140. /**
  25141. * Create and start an animation on a node
  25142. * @param name defines the name of the global animation that will be run on all nodes
  25143. * @param node defines the root node where the animation will take place
  25144. * @param targetProperty defines property to animate
  25145. * @param framePerSecond defines the number of frame per second yo use
  25146. * @param totalFrame defines the number of frames in total
  25147. * @param from defines the initial value
  25148. * @param to defines the final value
  25149. * @param loopMode defines which loop mode you want to use (off by default)
  25150. * @param easingFunction defines the easing function to use (linear by default)
  25151. * @param onAnimationEnd defines the callback to call when animation end
  25152. * @returns the animatable created for this animation
  25153. */
  25154. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25155. /**
  25156. * Create and start an animation on a node and its descendants
  25157. * @param name defines the name of the global animation that will be run on all nodes
  25158. * @param node defines the root node where the animation will take place
  25159. * @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
  25160. * @param targetProperty defines property to animate
  25161. * @param framePerSecond defines the number of frame per second to use
  25162. * @param totalFrame defines the number of frames in total
  25163. * @param from defines the initial value
  25164. * @param to defines the final value
  25165. * @param loopMode defines which loop mode you want to use (off by default)
  25166. * @param easingFunction defines the easing function to use (linear by default)
  25167. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25168. * @returns the list of animatables created for all nodes
  25169. * @example https://www.babylonjs-playground.com/#MH0VLI
  25170. */
  25171. 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[]>;
  25172. /**
  25173. * Creates a new animation, merges it with the existing animations and starts it
  25174. * @param name Name of the animation
  25175. * @param node Node which contains the scene that begins the animations
  25176. * @param targetProperty Specifies which property to animate
  25177. * @param framePerSecond The frames per second of the animation
  25178. * @param totalFrame The total number of frames
  25179. * @param from The frame at the beginning of the animation
  25180. * @param to The frame at the end of the animation
  25181. * @param loopMode Specifies the loop mode of the animation
  25182. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25183. * @param onAnimationEnd Callback to run once the animation is complete
  25184. * @returns Nullable animation
  25185. */
  25186. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25187. /**
  25188. * Transition property of an host to the target Value
  25189. * @param property The property to transition
  25190. * @param targetValue The target Value of the property
  25191. * @param host The object where the property to animate belongs
  25192. * @param scene Scene used to run the animation
  25193. * @param frameRate Framerate (in frame/s) to use
  25194. * @param transition The transition type we want to use
  25195. * @param duration The duration of the animation, in milliseconds
  25196. * @param onAnimationEnd Callback trigger at the end of the animation
  25197. * @returns Nullable animation
  25198. */
  25199. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25200. /**
  25201. * Return the array of runtime animations currently using this animation
  25202. */
  25203. readonly runtimeAnimations: RuntimeAnimation[];
  25204. /**
  25205. * Specifies if any of the runtime animations are currently running
  25206. */
  25207. readonly hasRunningRuntimeAnimations: boolean;
  25208. /**
  25209. * Initializes the animation
  25210. * @param name Name of the animation
  25211. * @param targetProperty Property to animate
  25212. * @param framePerSecond The frames per second of the animation
  25213. * @param dataType The data type of the animation
  25214. * @param loopMode The loop mode of the animation
  25215. * @param enableBlending Specifies if blending should be enabled
  25216. */
  25217. constructor(
  25218. /**Name of the animation */
  25219. name: string,
  25220. /**Property to animate */
  25221. targetProperty: string,
  25222. /**The frames per second of the animation */
  25223. framePerSecond: number,
  25224. /**The data type of the animation */
  25225. dataType: number,
  25226. /**The loop mode of the animation */
  25227. loopMode?: number | undefined,
  25228. /**Specifies if blending should be enabled */
  25229. enableBlending?: boolean | undefined);
  25230. /**
  25231. * Converts the animation to a string
  25232. * @param fullDetails support for multiple levels of logging within scene loading
  25233. * @returns String form of the animation
  25234. */
  25235. toString(fullDetails?: boolean): string;
  25236. /**
  25237. * Add an event to this animation
  25238. * @param event Event to add
  25239. */
  25240. addEvent(event: AnimationEvent): void;
  25241. /**
  25242. * Remove all events found at the given frame
  25243. * @param frame The frame to remove events from
  25244. */
  25245. removeEvents(frame: number): void;
  25246. /**
  25247. * Retrieves all the events from the animation
  25248. * @returns Events from the animation
  25249. */
  25250. getEvents(): AnimationEvent[];
  25251. /**
  25252. * Creates an animation range
  25253. * @param name Name of the animation range
  25254. * @param from Starting frame of the animation range
  25255. * @param to Ending frame of the animation
  25256. */
  25257. createRange(name: string, from: number, to: number): void;
  25258. /**
  25259. * Deletes an animation range by name
  25260. * @param name Name of the animation range to delete
  25261. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25262. */
  25263. deleteRange(name: string, deleteFrames?: boolean): void;
  25264. /**
  25265. * Gets the animation range by name, or null if not defined
  25266. * @param name Name of the animation range
  25267. * @returns Nullable animation range
  25268. */
  25269. getRange(name: string): Nullable<AnimationRange>;
  25270. /**
  25271. * Gets the key frames from the animation
  25272. * @returns The key frames of the animation
  25273. */
  25274. getKeys(): Array<IAnimationKey>;
  25275. /**
  25276. * Gets the highest frame rate of the animation
  25277. * @returns Highest frame rate of the animation
  25278. */
  25279. getHighestFrame(): number;
  25280. /**
  25281. * Gets the easing function of the animation
  25282. * @returns Easing function of the animation
  25283. */
  25284. getEasingFunction(): IEasingFunction;
  25285. /**
  25286. * Sets the easing function of the animation
  25287. * @param easingFunction A custom mathematical formula for animation
  25288. */
  25289. setEasingFunction(easingFunction: EasingFunction): void;
  25290. /**
  25291. * Interpolates a scalar linearly
  25292. * @param startValue Start value of the animation curve
  25293. * @param endValue End value of the animation curve
  25294. * @param gradient Scalar amount to interpolate
  25295. * @returns Interpolated scalar value
  25296. */
  25297. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25298. /**
  25299. * Interpolates a scalar cubically
  25300. * @param startValue Start value of the animation curve
  25301. * @param outTangent End tangent of the animation
  25302. * @param endValue End value of the animation curve
  25303. * @param inTangent Start tangent of the animation curve
  25304. * @param gradient Scalar amount to interpolate
  25305. * @returns Interpolated scalar value
  25306. */
  25307. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25308. /**
  25309. * Interpolates a quaternion using a spherical linear interpolation
  25310. * @param startValue Start value of the animation curve
  25311. * @param endValue End value of the animation curve
  25312. * @param gradient Scalar amount to interpolate
  25313. * @returns Interpolated quaternion value
  25314. */
  25315. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25316. /**
  25317. * Interpolates a quaternion cubically
  25318. * @param startValue Start value of the animation curve
  25319. * @param outTangent End tangent of the animation curve
  25320. * @param endValue End value of the animation curve
  25321. * @param inTangent Start tangent of the animation curve
  25322. * @param gradient Scalar amount to interpolate
  25323. * @returns Interpolated quaternion value
  25324. */
  25325. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25326. /**
  25327. * Interpolates a Vector3 linearl
  25328. * @param startValue Start value of the animation curve
  25329. * @param endValue End value of the animation curve
  25330. * @param gradient Scalar amount to interpolate
  25331. * @returns Interpolated scalar value
  25332. */
  25333. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25334. /**
  25335. * Interpolates a Vector3 cubically
  25336. * @param startValue Start value of the animation curve
  25337. * @param outTangent End tangent of the animation
  25338. * @param endValue End value of the animation curve
  25339. * @param inTangent Start tangent of the animation curve
  25340. * @param gradient Scalar amount to interpolate
  25341. * @returns InterpolatedVector3 value
  25342. */
  25343. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25344. /**
  25345. * Interpolates a Vector2 linearly
  25346. * @param startValue Start value of the animation curve
  25347. * @param endValue End value of the animation curve
  25348. * @param gradient Scalar amount to interpolate
  25349. * @returns Interpolated Vector2 value
  25350. */
  25351. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25352. /**
  25353. * Interpolates a Vector2 cubically
  25354. * @param startValue Start value of the animation curve
  25355. * @param outTangent End tangent of the animation
  25356. * @param endValue End value of the animation curve
  25357. * @param inTangent Start tangent of the animation curve
  25358. * @param gradient Scalar amount to interpolate
  25359. * @returns Interpolated Vector2 value
  25360. */
  25361. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25362. /**
  25363. * Interpolates a size linearly
  25364. * @param startValue Start value of the animation curve
  25365. * @param endValue End value of the animation curve
  25366. * @param gradient Scalar amount to interpolate
  25367. * @returns Interpolated Size value
  25368. */
  25369. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25370. /**
  25371. * Interpolates a Color3 linearly
  25372. * @param startValue Start value of the animation curve
  25373. * @param endValue End value of the animation curve
  25374. * @param gradient Scalar amount to interpolate
  25375. * @returns Interpolated Color3 value
  25376. */
  25377. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25378. /**
  25379. * @hidden Internal use only
  25380. */
  25381. _getKeyValue(value: any): any;
  25382. /**
  25383. * @hidden Internal use only
  25384. */
  25385. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25386. /**
  25387. * Defines the function to use to interpolate matrices
  25388. * @param startValue defines the start matrix
  25389. * @param endValue defines the end matrix
  25390. * @param gradient defines the gradient between both matrices
  25391. * @param result defines an optional target matrix where to store the interpolation
  25392. * @returns the interpolated matrix
  25393. */
  25394. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25395. /**
  25396. * Makes a copy of the animation
  25397. * @returns Cloned animation
  25398. */
  25399. clone(): Animation;
  25400. /**
  25401. * Sets the key frames of the animation
  25402. * @param values The animation key frames to set
  25403. */
  25404. setKeys(values: Array<IAnimationKey>): void;
  25405. /**
  25406. * Serializes the animation to an object
  25407. * @returns Serialized object
  25408. */
  25409. serialize(): any;
  25410. /**
  25411. * Float animation type
  25412. */
  25413. private static _ANIMATIONTYPE_FLOAT;
  25414. /**
  25415. * Vector3 animation type
  25416. */
  25417. private static _ANIMATIONTYPE_VECTOR3;
  25418. /**
  25419. * Quaternion animation type
  25420. */
  25421. private static _ANIMATIONTYPE_QUATERNION;
  25422. /**
  25423. * Matrix animation type
  25424. */
  25425. private static _ANIMATIONTYPE_MATRIX;
  25426. /**
  25427. * Color3 animation type
  25428. */
  25429. private static _ANIMATIONTYPE_COLOR3;
  25430. /**
  25431. * Vector2 animation type
  25432. */
  25433. private static _ANIMATIONTYPE_VECTOR2;
  25434. /**
  25435. * Size animation type
  25436. */
  25437. private static _ANIMATIONTYPE_SIZE;
  25438. /**
  25439. * Relative Loop Mode
  25440. */
  25441. private static _ANIMATIONLOOPMODE_RELATIVE;
  25442. /**
  25443. * Cycle Loop Mode
  25444. */
  25445. private static _ANIMATIONLOOPMODE_CYCLE;
  25446. /**
  25447. * Constant Loop Mode
  25448. */
  25449. private static _ANIMATIONLOOPMODE_CONSTANT;
  25450. /**
  25451. * Get the float animation type
  25452. */
  25453. static readonly ANIMATIONTYPE_FLOAT: number;
  25454. /**
  25455. * Get the Vector3 animation type
  25456. */
  25457. static readonly ANIMATIONTYPE_VECTOR3: number;
  25458. /**
  25459. * Get the Vector2 animation type
  25460. */
  25461. static readonly ANIMATIONTYPE_VECTOR2: number;
  25462. /**
  25463. * Get the Size animation type
  25464. */
  25465. static readonly ANIMATIONTYPE_SIZE: number;
  25466. /**
  25467. * Get the Quaternion animation type
  25468. */
  25469. static readonly ANIMATIONTYPE_QUATERNION: number;
  25470. /**
  25471. * Get the Matrix animation type
  25472. */
  25473. static readonly ANIMATIONTYPE_MATRIX: number;
  25474. /**
  25475. * Get the Color3 animation type
  25476. */
  25477. static readonly ANIMATIONTYPE_COLOR3: number;
  25478. /**
  25479. * Get the Relative Loop Mode
  25480. */
  25481. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25482. /**
  25483. * Get the Cycle Loop Mode
  25484. */
  25485. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25486. /**
  25487. * Get the Constant Loop Mode
  25488. */
  25489. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25490. /** @hidden */
  25491. static _UniversalLerp(left: any, right: any, amount: number): any;
  25492. /**
  25493. * Parses an animation object and creates an animation
  25494. * @param parsedAnimation Parsed animation object
  25495. * @returns Animation object
  25496. */
  25497. static Parse(parsedAnimation: any): Animation;
  25498. /**
  25499. * Appends the serialized animations from the source animations
  25500. * @param source Source containing the animations
  25501. * @param destination Target to store the animations
  25502. */
  25503. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25504. }
  25505. }
  25506. declare module "babylonjs/Materials/Textures/baseTexture" {
  25507. import { Observable } from "babylonjs/Misc/observable";
  25508. import { IAnimatable } from "babylonjs/Misc/tools";
  25509. import { Nullable } from "babylonjs/types";
  25510. import { Scene } from "babylonjs/scene";
  25511. import { Matrix, ISize } from "babylonjs/Maths/math";
  25512. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25514. /**
  25515. * Base class of all the textures in babylon.
  25516. * It groups all the common properties the materials, post process, lights... might need
  25517. * in order to make a correct use of the texture.
  25518. */
  25519. export class BaseTexture implements IAnimatable {
  25520. /**
  25521. * Default anisotropic filtering level for the application.
  25522. * It is set to 4 as a good tradeoff between perf and quality.
  25523. */
  25524. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25525. /**
  25526. * Gets or sets the unique id of the texture
  25527. */
  25528. uniqueId: number;
  25529. /**
  25530. * Define the name of the texture.
  25531. */
  25532. name: string;
  25533. /**
  25534. * Gets or sets an object used to store user defined information.
  25535. */
  25536. metadata: any;
  25537. /**
  25538. * For internal use only. Please do not use.
  25539. */
  25540. reservedDataStore: any;
  25541. private _hasAlpha;
  25542. /**
  25543. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25544. */
  25545. hasAlpha: boolean;
  25546. /**
  25547. * Defines if the alpha value should be determined via the rgb values.
  25548. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25549. */
  25550. getAlphaFromRGB: boolean;
  25551. /**
  25552. * Intensity or strength of the texture.
  25553. * It is commonly used by materials to fine tune the intensity of the texture
  25554. */
  25555. level: number;
  25556. /**
  25557. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25558. * This is part of the texture as textures usually maps to one uv set.
  25559. */
  25560. coordinatesIndex: number;
  25561. private _coordinatesMode;
  25562. /**
  25563. * How a texture is mapped.
  25564. *
  25565. * | Value | Type | Description |
  25566. * | ----- | ----------------------------------- | ----------- |
  25567. * | 0 | EXPLICIT_MODE | |
  25568. * | 1 | SPHERICAL_MODE | |
  25569. * | 2 | PLANAR_MODE | |
  25570. * | 3 | CUBIC_MODE | |
  25571. * | 4 | PROJECTION_MODE | |
  25572. * | 5 | SKYBOX_MODE | |
  25573. * | 6 | INVCUBIC_MODE | |
  25574. * | 7 | EQUIRECTANGULAR_MODE | |
  25575. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25576. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25577. */
  25578. coordinatesMode: number;
  25579. /**
  25580. * | Value | Type | Description |
  25581. * | ----- | ------------------ | ----------- |
  25582. * | 0 | CLAMP_ADDRESSMODE | |
  25583. * | 1 | WRAP_ADDRESSMODE | |
  25584. * | 2 | MIRROR_ADDRESSMODE | |
  25585. */
  25586. wrapU: number;
  25587. /**
  25588. * | Value | Type | Description |
  25589. * | ----- | ------------------ | ----------- |
  25590. * | 0 | CLAMP_ADDRESSMODE | |
  25591. * | 1 | WRAP_ADDRESSMODE | |
  25592. * | 2 | MIRROR_ADDRESSMODE | |
  25593. */
  25594. wrapV: number;
  25595. /**
  25596. * | Value | Type | Description |
  25597. * | ----- | ------------------ | ----------- |
  25598. * | 0 | CLAMP_ADDRESSMODE | |
  25599. * | 1 | WRAP_ADDRESSMODE | |
  25600. * | 2 | MIRROR_ADDRESSMODE | |
  25601. */
  25602. wrapR: number;
  25603. /**
  25604. * With compliant hardware and browser (supporting anisotropic filtering)
  25605. * this defines the level of anisotropic filtering in the texture.
  25606. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25607. */
  25608. anisotropicFilteringLevel: number;
  25609. /**
  25610. * Define if the texture is a cube texture or if false a 2d texture.
  25611. */
  25612. isCube: boolean;
  25613. /**
  25614. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25615. */
  25616. is3D: boolean;
  25617. /**
  25618. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25619. * HDR texture are usually stored in linear space.
  25620. * This only impacts the PBR and Background materials
  25621. */
  25622. gammaSpace: boolean;
  25623. /**
  25624. * Gets whether or not the texture contains RGBD data.
  25625. */
  25626. readonly isRGBD: boolean;
  25627. /**
  25628. * Is Z inverted in the texture (useful in a cube texture).
  25629. */
  25630. invertZ: boolean;
  25631. /**
  25632. * Are mip maps generated for this texture or not.
  25633. */
  25634. readonly noMipmap: boolean;
  25635. /**
  25636. * @hidden
  25637. */
  25638. lodLevelInAlpha: boolean;
  25639. /**
  25640. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25641. */
  25642. lodGenerationOffset: number;
  25643. /**
  25644. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25645. */
  25646. lodGenerationScale: number;
  25647. /**
  25648. * Define if the texture is a render target.
  25649. */
  25650. isRenderTarget: boolean;
  25651. /**
  25652. * Define the unique id of the texture in the scene.
  25653. */
  25654. readonly uid: string;
  25655. /**
  25656. * Return a string representation of the texture.
  25657. * @returns the texture as a string
  25658. */
  25659. toString(): string;
  25660. /**
  25661. * Get the class name of the texture.
  25662. * @returns "BaseTexture"
  25663. */
  25664. getClassName(): string;
  25665. /**
  25666. * Define the list of animation attached to the texture.
  25667. */
  25668. animations: import("babylonjs/Animations/animation").Animation[];
  25669. /**
  25670. * An event triggered when the texture is disposed.
  25671. */
  25672. onDisposeObservable: Observable<BaseTexture>;
  25673. private _onDisposeObserver;
  25674. /**
  25675. * Callback triggered when the texture has been disposed.
  25676. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25677. */
  25678. onDispose: () => void;
  25679. /**
  25680. * Define the current state of the loading sequence when in delayed load mode.
  25681. */
  25682. delayLoadState: number;
  25683. private _scene;
  25684. /** @hidden */
  25685. _texture: Nullable<InternalTexture>;
  25686. private _uid;
  25687. /**
  25688. * Define if the texture is preventinga material to render or not.
  25689. * If not and the texture is not ready, the engine will use a default black texture instead.
  25690. */
  25691. readonly isBlocking: boolean;
  25692. /**
  25693. * Instantiates a new BaseTexture.
  25694. * Base class of all the textures in babylon.
  25695. * It groups all the common properties the materials, post process, lights... might need
  25696. * in order to make a correct use of the texture.
  25697. * @param scene Define the scene the texture blongs to
  25698. */
  25699. constructor(scene: Nullable<Scene>);
  25700. /**
  25701. * Get the scene the texture belongs to.
  25702. * @returns the scene or null if undefined
  25703. */
  25704. getScene(): Nullable<Scene>;
  25705. /**
  25706. * Get the texture transform matrix used to offset tile the texture for istance.
  25707. * @returns the transformation matrix
  25708. */
  25709. getTextureMatrix(): Matrix;
  25710. /**
  25711. * Get the texture reflection matrix used to rotate/transform the reflection.
  25712. * @returns the reflection matrix
  25713. */
  25714. getReflectionTextureMatrix(): Matrix;
  25715. /**
  25716. * Get the underlying lower level texture from Babylon.
  25717. * @returns the insternal texture
  25718. */
  25719. getInternalTexture(): Nullable<InternalTexture>;
  25720. /**
  25721. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25722. * @returns true if ready or not blocking
  25723. */
  25724. isReadyOrNotBlocking(): boolean;
  25725. /**
  25726. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25727. * @returns true if fully ready
  25728. */
  25729. isReady(): boolean;
  25730. private _cachedSize;
  25731. /**
  25732. * Get the size of the texture.
  25733. * @returns the texture size.
  25734. */
  25735. getSize(): ISize;
  25736. /**
  25737. * Get the base size of the texture.
  25738. * It can be different from the size if the texture has been resized for POT for instance
  25739. * @returns the base size
  25740. */
  25741. getBaseSize(): ISize;
  25742. /**
  25743. * Update the sampling mode of the texture.
  25744. * Default is Trilinear mode.
  25745. *
  25746. * | Value | Type | Description |
  25747. * | ----- | ------------------ | ----------- |
  25748. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25749. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25750. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25751. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25752. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25753. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25754. * | 7 | NEAREST_LINEAR | |
  25755. * | 8 | NEAREST_NEAREST | |
  25756. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25757. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25758. * | 11 | LINEAR_LINEAR | |
  25759. * | 12 | LINEAR_NEAREST | |
  25760. *
  25761. * > _mag_: magnification filter (close to the viewer)
  25762. * > _min_: minification filter (far from the viewer)
  25763. * > _mip_: filter used between mip map levels
  25764. *@param samplingMode Define the new sampling mode of the texture
  25765. */
  25766. updateSamplingMode(samplingMode: number): void;
  25767. /**
  25768. * Scales the texture if is `canRescale()`
  25769. * @param ratio the resize factor we want to use to rescale
  25770. */
  25771. scale(ratio: number): void;
  25772. /**
  25773. * Get if the texture can rescale.
  25774. */
  25775. readonly canRescale: boolean;
  25776. /** @hidden */
  25777. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25778. /** @hidden */
  25779. _rebuild(): void;
  25780. /**
  25781. * Triggers the load sequence in delayed load mode.
  25782. */
  25783. delayLoad(): void;
  25784. /**
  25785. * Clones the texture.
  25786. * @returns the cloned texture
  25787. */
  25788. clone(): Nullable<BaseTexture>;
  25789. /**
  25790. * Get the texture underlying type (INT, FLOAT...)
  25791. */
  25792. readonly textureType: number;
  25793. /**
  25794. * Get the texture underlying format (RGB, RGBA...)
  25795. */
  25796. readonly textureFormat: number;
  25797. /**
  25798. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25799. * This will returns an RGBA array buffer containing either in values (0-255) or
  25800. * float values (0-1) depending of the underlying buffer type.
  25801. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25802. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25803. * @param buffer defines a user defined buffer to fill with data (can be null)
  25804. * @returns The Array buffer containing the pixels data.
  25805. */
  25806. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25807. /**
  25808. * Release and destroy the underlying lower level texture aka internalTexture.
  25809. */
  25810. releaseInternalTexture(): void;
  25811. /**
  25812. * Get the polynomial representation of the texture data.
  25813. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25814. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25815. */
  25816. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25817. /** @hidden */
  25818. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25819. /** @hidden */
  25820. readonly _lodTextureMid: Nullable<BaseTexture>;
  25821. /** @hidden */
  25822. readonly _lodTextureLow: Nullable<BaseTexture>;
  25823. /**
  25824. * Dispose the texture and release its associated resources.
  25825. */
  25826. dispose(): void;
  25827. /**
  25828. * Serialize the texture into a JSON representation that can be parsed later on.
  25829. * @returns the JSON representation of the texture
  25830. */
  25831. serialize(): any;
  25832. /**
  25833. * Helper function to be called back once a list of texture contains only ready textures.
  25834. * @param textures Define the list of textures to wait for
  25835. * @param callback Define the callback triggered once the entire list will be ready
  25836. */
  25837. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25838. }
  25839. }
  25840. declare module "babylonjs/Materials/uniformBuffer" {
  25841. import { Nullable, FloatArray } from "babylonjs/types";
  25842. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25843. import { Engine } from "babylonjs/Engines/engine";
  25844. import { Effect } from "babylonjs/Materials/effect";
  25845. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25846. /**
  25847. * Uniform buffer objects.
  25848. *
  25849. * Handles blocks of uniform on the GPU.
  25850. *
  25851. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25852. *
  25853. * For more information, please refer to :
  25854. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25855. */
  25856. export class UniformBuffer {
  25857. private _engine;
  25858. private _buffer;
  25859. private _data;
  25860. private _bufferData;
  25861. private _dynamic?;
  25862. private _uniformLocations;
  25863. private _uniformSizes;
  25864. private _uniformLocationPointer;
  25865. private _needSync;
  25866. private _noUBO;
  25867. private _currentEffect;
  25868. private static _MAX_UNIFORM_SIZE;
  25869. private static _tempBuffer;
  25870. /**
  25871. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25872. * This is dynamic to allow compat with webgl 1 and 2.
  25873. * You will need to pass the name of the uniform as well as the value.
  25874. */
  25875. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25876. /**
  25877. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25878. * This is dynamic to allow compat with webgl 1 and 2.
  25879. * You will need to pass the name of the uniform as well as the value.
  25880. */
  25881. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25882. /**
  25883. * Lambda to Update a single float in a uniform buffer.
  25884. * This is dynamic to allow compat with webgl 1 and 2.
  25885. * You will need to pass the name of the uniform as well as the value.
  25886. */
  25887. updateFloat: (name: string, x: number) => void;
  25888. /**
  25889. * Lambda to Update a vec2 of float in a uniform buffer.
  25890. * This is dynamic to allow compat with webgl 1 and 2.
  25891. * You will need to pass the name of the uniform as well as the value.
  25892. */
  25893. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25894. /**
  25895. * Lambda to Update a vec3 of float in a uniform buffer.
  25896. * This is dynamic to allow compat with webgl 1 and 2.
  25897. * You will need to pass the name of the uniform as well as the value.
  25898. */
  25899. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25900. /**
  25901. * Lambda to Update a vec4 of float in a uniform buffer.
  25902. * This is dynamic to allow compat with webgl 1 and 2.
  25903. * You will need to pass the name of the uniform as well as the value.
  25904. */
  25905. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25906. /**
  25907. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25908. * This is dynamic to allow compat with webgl 1 and 2.
  25909. * You will need to pass the name of the uniform as well as the value.
  25910. */
  25911. updateMatrix: (name: string, mat: Matrix) => void;
  25912. /**
  25913. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25914. * This is dynamic to allow compat with webgl 1 and 2.
  25915. * You will need to pass the name of the uniform as well as the value.
  25916. */
  25917. updateVector3: (name: string, vector: Vector3) => void;
  25918. /**
  25919. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25920. * This is dynamic to allow compat with webgl 1 and 2.
  25921. * You will need to pass the name of the uniform as well as the value.
  25922. */
  25923. updateVector4: (name: string, vector: Vector4) => void;
  25924. /**
  25925. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25926. * This is dynamic to allow compat with webgl 1 and 2.
  25927. * You will need to pass the name of the uniform as well as the value.
  25928. */
  25929. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25930. /**
  25931. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25932. * This is dynamic to allow compat with webgl 1 and 2.
  25933. * You will need to pass the name of the uniform as well as the value.
  25934. */
  25935. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25936. /**
  25937. * Instantiates a new Uniform buffer objects.
  25938. *
  25939. * Handles blocks of uniform on the GPU.
  25940. *
  25941. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25942. *
  25943. * For more information, please refer to :
  25944. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25945. * @param engine Define the engine the buffer is associated with
  25946. * @param data Define the data contained in the buffer
  25947. * @param dynamic Define if the buffer is updatable
  25948. */
  25949. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25950. /**
  25951. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25952. * or just falling back on setUniformXXX calls.
  25953. */
  25954. readonly useUbo: boolean;
  25955. /**
  25956. * Indicates if the WebGL underlying uniform buffer is in sync
  25957. * with the javascript cache data.
  25958. */
  25959. readonly isSync: boolean;
  25960. /**
  25961. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25962. * Also, a dynamic UniformBuffer will disable cache verification and always
  25963. * update the underlying WebGL uniform buffer to the GPU.
  25964. * @returns if Dynamic, otherwise false
  25965. */
  25966. isDynamic(): boolean;
  25967. /**
  25968. * The data cache on JS side.
  25969. * @returns the underlying data as a float array
  25970. */
  25971. getData(): Float32Array;
  25972. /**
  25973. * The underlying WebGL Uniform buffer.
  25974. * @returns the webgl buffer
  25975. */
  25976. getBuffer(): Nullable<WebGLBuffer>;
  25977. /**
  25978. * std140 layout specifies how to align data within an UBO structure.
  25979. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25980. * for specs.
  25981. */
  25982. private _fillAlignment;
  25983. /**
  25984. * Adds an uniform in the buffer.
  25985. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25986. * for the layout to be correct !
  25987. * @param name Name of the uniform, as used in the uniform block in the shader.
  25988. * @param size Data size, or data directly.
  25989. */
  25990. addUniform(name: string, size: number | number[]): void;
  25991. /**
  25992. * Adds a Matrix 4x4 to the uniform buffer.
  25993. * @param name Name of the uniform, as used in the uniform block in the shader.
  25994. * @param mat A 4x4 matrix.
  25995. */
  25996. addMatrix(name: string, mat: Matrix): void;
  25997. /**
  25998. * Adds a vec2 to the uniform buffer.
  25999. * @param name Name of the uniform, as used in the uniform block in the shader.
  26000. * @param x Define the x component value of the vec2
  26001. * @param y Define the y component value of the vec2
  26002. */
  26003. addFloat2(name: string, x: number, y: number): void;
  26004. /**
  26005. * Adds a vec3 to the uniform buffer.
  26006. * @param name Name of the uniform, as used in the uniform block in the shader.
  26007. * @param x Define the x component value of the vec3
  26008. * @param y Define the y component value of the vec3
  26009. * @param z Define the z component value of the vec3
  26010. */
  26011. addFloat3(name: string, x: number, y: number, z: number): void;
  26012. /**
  26013. * Adds a vec3 to the uniform buffer.
  26014. * @param name Name of the uniform, as used in the uniform block in the shader.
  26015. * @param color Define the vec3 from a Color
  26016. */
  26017. addColor3(name: string, color: Color3): void;
  26018. /**
  26019. * Adds a vec4 to the uniform buffer.
  26020. * @param name Name of the uniform, as used in the uniform block in the shader.
  26021. * @param color Define the rgb components from a Color
  26022. * @param alpha Define the a component of the vec4
  26023. */
  26024. addColor4(name: string, color: Color3, alpha: number): void;
  26025. /**
  26026. * Adds a vec3 to the uniform buffer.
  26027. * @param name Name of the uniform, as used in the uniform block in the shader.
  26028. * @param vector Define the vec3 components from a Vector
  26029. */
  26030. addVector3(name: string, vector: Vector3): void;
  26031. /**
  26032. * Adds a Matrix 3x3 to the uniform buffer.
  26033. * @param name Name of the uniform, as used in the uniform block in the shader.
  26034. */
  26035. addMatrix3x3(name: string): void;
  26036. /**
  26037. * Adds a Matrix 2x2 to the uniform buffer.
  26038. * @param name Name of the uniform, as used in the uniform block in the shader.
  26039. */
  26040. addMatrix2x2(name: string): void;
  26041. /**
  26042. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26043. */
  26044. create(): void;
  26045. /** @hidden */
  26046. _rebuild(): void;
  26047. /**
  26048. * Updates the WebGL Uniform Buffer on the GPU.
  26049. * If the `dynamic` flag is set to true, no cache comparison is done.
  26050. * Otherwise, the buffer will be updated only if the cache differs.
  26051. */
  26052. update(): void;
  26053. /**
  26054. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26055. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26056. * @param data Define the flattened data
  26057. * @param size Define the size of the data.
  26058. */
  26059. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26060. private _updateMatrix3x3ForUniform;
  26061. private _updateMatrix3x3ForEffect;
  26062. private _updateMatrix2x2ForEffect;
  26063. private _updateMatrix2x2ForUniform;
  26064. private _updateFloatForEffect;
  26065. private _updateFloatForUniform;
  26066. private _updateFloat2ForEffect;
  26067. private _updateFloat2ForUniform;
  26068. private _updateFloat3ForEffect;
  26069. private _updateFloat3ForUniform;
  26070. private _updateFloat4ForEffect;
  26071. private _updateFloat4ForUniform;
  26072. private _updateMatrixForEffect;
  26073. private _updateMatrixForUniform;
  26074. private _updateVector3ForEffect;
  26075. private _updateVector3ForUniform;
  26076. private _updateVector4ForEffect;
  26077. private _updateVector4ForUniform;
  26078. private _updateColor3ForEffect;
  26079. private _updateColor3ForUniform;
  26080. private _updateColor4ForEffect;
  26081. private _updateColor4ForUniform;
  26082. /**
  26083. * Sets a sampler uniform on the effect.
  26084. * @param name Define the name of the sampler.
  26085. * @param texture Define the texture to set in the sampler
  26086. */
  26087. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26088. /**
  26089. * Directly updates the value of the uniform in the cache AND on the GPU.
  26090. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26091. * @param data Define the flattened data
  26092. */
  26093. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26094. /**
  26095. * Binds this uniform buffer to an effect.
  26096. * @param effect Define the effect to bind the buffer to
  26097. * @param name Name of the uniform block in the shader.
  26098. */
  26099. bindToEffect(effect: Effect, name: string): void;
  26100. /**
  26101. * Disposes the uniform buffer.
  26102. */
  26103. dispose(): void;
  26104. }
  26105. }
  26106. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26107. import { Nullable } from "babylonjs/types";
  26108. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26109. /**
  26110. * This represents the required contract to create a new type of texture loader.
  26111. */
  26112. export interface IInternalTextureLoader {
  26113. /**
  26114. * Defines wether the loader supports cascade loading the different faces.
  26115. */
  26116. supportCascades: boolean;
  26117. /**
  26118. * This returns if the loader support the current file information.
  26119. * @param extension defines the file extension of the file being loaded
  26120. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26121. * @param fallback defines the fallback internal texture if any
  26122. * @param isBase64 defines whether the texture is encoded as a base64
  26123. * @param isBuffer defines whether the texture data are stored as a buffer
  26124. * @returns true if the loader can load the specified file
  26125. */
  26126. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26127. /**
  26128. * Transform the url before loading if required.
  26129. * @param rootUrl the url of the texture
  26130. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26131. * @returns the transformed texture
  26132. */
  26133. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26134. /**
  26135. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26136. * @param rootUrl the url of the texture
  26137. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26138. * @returns the fallback texture
  26139. */
  26140. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26141. /**
  26142. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26143. * @param data contains the texture data
  26144. * @param texture defines the BabylonJS internal texture
  26145. * @param createPolynomials will be true if polynomials have been requested
  26146. * @param onLoad defines the callback to trigger once the texture is ready
  26147. * @param onError defines the callback to trigger in case of error
  26148. */
  26149. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26150. /**
  26151. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26152. * @param data contains the texture data
  26153. * @param texture defines the BabylonJS internal texture
  26154. * @param callback defines the method to call once ready to upload
  26155. */
  26156. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26157. }
  26158. }
  26159. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26160. import { Scene } from "babylonjs/scene";
  26161. import { Engine } from "babylonjs/Engines/engine";
  26162. import { Texture } from "babylonjs/Materials/Textures/texture";
  26163. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26164. /**
  26165. * Creation options of the multi render target texture.
  26166. */
  26167. export interface IMultiRenderTargetOptions {
  26168. /**
  26169. * Define if the texture needs to create mip maps after render.
  26170. */
  26171. generateMipMaps?: boolean;
  26172. /**
  26173. * Define the types of all the draw buffers we want to create
  26174. */
  26175. types?: number[];
  26176. /**
  26177. * Define the sampling modes of all the draw buffers we want to create
  26178. */
  26179. samplingModes?: number[];
  26180. /**
  26181. * Define if a depth buffer is required
  26182. */
  26183. generateDepthBuffer?: boolean;
  26184. /**
  26185. * Define if a stencil buffer is required
  26186. */
  26187. generateStencilBuffer?: boolean;
  26188. /**
  26189. * Define if a depth texture is required instead of a depth buffer
  26190. */
  26191. generateDepthTexture?: boolean;
  26192. /**
  26193. * Define the number of desired draw buffers
  26194. */
  26195. textureCount?: number;
  26196. /**
  26197. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26198. */
  26199. doNotChangeAspectRatio?: boolean;
  26200. /**
  26201. * Define the default type of the buffers we are creating
  26202. */
  26203. defaultType?: number;
  26204. }
  26205. /**
  26206. * A multi render target, like a render target provides the ability to render to a texture.
  26207. * Unlike the render target, it can render to several draw buffers in one draw.
  26208. * This is specially interesting in deferred rendering or for any effects requiring more than
  26209. * just one color from a single pass.
  26210. */
  26211. export class MultiRenderTarget extends RenderTargetTexture {
  26212. private _internalTextures;
  26213. private _textures;
  26214. private _multiRenderTargetOptions;
  26215. /**
  26216. * Get if draw buffers are currently supported by the used hardware and browser.
  26217. */
  26218. readonly isSupported: boolean;
  26219. /**
  26220. * Get the list of textures generated by the multi render target.
  26221. */
  26222. readonly textures: Texture[];
  26223. /**
  26224. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26225. */
  26226. readonly depthTexture: Texture;
  26227. /**
  26228. * Set the wrapping mode on U of all the textures we are rendering to.
  26229. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26230. */
  26231. wrapU: number;
  26232. /**
  26233. * Set the wrapping mode on V of all the textures we are rendering to.
  26234. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26235. */
  26236. wrapV: number;
  26237. /**
  26238. * Instantiate a new multi render target texture.
  26239. * A multi render target, like a render target provides the ability to render to a texture.
  26240. * Unlike the render target, it can render to several draw buffers in one draw.
  26241. * This is specially interesting in deferred rendering or for any effects requiring more than
  26242. * just one color from a single pass.
  26243. * @param name Define the name of the texture
  26244. * @param size Define the size of the buffers to render to
  26245. * @param count Define the number of target we are rendering into
  26246. * @param scene Define the scene the texture belongs to
  26247. * @param options Define the options used to create the multi render target
  26248. */
  26249. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26250. /** @hidden */
  26251. _rebuild(): void;
  26252. private _createInternalTextures;
  26253. private _createTextures;
  26254. /**
  26255. * Define the number of samples used if MSAA is enabled.
  26256. */
  26257. samples: number;
  26258. /**
  26259. * Resize all the textures in the multi render target.
  26260. * Be carrefull as it will recreate all the data in the new texture.
  26261. * @param size Define the new size
  26262. */
  26263. resize(size: any): void;
  26264. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26265. /**
  26266. * Dispose the render targets and their associated resources
  26267. */
  26268. dispose(): void;
  26269. /**
  26270. * Release all the underlying texture used as draw buffers.
  26271. */
  26272. releaseInternalTextures(): void;
  26273. }
  26274. }
  26275. declare module "babylonjs/Audio/analyser" {
  26276. import { Scene } from "babylonjs/scene";
  26277. /**
  26278. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26280. */
  26281. export class Analyser {
  26282. /**
  26283. * Gets or sets the smoothing
  26284. * @ignorenaming
  26285. */
  26286. SMOOTHING: number;
  26287. /**
  26288. * Gets or sets the FFT table size
  26289. * @ignorenaming
  26290. */
  26291. FFT_SIZE: number;
  26292. /**
  26293. * Gets or sets the bar graph amplitude
  26294. * @ignorenaming
  26295. */
  26296. BARGRAPHAMPLITUDE: number;
  26297. /**
  26298. * Gets or sets the position of the debug canvas
  26299. * @ignorenaming
  26300. */
  26301. DEBUGCANVASPOS: {
  26302. x: number;
  26303. y: number;
  26304. };
  26305. /**
  26306. * Gets or sets the debug canvas size
  26307. * @ignorenaming
  26308. */
  26309. DEBUGCANVASSIZE: {
  26310. width: number;
  26311. height: number;
  26312. };
  26313. private _byteFreqs;
  26314. private _byteTime;
  26315. private _floatFreqs;
  26316. private _webAudioAnalyser;
  26317. private _debugCanvas;
  26318. private _debugCanvasContext;
  26319. private _scene;
  26320. private _registerFunc;
  26321. private _audioEngine;
  26322. /**
  26323. * Creates a new analyser
  26324. * @param scene defines hosting scene
  26325. */
  26326. constructor(scene: Scene);
  26327. /**
  26328. * Get the number of data values you will have to play with for the visualization
  26329. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26330. * @returns a number
  26331. */
  26332. getFrequencyBinCount(): number;
  26333. /**
  26334. * Gets the current frequency data as a byte array
  26335. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26336. * @returns a Uint8Array
  26337. */
  26338. getByteFrequencyData(): Uint8Array;
  26339. /**
  26340. * Gets the current waveform as a byte array
  26341. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26342. * @returns a Uint8Array
  26343. */
  26344. getByteTimeDomainData(): Uint8Array;
  26345. /**
  26346. * Gets the current frequency data as a float array
  26347. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26348. * @returns a Float32Array
  26349. */
  26350. getFloatFrequencyData(): Float32Array;
  26351. /**
  26352. * Renders the debug canvas
  26353. */
  26354. drawDebugCanvas(): void;
  26355. /**
  26356. * Stops rendering the debug canvas and removes it
  26357. */
  26358. stopDebugCanvas(): void;
  26359. /**
  26360. * Connects two audio nodes
  26361. * @param inputAudioNode defines first node to connect
  26362. * @param outputAudioNode defines second node to connect
  26363. */
  26364. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26365. /**
  26366. * Releases all associated resources
  26367. */
  26368. dispose(): void;
  26369. }
  26370. }
  26371. declare module "babylonjs/Audio/audioEngine" {
  26372. import { IDisposable } from "babylonjs/scene";
  26373. import { Analyser } from "babylonjs/Audio/analyser";
  26374. import { Nullable } from "babylonjs/types";
  26375. import { Observable } from "babylonjs/Misc/observable";
  26376. /**
  26377. * This represents an audio engine and it is responsible
  26378. * to play, synchronize and analyse sounds throughout the application.
  26379. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26380. */
  26381. export interface IAudioEngine extends IDisposable {
  26382. /**
  26383. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26384. */
  26385. readonly canUseWebAudio: boolean;
  26386. /**
  26387. * Gets the current AudioContext if available.
  26388. */
  26389. readonly audioContext: Nullable<AudioContext>;
  26390. /**
  26391. * The master gain node defines the global audio volume of your audio engine.
  26392. */
  26393. readonly masterGain: GainNode;
  26394. /**
  26395. * Gets whether or not mp3 are supported by your browser.
  26396. */
  26397. readonly isMP3supported: boolean;
  26398. /**
  26399. * Gets whether or not ogg are supported by your browser.
  26400. */
  26401. readonly isOGGsupported: boolean;
  26402. /**
  26403. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26404. * @ignoreNaming
  26405. */
  26406. WarnedWebAudioUnsupported: boolean;
  26407. /**
  26408. * Defines if the audio engine relies on a custom unlocked button.
  26409. * In this case, the embedded button will not be displayed.
  26410. */
  26411. useCustomUnlockedButton: boolean;
  26412. /**
  26413. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26414. */
  26415. readonly unlocked: boolean;
  26416. /**
  26417. * Event raised when audio has been unlocked on the browser.
  26418. */
  26419. onAudioUnlockedObservable: Observable<AudioEngine>;
  26420. /**
  26421. * Event raised when audio has been locked on the browser.
  26422. */
  26423. onAudioLockedObservable: Observable<AudioEngine>;
  26424. /**
  26425. * Flags the audio engine in Locked state.
  26426. * This happens due to new browser policies preventing audio to autoplay.
  26427. */
  26428. lock(): void;
  26429. /**
  26430. * Unlocks the audio engine once a user action has been done on the dom.
  26431. * This is helpful to resume play once browser policies have been satisfied.
  26432. */
  26433. unlock(): void;
  26434. }
  26435. /**
  26436. * This represents the default audio engine used in babylon.
  26437. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26439. */
  26440. export class AudioEngine implements IAudioEngine {
  26441. private _audioContext;
  26442. private _audioContextInitialized;
  26443. private _muteButton;
  26444. private _hostElement;
  26445. /**
  26446. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26447. */
  26448. canUseWebAudio: boolean;
  26449. /**
  26450. * The master gain node defines the global audio volume of your audio engine.
  26451. */
  26452. masterGain: GainNode;
  26453. /**
  26454. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26455. * @ignoreNaming
  26456. */
  26457. WarnedWebAudioUnsupported: boolean;
  26458. /**
  26459. * Gets whether or not mp3 are supported by your browser.
  26460. */
  26461. isMP3supported: boolean;
  26462. /**
  26463. * Gets whether or not ogg are supported by your browser.
  26464. */
  26465. isOGGsupported: boolean;
  26466. /**
  26467. * Gets whether audio has been unlocked on the device.
  26468. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26469. * a user interaction has happened.
  26470. */
  26471. unlocked: boolean;
  26472. /**
  26473. * Defines if the audio engine relies on a custom unlocked button.
  26474. * In this case, the embedded button will not be displayed.
  26475. */
  26476. useCustomUnlockedButton: boolean;
  26477. /**
  26478. * Event raised when audio has been unlocked on the browser.
  26479. */
  26480. onAudioUnlockedObservable: Observable<AudioEngine>;
  26481. /**
  26482. * Event raised when audio has been locked on the browser.
  26483. */
  26484. onAudioLockedObservable: Observable<AudioEngine>;
  26485. /**
  26486. * Gets the current AudioContext if available.
  26487. */
  26488. readonly audioContext: Nullable<AudioContext>;
  26489. private _connectedAnalyser;
  26490. /**
  26491. * Instantiates a new audio engine.
  26492. *
  26493. * There should be only one per page as some browsers restrict the number
  26494. * of audio contexts you can create.
  26495. * @param hostElement defines the host element where to display the mute icon if necessary
  26496. */
  26497. constructor(hostElement?: Nullable<HTMLElement>);
  26498. /**
  26499. * Flags the audio engine in Locked state.
  26500. * This happens due to new browser policies preventing audio to autoplay.
  26501. */
  26502. lock(): void;
  26503. /**
  26504. * Unlocks the audio engine once a user action has been done on the dom.
  26505. * This is helpful to resume play once browser policies have been satisfied.
  26506. */
  26507. unlock(): void;
  26508. private _resumeAudioContext;
  26509. private _initializeAudioContext;
  26510. private _tryToRun;
  26511. private _triggerRunningState;
  26512. private _triggerSuspendedState;
  26513. private _displayMuteButton;
  26514. private _moveButtonToTopLeft;
  26515. private _onResize;
  26516. private _hideMuteButton;
  26517. /**
  26518. * Destroy and release the resources associated with the audio ccontext.
  26519. */
  26520. dispose(): void;
  26521. /**
  26522. * Gets the global volume sets on the master gain.
  26523. * @returns the global volume if set or -1 otherwise
  26524. */
  26525. getGlobalVolume(): number;
  26526. /**
  26527. * Sets the global volume of your experience (sets on the master gain).
  26528. * @param newVolume Defines the new global volume of the application
  26529. */
  26530. setGlobalVolume(newVolume: number): void;
  26531. /**
  26532. * Connect the audio engine to an audio analyser allowing some amazing
  26533. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26535. * @param analyser The analyser to connect to the engine
  26536. */
  26537. connectToAnalyser(analyser: Analyser): void;
  26538. }
  26539. }
  26540. declare module "babylonjs/Loading/loadingScreen" {
  26541. /**
  26542. * Interface used to present a loading screen while loading a scene
  26543. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26544. */
  26545. export interface ILoadingScreen {
  26546. /**
  26547. * Function called to display the loading screen
  26548. */
  26549. displayLoadingUI: () => void;
  26550. /**
  26551. * Function called to hide the loading screen
  26552. */
  26553. hideLoadingUI: () => void;
  26554. /**
  26555. * Gets or sets the color to use for the background
  26556. */
  26557. loadingUIBackgroundColor: string;
  26558. /**
  26559. * Gets or sets the text to display while loading
  26560. */
  26561. loadingUIText: string;
  26562. }
  26563. /**
  26564. * Class used for the default loading screen
  26565. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26566. */
  26567. export class DefaultLoadingScreen implements ILoadingScreen {
  26568. private _renderingCanvas;
  26569. private _loadingText;
  26570. private _loadingDivBackgroundColor;
  26571. private _loadingDiv;
  26572. private _loadingTextDiv;
  26573. /**
  26574. * Creates a new default loading screen
  26575. * @param _renderingCanvas defines the canvas used to render the scene
  26576. * @param _loadingText defines the default text to display
  26577. * @param _loadingDivBackgroundColor defines the default background color
  26578. */
  26579. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26580. /**
  26581. * Function called to display the loading screen
  26582. */
  26583. displayLoadingUI(): void;
  26584. /**
  26585. * Function called to hide the loading screen
  26586. */
  26587. hideLoadingUI(): void;
  26588. /**
  26589. * Gets or sets the text to display while loading
  26590. */
  26591. loadingUIText: string;
  26592. /**
  26593. * Gets or sets the color to use for the background
  26594. */
  26595. loadingUIBackgroundColor: string;
  26596. private _resizeLoadingUI;
  26597. }
  26598. }
  26599. declare module "babylonjs/Materials/Textures/videoTexture" {
  26600. import { Observable } from "babylonjs/Misc/observable";
  26601. import { Nullable } from "babylonjs/types";
  26602. import { Scene } from "babylonjs/scene";
  26603. import { Texture } from "babylonjs/Materials/Textures/texture";
  26604. /**
  26605. * Settings for finer control over video usage
  26606. */
  26607. export interface VideoTextureSettings {
  26608. /**
  26609. * Applies `autoplay` to video, if specified
  26610. */
  26611. autoPlay?: boolean;
  26612. /**
  26613. * Applies `loop` to video, if specified
  26614. */
  26615. loop?: boolean;
  26616. /**
  26617. * Automatically updates internal texture from video at every frame in the render loop
  26618. */
  26619. autoUpdateTexture: boolean;
  26620. /**
  26621. * Image src displayed during the video loading or until the user interacts with the video.
  26622. */
  26623. poster?: string;
  26624. }
  26625. /**
  26626. * If you want to display a video in your scene, this is the special texture for that.
  26627. * This special texture works similar to other textures, with the exception of a few parameters.
  26628. * @see https://doc.babylonjs.com/how_to/video_texture
  26629. */
  26630. export class VideoTexture extends Texture {
  26631. /**
  26632. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26633. */
  26634. readonly autoUpdateTexture: boolean;
  26635. /**
  26636. * The video instance used by the texture internally
  26637. */
  26638. readonly video: HTMLVideoElement;
  26639. private _onUserActionRequestedObservable;
  26640. /**
  26641. * Event triggerd when a dom action is required by the user to play the video.
  26642. * This happens due to recent changes in browser policies preventing video to auto start.
  26643. */
  26644. readonly onUserActionRequestedObservable: Observable<Texture>;
  26645. private _generateMipMaps;
  26646. private _engine;
  26647. private _stillImageCaptured;
  26648. private _displayingPosterTexture;
  26649. private _settings;
  26650. private _createInternalTextureOnEvent;
  26651. /**
  26652. * Creates a video texture.
  26653. * If you want to display a video in your scene, this is the special texture for that.
  26654. * This special texture works similar to other textures, with the exception of a few parameters.
  26655. * @see https://doc.babylonjs.com/how_to/video_texture
  26656. * @param name optional name, will detect from video source, if not defined
  26657. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26658. * @param scene is obviously the current scene.
  26659. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26660. * @param invertY is false by default but can be used to invert video on Y axis
  26661. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26662. * @param settings allows finer control over video usage
  26663. */
  26664. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26665. private _getName;
  26666. private _getVideo;
  26667. private _createInternalTexture;
  26668. private reset;
  26669. /**
  26670. * @hidden Internal method to initiate `update`.
  26671. */
  26672. _rebuild(): void;
  26673. /**
  26674. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26675. */
  26676. update(): void;
  26677. /**
  26678. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26679. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26680. */
  26681. updateTexture(isVisible: boolean): void;
  26682. protected _updateInternalTexture: () => void;
  26683. /**
  26684. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26685. * @param url New url.
  26686. */
  26687. updateURL(url: string): void;
  26688. /**
  26689. * Dispose the texture and release its associated resources.
  26690. */
  26691. dispose(): void;
  26692. /**
  26693. * Creates a video texture straight from a stream.
  26694. * @param scene Define the scene the texture should be created in
  26695. * @param stream Define the stream the texture should be created from
  26696. * @returns The created video texture as a promise
  26697. */
  26698. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26699. /**
  26700. * Creates a video texture straight from your WebCam video feed.
  26701. * @param scene Define the scene the texture should be created in
  26702. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26703. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26704. * @returns The created video texture as a promise
  26705. */
  26706. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26707. minWidth: number;
  26708. maxWidth: number;
  26709. minHeight: number;
  26710. maxHeight: number;
  26711. deviceId: string;
  26712. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26713. /**
  26714. * Creates a video texture straight from your WebCam video feed.
  26715. * @param scene Define the scene the texture should be created in
  26716. * @param onReady Define a callback to triggered once the texture will be ready
  26717. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26718. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26719. */
  26720. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26721. minWidth: number;
  26722. maxWidth: number;
  26723. minHeight: number;
  26724. maxHeight: number;
  26725. deviceId: string;
  26726. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26727. }
  26728. }
  26729. declare module "babylonjs/Engines/engine" {
  26730. import { Observable } from "babylonjs/Misc/observable";
  26731. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26732. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26733. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26734. import { Camera } from "babylonjs/Cameras/camera";
  26735. import { Scene } from "babylonjs/scene";
  26736. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26737. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26738. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26739. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26740. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26741. import { Material } from "babylonjs/Materials/material";
  26742. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26743. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26745. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26746. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26747. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26748. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26749. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26750. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26751. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26752. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26753. /**
  26754. * Interface for attribute information associated with buffer instanciation
  26755. */
  26756. export class InstancingAttributeInfo {
  26757. /**
  26758. * Index/offset of the attribute in the vertex shader
  26759. */
  26760. index: number;
  26761. /**
  26762. * size of the attribute, 1, 2, 3 or 4
  26763. */
  26764. attributeSize: number;
  26765. /**
  26766. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26767. * default is FLOAT
  26768. */
  26769. attribyteType: number;
  26770. /**
  26771. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26772. */
  26773. normalized: boolean;
  26774. /**
  26775. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26776. */
  26777. offset: number;
  26778. /**
  26779. * Name of the GLSL attribute, for debugging purpose only
  26780. */
  26781. attributeName: string;
  26782. }
  26783. /**
  26784. * Define options used to create a depth texture
  26785. */
  26786. export class DepthTextureCreationOptions {
  26787. /** Specifies whether or not a stencil should be allocated in the texture */
  26788. generateStencil?: boolean;
  26789. /** Specifies whether or not bilinear filtering is enable on the texture */
  26790. bilinearFiltering?: boolean;
  26791. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26792. comparisonFunction?: number;
  26793. /** Specifies if the created texture is a cube texture */
  26794. isCube?: boolean;
  26795. }
  26796. /**
  26797. * Class used to describe the capabilities of the engine relatively to the current browser
  26798. */
  26799. export class EngineCapabilities {
  26800. /** Maximum textures units per fragment shader */
  26801. maxTexturesImageUnits: number;
  26802. /** Maximum texture units per vertex shader */
  26803. maxVertexTextureImageUnits: number;
  26804. /** Maximum textures units in the entire pipeline */
  26805. maxCombinedTexturesImageUnits: number;
  26806. /** Maximum texture size */
  26807. maxTextureSize: number;
  26808. /** Maximum cube texture size */
  26809. maxCubemapTextureSize: number;
  26810. /** Maximum render texture size */
  26811. maxRenderTextureSize: number;
  26812. /** Maximum number of vertex attributes */
  26813. maxVertexAttribs: number;
  26814. /** Maximum number of varyings */
  26815. maxVaryingVectors: number;
  26816. /** Maximum number of uniforms per vertex shader */
  26817. maxVertexUniformVectors: number;
  26818. /** Maximum number of uniforms per fragment shader */
  26819. maxFragmentUniformVectors: number;
  26820. /** Defines if standard derivates (dx/dy) are supported */
  26821. standardDerivatives: boolean;
  26822. /** Defines if s3tc texture compression is supported */
  26823. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26824. /** Defines if pvrtc texture compression is supported */
  26825. pvrtc: any;
  26826. /** Defines if etc1 texture compression is supported */
  26827. etc1: any;
  26828. /** Defines if etc2 texture compression is supported */
  26829. etc2: any;
  26830. /** Defines if astc texture compression is supported */
  26831. astc: any;
  26832. /** Defines if float textures are supported */
  26833. textureFloat: boolean;
  26834. /** Defines if vertex array objects are supported */
  26835. vertexArrayObject: boolean;
  26836. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26837. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26838. /** Gets the maximum level of anisotropy supported */
  26839. maxAnisotropy: number;
  26840. /** Defines if instancing is supported */
  26841. instancedArrays: boolean;
  26842. /** Defines if 32 bits indices are supported */
  26843. uintIndices: boolean;
  26844. /** Defines if high precision shaders are supported */
  26845. highPrecisionShaderSupported: boolean;
  26846. /** Defines if depth reading in the fragment shader is supported */
  26847. fragmentDepthSupported: boolean;
  26848. /** Defines if float texture linear filtering is supported*/
  26849. textureFloatLinearFiltering: boolean;
  26850. /** Defines if rendering to float textures is supported */
  26851. textureFloatRender: boolean;
  26852. /** Defines if half float textures are supported*/
  26853. textureHalfFloat: boolean;
  26854. /** Defines if half float texture linear filtering is supported*/
  26855. textureHalfFloatLinearFiltering: boolean;
  26856. /** Defines if rendering to half float textures is supported */
  26857. textureHalfFloatRender: boolean;
  26858. /** Defines if textureLOD shader command is supported */
  26859. textureLOD: boolean;
  26860. /** Defines if draw buffers extension is supported */
  26861. drawBuffersExtension: boolean;
  26862. /** Defines if depth textures are supported */
  26863. depthTextureExtension: boolean;
  26864. /** Defines if float color buffer are supported */
  26865. colorBufferFloat: boolean;
  26866. /** Gets disjoint timer query extension (null if not supported) */
  26867. timerQuery: EXT_disjoint_timer_query;
  26868. /** Defines if timestamp can be used with timer query */
  26869. canUseTimestampForTimerQuery: boolean;
  26870. /** Function used to let the system compiles shaders in background */
  26871. parallelShaderCompile: {
  26872. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26873. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26874. COMPLETION_STATUS_KHR: number;
  26875. };
  26876. }
  26877. /** Interface defining initialization parameters for Engine class */
  26878. export interface EngineOptions extends WebGLContextAttributes {
  26879. /**
  26880. * Defines if the engine should no exceed a specified device ratio
  26881. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26882. */
  26883. limitDeviceRatio?: number;
  26884. /**
  26885. * Defines if webvr should be enabled automatically
  26886. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26887. */
  26888. autoEnableWebVR?: boolean;
  26889. /**
  26890. * Defines if webgl2 should be turned off even if supported
  26891. * @see http://doc.babylonjs.com/features/webgl2
  26892. */
  26893. disableWebGL2Support?: boolean;
  26894. /**
  26895. * Defines if webaudio should be initialized as well
  26896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26897. */
  26898. audioEngine?: boolean;
  26899. /**
  26900. * Defines if animations should run using a deterministic lock step
  26901. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26902. */
  26903. deterministicLockstep?: boolean;
  26904. /** Defines the maximum steps to use with deterministic lock step mode */
  26905. lockstepMaxSteps?: number;
  26906. /**
  26907. * Defines that engine should ignore context lost events
  26908. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26909. */
  26910. doNotHandleContextLost?: boolean;
  26911. /**
  26912. * Defines that engine should ignore modifying touch action attribute and style
  26913. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26914. */
  26915. doNotHandleTouchAction?: boolean;
  26916. }
  26917. /**
  26918. * Defines the interface used by display changed events
  26919. */
  26920. export interface IDisplayChangedEventArgs {
  26921. /** Gets the vrDisplay object (if any) */
  26922. vrDisplay: Nullable<any>;
  26923. /** Gets a boolean indicating if webVR is supported */
  26924. vrSupported: boolean;
  26925. }
  26926. /**
  26927. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26928. */
  26929. export class Engine {
  26930. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26931. static ExceptionList: ({
  26932. key: string;
  26933. capture: string;
  26934. captureConstraint: number;
  26935. targets: string[];
  26936. } | {
  26937. key: string;
  26938. capture: null;
  26939. captureConstraint: null;
  26940. targets: string[];
  26941. })[];
  26942. /** Gets the list of created engines */
  26943. static readonly Instances: Engine[];
  26944. /**
  26945. * Gets the latest created engine
  26946. */
  26947. static readonly LastCreatedEngine: Nullable<Engine>;
  26948. /**
  26949. * Gets the latest created scene
  26950. */
  26951. static readonly LastCreatedScene: Nullable<Scene>;
  26952. /**
  26953. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26954. * @param flag defines which part of the materials must be marked as dirty
  26955. * @param predicate defines a predicate used to filter which materials should be affected
  26956. */
  26957. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26958. /**
  26959. * Hidden
  26960. */
  26961. static _TextureLoaders: IInternalTextureLoader[];
  26962. /** Defines that alpha blending is disabled */
  26963. static readonly ALPHA_DISABLE: number;
  26964. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26965. static readonly ALPHA_ADD: number;
  26966. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26967. static readonly ALPHA_COMBINE: number;
  26968. /** Defines that alpha blending to DEST - SRC * DEST */
  26969. static readonly ALPHA_SUBTRACT: number;
  26970. /** Defines that alpha blending to SRC * DEST */
  26971. static readonly ALPHA_MULTIPLY: number;
  26972. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26973. static readonly ALPHA_MAXIMIZED: number;
  26974. /** Defines that alpha blending to SRC + DEST */
  26975. static readonly ALPHA_ONEONE: number;
  26976. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26977. static readonly ALPHA_PREMULTIPLIED: number;
  26978. /**
  26979. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26980. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26981. */
  26982. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26983. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26984. static readonly ALPHA_INTERPOLATE: number;
  26985. /**
  26986. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26987. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26988. */
  26989. static readonly ALPHA_SCREENMODE: number;
  26990. /** Defines that the ressource is not delayed*/
  26991. static readonly DELAYLOADSTATE_NONE: number;
  26992. /** Defines that the ressource was successfully delay loaded */
  26993. static readonly DELAYLOADSTATE_LOADED: number;
  26994. /** Defines that the ressource is currently delay loading */
  26995. static readonly DELAYLOADSTATE_LOADING: number;
  26996. /** Defines that the ressource is delayed and has not started loading */
  26997. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26998. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26999. static readonly NEVER: number;
  27000. /** 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 */
  27001. static readonly ALWAYS: number;
  27002. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27003. static readonly LESS: number;
  27004. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27005. static readonly EQUAL: number;
  27006. /** 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 */
  27007. static readonly LEQUAL: number;
  27008. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27009. static readonly GREATER: number;
  27010. /** 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 */
  27011. static readonly GEQUAL: number;
  27012. /** 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 */
  27013. static readonly NOTEQUAL: number;
  27014. /** Passed to stencilOperation to specify that stencil value must be kept */
  27015. static readonly KEEP: number;
  27016. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27017. static readonly REPLACE: number;
  27018. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27019. static readonly INCR: number;
  27020. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27021. static readonly DECR: number;
  27022. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27023. static readonly INVERT: number;
  27024. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27025. static readonly INCR_WRAP: number;
  27026. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27027. static readonly DECR_WRAP: number;
  27028. /** Texture is not repeating outside of 0..1 UVs */
  27029. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27030. /** Texture is repeating outside of 0..1 UVs */
  27031. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27032. /** Texture is repeating and mirrored */
  27033. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27034. /** ALPHA */
  27035. static readonly TEXTUREFORMAT_ALPHA: number;
  27036. /** LUMINANCE */
  27037. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27038. /** LUMINANCE_ALPHA */
  27039. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27040. /** RGB */
  27041. static readonly TEXTUREFORMAT_RGB: number;
  27042. /** RGBA */
  27043. static readonly TEXTUREFORMAT_RGBA: number;
  27044. /** RED */
  27045. static readonly TEXTUREFORMAT_RED: number;
  27046. /** RED (2nd reference) */
  27047. static readonly TEXTUREFORMAT_R: number;
  27048. /** RG */
  27049. static readonly TEXTUREFORMAT_RG: number;
  27050. /** RED_INTEGER */
  27051. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27052. /** RED_INTEGER (2nd reference) */
  27053. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27054. /** RG_INTEGER */
  27055. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27056. /** RGB_INTEGER */
  27057. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27058. /** RGBA_INTEGER */
  27059. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27060. /** UNSIGNED_BYTE */
  27061. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27062. /** UNSIGNED_BYTE (2nd reference) */
  27063. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27064. /** FLOAT */
  27065. static readonly TEXTURETYPE_FLOAT: number;
  27066. /** HALF_FLOAT */
  27067. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27068. /** BYTE */
  27069. static readonly TEXTURETYPE_BYTE: number;
  27070. /** SHORT */
  27071. static readonly TEXTURETYPE_SHORT: number;
  27072. /** UNSIGNED_SHORT */
  27073. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27074. /** INT */
  27075. static readonly TEXTURETYPE_INT: number;
  27076. /** UNSIGNED_INT */
  27077. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27078. /** UNSIGNED_SHORT_4_4_4_4 */
  27079. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27080. /** UNSIGNED_SHORT_5_5_5_1 */
  27081. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27082. /** UNSIGNED_SHORT_5_6_5 */
  27083. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27084. /** UNSIGNED_INT_2_10_10_10_REV */
  27085. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27086. /** UNSIGNED_INT_24_8 */
  27087. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27088. /** UNSIGNED_INT_10F_11F_11F_REV */
  27089. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27090. /** UNSIGNED_INT_5_9_9_9_REV */
  27091. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27092. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27093. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27094. /** nearest is mag = nearest and min = nearest and mip = linear */
  27095. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27096. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27097. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27098. /** Trilinear is mag = linear and min = linear and mip = linear */
  27099. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27100. /** nearest is mag = nearest and min = nearest and mip = linear */
  27101. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27102. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27103. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27104. /** Trilinear is mag = linear and min = linear and mip = linear */
  27105. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27106. /** mag = nearest and min = nearest and mip = nearest */
  27107. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27108. /** mag = nearest and min = linear and mip = nearest */
  27109. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27110. /** mag = nearest and min = linear and mip = linear */
  27111. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27112. /** mag = nearest and min = linear and mip = none */
  27113. static readonly TEXTURE_NEAREST_LINEAR: number;
  27114. /** mag = nearest and min = nearest and mip = none */
  27115. static readonly TEXTURE_NEAREST_NEAREST: number;
  27116. /** mag = linear and min = nearest and mip = nearest */
  27117. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27118. /** mag = linear and min = nearest and mip = linear */
  27119. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27120. /** mag = linear and min = linear and mip = none */
  27121. static readonly TEXTURE_LINEAR_LINEAR: number;
  27122. /** mag = linear and min = nearest and mip = none */
  27123. static readonly TEXTURE_LINEAR_NEAREST: number;
  27124. /** Explicit coordinates mode */
  27125. static readonly TEXTURE_EXPLICIT_MODE: number;
  27126. /** Spherical coordinates mode */
  27127. static readonly TEXTURE_SPHERICAL_MODE: number;
  27128. /** Planar coordinates mode */
  27129. static readonly TEXTURE_PLANAR_MODE: number;
  27130. /** Cubic coordinates mode */
  27131. static readonly TEXTURE_CUBIC_MODE: number;
  27132. /** Projection coordinates mode */
  27133. static readonly TEXTURE_PROJECTION_MODE: number;
  27134. /** Skybox coordinates mode */
  27135. static readonly TEXTURE_SKYBOX_MODE: number;
  27136. /** Inverse Cubic coordinates mode */
  27137. static readonly TEXTURE_INVCUBIC_MODE: number;
  27138. /** Equirectangular coordinates mode */
  27139. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27140. /** Equirectangular Fixed coordinates mode */
  27141. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27142. /** Equirectangular Fixed Mirrored coordinates mode */
  27143. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27144. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27145. static readonly SCALEMODE_FLOOR: number;
  27146. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27147. static readonly SCALEMODE_NEAREST: number;
  27148. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27149. static readonly SCALEMODE_CEILING: number;
  27150. /**
  27151. * Returns the current version of the framework
  27152. */
  27153. static readonly Version: string;
  27154. /**
  27155. * Returns a string describing the current engine
  27156. */
  27157. readonly description: string;
  27158. /**
  27159. * Gets or sets the epsilon value used by collision engine
  27160. */
  27161. static CollisionsEpsilon: number;
  27162. /**
  27163. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27164. */
  27165. static ShadersRepository: string;
  27166. /**
  27167. * Method called to create the default loading screen.
  27168. * This can be overriden in your own app.
  27169. * @param canvas The rendering canvas element
  27170. * @returns The loading screen
  27171. */
  27172. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27173. /**
  27174. * Method called to create the default rescale post process on each engine.
  27175. */
  27176. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27177. /**
  27178. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27179. */
  27180. forcePOTTextures: boolean;
  27181. /**
  27182. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27183. */
  27184. isFullscreen: boolean;
  27185. /**
  27186. * Gets a boolean indicating if the pointer is currently locked
  27187. */
  27188. isPointerLock: boolean;
  27189. /**
  27190. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27191. */
  27192. cullBackFaces: boolean;
  27193. /**
  27194. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27195. */
  27196. renderEvenInBackground: boolean;
  27197. /**
  27198. * Gets or sets a boolean indicating that cache can be kept between frames
  27199. */
  27200. preventCacheWipeBetweenFrames: boolean;
  27201. /**
  27202. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27203. **/
  27204. enableOfflineSupport: boolean;
  27205. /**
  27206. * 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)
  27207. **/
  27208. disableManifestCheck: boolean;
  27209. /**
  27210. * Gets the list of created scenes
  27211. */
  27212. scenes: Scene[];
  27213. /**
  27214. * Event raised when a new scene is created
  27215. */
  27216. onNewSceneAddedObservable: Observable<Scene>;
  27217. /**
  27218. * Gets the list of created postprocesses
  27219. */
  27220. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27221. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27222. validateShaderPrograms: boolean;
  27223. /**
  27224. * Observable event triggered each time the rendering canvas is resized
  27225. */
  27226. onResizeObservable: Observable<Engine>;
  27227. /**
  27228. * Observable event triggered each time the canvas loses focus
  27229. */
  27230. onCanvasBlurObservable: Observable<Engine>;
  27231. /**
  27232. * Observable event triggered each time the canvas gains focus
  27233. */
  27234. onCanvasFocusObservable: Observable<Engine>;
  27235. /**
  27236. * Observable event triggered each time the canvas receives pointerout event
  27237. */
  27238. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27239. /**
  27240. * Observable event triggered before each texture is initialized
  27241. */
  27242. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27243. private _vrDisplay;
  27244. private _vrSupported;
  27245. private _oldSize;
  27246. private _oldHardwareScaleFactor;
  27247. private _vrExclusivePointerMode;
  27248. private _webVRInitPromise;
  27249. /**
  27250. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27251. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27252. */
  27253. readonly isInVRExclusivePointerMode: boolean;
  27254. /**
  27255. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27256. */
  27257. disableUniformBuffers: boolean;
  27258. /** @hidden */
  27259. _uniformBuffers: UniformBuffer[];
  27260. /**
  27261. * Gets a boolean indicating that the engine supports uniform buffers
  27262. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27263. */
  27264. readonly supportsUniformBuffers: boolean;
  27265. /**
  27266. * Observable raised when the engine begins a new frame
  27267. */
  27268. onBeginFrameObservable: Observable<Engine>;
  27269. /**
  27270. * If set, will be used to request the next animation frame for the render loop
  27271. */
  27272. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27273. /**
  27274. * Observable raised when the engine ends the current frame
  27275. */
  27276. onEndFrameObservable: Observable<Engine>;
  27277. /**
  27278. * Observable raised when the engine is about to compile a shader
  27279. */
  27280. onBeforeShaderCompilationObservable: Observable<Engine>;
  27281. /**
  27282. * Observable raised when the engine has jsut compiled a shader
  27283. */
  27284. onAfterShaderCompilationObservable: Observable<Engine>;
  27285. /** @hidden */
  27286. _gl: WebGLRenderingContext;
  27287. private _renderingCanvas;
  27288. private _windowIsBackground;
  27289. private _webGLVersion;
  27290. /**
  27291. * Gets a boolean indicating that only power of 2 textures are supported
  27292. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27293. */
  27294. readonly needPOTTextures: boolean;
  27295. /** @hidden */
  27296. _badOS: boolean;
  27297. /** @hidden */
  27298. _badDesktopOS: boolean;
  27299. /**
  27300. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27301. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27302. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27303. */
  27304. disableTextureBindingOptimization: boolean;
  27305. /**
  27306. * Gets the audio engine
  27307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27308. * @ignorenaming
  27309. */
  27310. static audioEngine: IAudioEngine;
  27311. /**
  27312. * Default AudioEngine factory responsible of creating the Audio Engine.
  27313. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27314. */
  27315. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27316. /**
  27317. * Default offline support factory responsible of creating a tool used to store data locally.
  27318. * By default, this will create a Database object if the workload has been embedded.
  27319. */
  27320. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27321. private _onFocus;
  27322. private _onBlur;
  27323. private _onCanvasPointerOut;
  27324. private _onCanvasBlur;
  27325. private _onCanvasFocus;
  27326. private _onFullscreenChange;
  27327. private _onPointerLockChange;
  27328. private _onVRDisplayPointerRestricted;
  27329. private _onVRDisplayPointerUnrestricted;
  27330. private _onVrDisplayConnect;
  27331. private _onVrDisplayDisconnect;
  27332. private _onVrDisplayPresentChange;
  27333. /**
  27334. * Observable signaled when VR display mode changes
  27335. */
  27336. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27337. /**
  27338. * Observable signaled when VR request present is complete
  27339. */
  27340. onVRRequestPresentComplete: Observable<boolean>;
  27341. /**
  27342. * Observable signaled when VR request present starts
  27343. */
  27344. onVRRequestPresentStart: Observable<Engine>;
  27345. private _hardwareScalingLevel;
  27346. /** @hidden */
  27347. protected _caps: EngineCapabilities;
  27348. private _pointerLockRequested;
  27349. private _isStencilEnable;
  27350. private _colorWrite;
  27351. private _loadingScreen;
  27352. /** @hidden */
  27353. _drawCalls: PerfCounter;
  27354. /** @hidden */
  27355. _textureCollisions: PerfCounter;
  27356. private _glVersion;
  27357. private _glRenderer;
  27358. private _glVendor;
  27359. private _videoTextureSupported;
  27360. private _renderingQueueLaunched;
  27361. private _activeRenderLoops;
  27362. private _deterministicLockstep;
  27363. private _lockstepMaxSteps;
  27364. /**
  27365. * Observable signaled when a context lost event is raised
  27366. */
  27367. onContextLostObservable: Observable<Engine>;
  27368. /**
  27369. * Observable signaled when a context restored event is raised
  27370. */
  27371. onContextRestoredObservable: Observable<Engine>;
  27372. private _onContextLost;
  27373. private _onContextRestored;
  27374. private _contextWasLost;
  27375. private _doNotHandleContextLost;
  27376. /**
  27377. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27378. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27379. */
  27380. doNotHandleContextLost: boolean;
  27381. private _performanceMonitor;
  27382. private _fps;
  27383. private _deltaTime;
  27384. /**
  27385. * Turn this value on if you want to pause FPS computation when in background
  27386. */
  27387. disablePerformanceMonitorInBackground: boolean;
  27388. /**
  27389. * Gets the performance monitor attached to this engine
  27390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27391. */
  27392. readonly performanceMonitor: PerformanceMonitor;
  27393. /** @hidden */
  27394. protected _depthCullingState: _DepthCullingState;
  27395. /** @hidden */
  27396. protected _stencilState: _StencilState;
  27397. /** @hidden */
  27398. protected _alphaState: _AlphaState;
  27399. /** @hidden */
  27400. protected _alphaMode: number;
  27401. protected _internalTexturesCache: InternalTexture[];
  27402. /** @hidden */
  27403. protected _activeChannel: number;
  27404. private _currentTextureChannel;
  27405. /** @hidden */
  27406. protected _boundTexturesCache: {
  27407. [key: string]: Nullable<InternalTexture>;
  27408. };
  27409. /** @hidden */
  27410. protected _currentEffect: Nullable<Effect>;
  27411. /** @hidden */
  27412. protected _currentProgram: Nullable<WebGLProgram>;
  27413. private _compiledEffects;
  27414. private _vertexAttribArraysEnabled;
  27415. /** @hidden */
  27416. protected _cachedViewport: Nullable<Viewport>;
  27417. private _cachedVertexArrayObject;
  27418. /** @hidden */
  27419. protected _cachedVertexBuffers: any;
  27420. /** @hidden */
  27421. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27422. /** @hidden */
  27423. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27424. /** @hidden */
  27425. protected _currentRenderTarget: Nullable<InternalTexture>;
  27426. private _uintIndicesCurrentlySet;
  27427. private _currentBoundBuffer;
  27428. /** @hidden */
  27429. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27430. private _currentBufferPointers;
  27431. private _currentInstanceLocations;
  27432. private _currentInstanceBuffers;
  27433. private _textureUnits;
  27434. private _firstBoundInternalTextureTracker;
  27435. private _lastBoundInternalTextureTracker;
  27436. private _workingCanvas;
  27437. private _workingContext;
  27438. private _rescalePostProcess;
  27439. private _dummyFramebuffer;
  27440. private _externalData;
  27441. private _bindedRenderFunction;
  27442. private _vaoRecordInProgress;
  27443. private _mustWipeVertexAttributes;
  27444. private _emptyTexture;
  27445. private _emptyCubeTexture;
  27446. private _emptyTexture3D;
  27447. /** @hidden */
  27448. _frameHandler: number;
  27449. private _nextFreeTextureSlots;
  27450. private _maxSimultaneousTextures;
  27451. private _activeRequests;
  27452. private _texturesSupported;
  27453. private _textureFormatInUse;
  27454. /**
  27455. * Gets the list of texture formats supported
  27456. */
  27457. readonly texturesSupported: Array<string>;
  27458. /**
  27459. * Gets the list of texture formats in use
  27460. */
  27461. readonly textureFormatInUse: Nullable<string>;
  27462. /**
  27463. * Gets the current viewport
  27464. */
  27465. readonly currentViewport: Nullable<Viewport>;
  27466. /**
  27467. * Gets the default empty texture
  27468. */
  27469. readonly emptyTexture: InternalTexture;
  27470. /**
  27471. * Gets the default empty 3D texture
  27472. */
  27473. readonly emptyTexture3D: InternalTexture;
  27474. /**
  27475. * Gets the default empty cube texture
  27476. */
  27477. readonly emptyCubeTexture: InternalTexture;
  27478. /**
  27479. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27480. */
  27481. readonly premultipliedAlpha: boolean;
  27482. /**
  27483. * Creates a new engine
  27484. * @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
  27485. * @param antialias defines enable antialiasing (default: false)
  27486. * @param options defines further options to be sent to the getContext() function
  27487. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27488. */
  27489. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27490. private _disableTouchAction;
  27491. private _rebuildInternalTextures;
  27492. private _rebuildEffects;
  27493. /**
  27494. * Gets a boolean indicating if all created effects are ready
  27495. * @returns true if all effects are ready
  27496. */
  27497. areAllEffectsReady(): boolean;
  27498. private _rebuildBuffers;
  27499. private _initGLContext;
  27500. /**
  27501. * Gets version of the current webGL context
  27502. */
  27503. readonly webGLVersion: number;
  27504. /**
  27505. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27506. */
  27507. readonly isStencilEnable: boolean;
  27508. private _prepareWorkingCanvas;
  27509. /**
  27510. * Reset the texture cache to empty state
  27511. */
  27512. resetTextureCache(): void;
  27513. /**
  27514. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27515. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27516. * @returns true if engine is in deterministic lock step mode
  27517. */
  27518. isDeterministicLockStep(): boolean;
  27519. /**
  27520. * Gets the max steps when engine is running in deterministic lock step
  27521. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27522. * @returns the max steps
  27523. */
  27524. getLockstepMaxSteps(): number;
  27525. /**
  27526. * Gets an object containing information about the current webGL context
  27527. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27528. */
  27529. getGlInfo(): {
  27530. vendor: string;
  27531. renderer: string;
  27532. version: string;
  27533. };
  27534. /**
  27535. * Gets current aspect ratio
  27536. * @param camera defines the camera to use to get the aspect ratio
  27537. * @param useScreen defines if screen size must be used (or the current render target if any)
  27538. * @returns a number defining the aspect ratio
  27539. */
  27540. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27541. /**
  27542. * Gets current screen aspect ratio
  27543. * @returns a number defining the aspect ratio
  27544. */
  27545. getScreenAspectRatio(): number;
  27546. /**
  27547. * Gets the current render width
  27548. * @param useScreen defines if screen size must be used (or the current render target if any)
  27549. * @returns a number defining the current render width
  27550. */
  27551. getRenderWidth(useScreen?: boolean): number;
  27552. /**
  27553. * Gets the current render height
  27554. * @param useScreen defines if screen size must be used (or the current render target if any)
  27555. * @returns a number defining the current render height
  27556. */
  27557. getRenderHeight(useScreen?: boolean): number;
  27558. /**
  27559. * Gets the HTML canvas attached with the current webGL context
  27560. * @returns a HTML canvas
  27561. */
  27562. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27563. /**
  27564. * Gets the client rect of the HTML canvas attached with the current webGL context
  27565. * @returns a client rectanglee
  27566. */
  27567. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27568. /**
  27569. * Defines the hardware scaling level.
  27570. * By default the hardware scaling level is computed from the window device ratio.
  27571. * 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.
  27572. * @param level defines the level to use
  27573. */
  27574. setHardwareScalingLevel(level: number): void;
  27575. /**
  27576. * Gets the current hardware scaling level.
  27577. * By default the hardware scaling level is computed from the window device ratio.
  27578. * 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.
  27579. * @returns a number indicating the current hardware scaling level
  27580. */
  27581. getHardwareScalingLevel(): number;
  27582. /**
  27583. * Gets the list of loaded textures
  27584. * @returns an array containing all loaded textures
  27585. */
  27586. getLoadedTexturesCache(): InternalTexture[];
  27587. /**
  27588. * Gets the object containing all engine capabilities
  27589. * @returns the EngineCapabilities object
  27590. */
  27591. getCaps(): EngineCapabilities;
  27592. /**
  27593. * Gets the current depth function
  27594. * @returns a number defining the depth function
  27595. */
  27596. getDepthFunction(): Nullable<number>;
  27597. /**
  27598. * Sets the current depth function
  27599. * @param depthFunc defines the function to use
  27600. */
  27601. setDepthFunction(depthFunc: number): void;
  27602. /**
  27603. * Sets the current depth function to GREATER
  27604. */
  27605. setDepthFunctionToGreater(): void;
  27606. /**
  27607. * Sets the current depth function to GEQUAL
  27608. */
  27609. setDepthFunctionToGreaterOrEqual(): void;
  27610. /**
  27611. * Sets the current depth function to LESS
  27612. */
  27613. setDepthFunctionToLess(): void;
  27614. /**
  27615. * Sets the current depth function to LEQUAL
  27616. */
  27617. setDepthFunctionToLessOrEqual(): void;
  27618. /**
  27619. * Gets a boolean indicating if stencil buffer is enabled
  27620. * @returns the current stencil buffer state
  27621. */
  27622. getStencilBuffer(): boolean;
  27623. /**
  27624. * Enable or disable the stencil buffer
  27625. * @param enable defines if the stencil buffer must be enabled or disabled
  27626. */
  27627. setStencilBuffer(enable: boolean): void;
  27628. /**
  27629. * Gets the current stencil mask
  27630. * @returns a number defining the new stencil mask to use
  27631. */
  27632. getStencilMask(): number;
  27633. /**
  27634. * Sets the current stencil mask
  27635. * @param mask defines the new stencil mask to use
  27636. */
  27637. setStencilMask(mask: number): void;
  27638. /**
  27639. * Gets the current stencil function
  27640. * @returns a number defining the stencil function to use
  27641. */
  27642. getStencilFunction(): number;
  27643. /**
  27644. * Gets the current stencil reference value
  27645. * @returns a number defining the stencil reference value to use
  27646. */
  27647. getStencilFunctionReference(): number;
  27648. /**
  27649. * Gets the current stencil mask
  27650. * @returns a number defining the stencil mask to use
  27651. */
  27652. getStencilFunctionMask(): number;
  27653. /**
  27654. * Sets the current stencil function
  27655. * @param stencilFunc defines the new stencil function to use
  27656. */
  27657. setStencilFunction(stencilFunc: number): void;
  27658. /**
  27659. * Sets the current stencil reference
  27660. * @param reference defines the new stencil reference to use
  27661. */
  27662. setStencilFunctionReference(reference: number): void;
  27663. /**
  27664. * Sets the current stencil mask
  27665. * @param mask defines the new stencil mask to use
  27666. */
  27667. setStencilFunctionMask(mask: number): void;
  27668. /**
  27669. * Gets the current stencil operation when stencil fails
  27670. * @returns a number defining stencil operation to use when stencil fails
  27671. */
  27672. getStencilOperationFail(): number;
  27673. /**
  27674. * Gets the current stencil operation when depth fails
  27675. * @returns a number defining stencil operation to use when depth fails
  27676. */
  27677. getStencilOperationDepthFail(): number;
  27678. /**
  27679. * Gets the current stencil operation when stencil passes
  27680. * @returns a number defining stencil operation to use when stencil passes
  27681. */
  27682. getStencilOperationPass(): number;
  27683. /**
  27684. * Sets the stencil operation to use when stencil fails
  27685. * @param operation defines the stencil operation to use when stencil fails
  27686. */
  27687. setStencilOperationFail(operation: number): void;
  27688. /**
  27689. * Sets the stencil operation to use when depth fails
  27690. * @param operation defines the stencil operation to use when depth fails
  27691. */
  27692. setStencilOperationDepthFail(operation: number): void;
  27693. /**
  27694. * Sets the stencil operation to use when stencil passes
  27695. * @param operation defines the stencil operation to use when stencil passes
  27696. */
  27697. setStencilOperationPass(operation: number): void;
  27698. /**
  27699. * Sets a boolean indicating if the dithering state is enabled or disabled
  27700. * @param value defines the dithering state
  27701. */
  27702. setDitheringState(value: boolean): void;
  27703. /**
  27704. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27705. * @param value defines the rasterizer state
  27706. */
  27707. setRasterizerState(value: boolean): void;
  27708. /**
  27709. * stop executing a render loop function and remove it from the execution array
  27710. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27711. */
  27712. stopRenderLoop(renderFunction?: () => void): void;
  27713. /** @hidden */
  27714. _renderLoop(): void;
  27715. /**
  27716. * Register and execute a render loop. The engine can have more than one render function
  27717. * @param renderFunction defines the function to continuously execute
  27718. */
  27719. runRenderLoop(renderFunction: () => void): void;
  27720. /**
  27721. * Toggle full screen mode
  27722. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27723. */
  27724. switchFullscreen(requestPointerLock: boolean): void;
  27725. /**
  27726. * Enters full screen mode
  27727. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27728. */
  27729. enterFullscreen(requestPointerLock: boolean): void;
  27730. /**
  27731. * Exits full screen mode
  27732. */
  27733. exitFullscreen(): void;
  27734. /**
  27735. * Clear the current render buffer or the current render target (if any is set up)
  27736. * @param color defines the color to use
  27737. * @param backBuffer defines if the back buffer must be cleared
  27738. * @param depth defines if the depth buffer must be cleared
  27739. * @param stencil defines if the stencil buffer must be cleared
  27740. */
  27741. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27742. /**
  27743. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27744. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27745. * @param y defines the y-coordinate of the corner of the clear rectangle
  27746. * @param width defines the width of the clear rectangle
  27747. * @param height defines the height of the clear rectangle
  27748. * @param clearColor defines the clear color
  27749. */
  27750. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27751. /**
  27752. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27753. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27754. * @param y defines the y-coordinate of the corner of the clear rectangle
  27755. * @param width defines the width of the clear rectangle
  27756. * @param height defines the height of the clear rectangle
  27757. */
  27758. enableScissor(x: number, y: number, width: number, height: number): void;
  27759. /**
  27760. * Disable previously set scissor test rectangle
  27761. */
  27762. disableScissor(): void;
  27763. private _viewportCached;
  27764. /** @hidden */
  27765. _viewport(x: number, y: number, width: number, height: number): void;
  27766. /**
  27767. * Set the WebGL's viewport
  27768. * @param viewport defines the viewport element to be used
  27769. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27770. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27771. */
  27772. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27773. /**
  27774. * Directly set the WebGL Viewport
  27775. * @param x defines the x coordinate of the viewport (in screen space)
  27776. * @param y defines the y coordinate of the viewport (in screen space)
  27777. * @param width defines the width of the viewport (in screen space)
  27778. * @param height defines the height of the viewport (in screen space)
  27779. * @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
  27780. */
  27781. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27782. /**
  27783. * Begin a new frame
  27784. */
  27785. beginFrame(): void;
  27786. /**
  27787. * Enf the current frame
  27788. */
  27789. endFrame(): void;
  27790. /**
  27791. * Resize the view according to the canvas' size
  27792. */
  27793. resize(): void;
  27794. /**
  27795. * Force a specific size of the canvas
  27796. * @param width defines the new canvas' width
  27797. * @param height defines the new canvas' height
  27798. */
  27799. setSize(width: number, height: number): void;
  27800. /**
  27801. * Gets a boolean indicating if a webVR device was detected
  27802. * @returns true if a webVR device was detected
  27803. */
  27804. isVRDevicePresent(): boolean;
  27805. /**
  27806. * Gets the current webVR device
  27807. * @returns the current webVR device (or null)
  27808. */
  27809. getVRDevice(): any;
  27810. /**
  27811. * Initializes a webVR display and starts listening to display change events
  27812. * The onVRDisplayChangedObservable will be notified upon these changes
  27813. * @returns The onVRDisplayChangedObservable
  27814. */
  27815. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27816. /**
  27817. * Initializes a webVR display and starts listening to display change events
  27818. * The onVRDisplayChangedObservable will be notified upon these changes
  27819. * @returns A promise containing a VRDisplay and if vr is supported
  27820. */
  27821. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27822. /**
  27823. * Call this function to switch to webVR mode
  27824. * Will do nothing if webVR is not supported or if there is no webVR device
  27825. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27826. */
  27827. enableVR(): void;
  27828. /**
  27829. * Call this function to leave webVR mode
  27830. * Will do nothing if webVR is not supported or if there is no webVR device
  27831. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27832. */
  27833. disableVR(): void;
  27834. private _onVRFullScreenTriggered;
  27835. private _getVRDisplaysAsync;
  27836. /**
  27837. * Binds the frame buffer to the specified texture.
  27838. * @param texture The texture to render to or null for the default canvas
  27839. * @param faceIndex The face of the texture to render to in case of cube texture
  27840. * @param requiredWidth The width of the target to render to
  27841. * @param requiredHeight The height of the target to render to
  27842. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27843. * @param depthStencilTexture The depth stencil texture to use to render
  27844. * @param lodLevel defines le lod level to bind to the frame buffer
  27845. */
  27846. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27847. private bindUnboundFramebuffer;
  27848. /**
  27849. * Unbind the current render target texture from the webGL context
  27850. * @param texture defines the render target texture to unbind
  27851. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27852. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27853. */
  27854. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27855. /**
  27856. * Unbind a list of render target textures from the webGL context
  27857. * This is used only when drawBuffer extension or webGL2 are active
  27858. * @param textures defines the render target textures to unbind
  27859. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27860. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27861. */
  27862. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27863. /**
  27864. * Force the mipmap generation for the given render target texture
  27865. * @param texture defines the render target texture to use
  27866. */
  27867. generateMipMapsForCubemap(texture: InternalTexture): void;
  27868. /**
  27869. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27870. */
  27871. flushFramebuffer(): void;
  27872. /**
  27873. * Unbind the current render target and bind the default framebuffer
  27874. */
  27875. restoreDefaultFramebuffer(): void;
  27876. /**
  27877. * Create an uniform buffer
  27878. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27879. * @param elements defines the content of the uniform buffer
  27880. * @returns the webGL uniform buffer
  27881. */
  27882. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27883. /**
  27884. * Create a dynamic uniform buffer
  27885. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27886. * @param elements defines the content of the uniform buffer
  27887. * @returns the webGL uniform buffer
  27888. */
  27889. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27890. /**
  27891. * Update an existing uniform buffer
  27892. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27893. * @param uniformBuffer defines the target uniform buffer
  27894. * @param elements defines the content to update
  27895. * @param offset defines the offset in the uniform buffer where update should start
  27896. * @param count defines the size of the data to update
  27897. */
  27898. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27899. private _resetVertexBufferBinding;
  27900. /**
  27901. * Creates a vertex buffer
  27902. * @param data the data for the vertex buffer
  27903. * @returns the new WebGL static buffer
  27904. */
  27905. createVertexBuffer(data: DataArray): WebGLBuffer;
  27906. /**
  27907. * Creates a dynamic vertex buffer
  27908. * @param data the data for the dynamic vertex buffer
  27909. * @returns the new WebGL dynamic buffer
  27910. */
  27911. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27912. /**
  27913. * Update a dynamic index buffer
  27914. * @param indexBuffer defines the target index buffer
  27915. * @param indices defines the data to update
  27916. * @param offset defines the offset in the target index buffer where update should start
  27917. */
  27918. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27919. /**
  27920. * Updates a dynamic vertex buffer.
  27921. * @param vertexBuffer the vertex buffer to update
  27922. * @param data the data used to update the vertex buffer
  27923. * @param byteOffset the byte offset of the data
  27924. * @param byteLength the byte length of the data
  27925. */
  27926. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27927. private _resetIndexBufferBinding;
  27928. /**
  27929. * Creates a new index buffer
  27930. * @param indices defines the content of the index buffer
  27931. * @param updatable defines if the index buffer must be updatable
  27932. * @returns a new webGL buffer
  27933. */
  27934. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27935. /**
  27936. * Bind a webGL buffer to the webGL context
  27937. * @param buffer defines the buffer to bind
  27938. */
  27939. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27940. /**
  27941. * Bind an uniform buffer to the current webGL context
  27942. * @param buffer defines the buffer to bind
  27943. */
  27944. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27945. /**
  27946. * Bind a buffer to the current webGL context at a given location
  27947. * @param buffer defines the buffer to bind
  27948. * @param location defines the index where to bind the buffer
  27949. */
  27950. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27951. /**
  27952. * Bind a specific block at a given index in a specific shader program
  27953. * @param shaderProgram defines the shader program
  27954. * @param blockName defines the block name
  27955. * @param index defines the index where to bind the block
  27956. */
  27957. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27958. private bindIndexBuffer;
  27959. private bindBuffer;
  27960. /**
  27961. * update the bound buffer with the given data
  27962. * @param data defines the data to update
  27963. */
  27964. updateArrayBuffer(data: Float32Array): void;
  27965. private _vertexAttribPointer;
  27966. private _bindIndexBufferWithCache;
  27967. private _bindVertexBuffersAttributes;
  27968. /**
  27969. * Records a vertex array object
  27970. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27971. * @param vertexBuffers defines the list of vertex buffers to store
  27972. * @param indexBuffer defines the index buffer to store
  27973. * @param effect defines the effect to store
  27974. * @returns the new vertex array object
  27975. */
  27976. recordVertexArrayObject(vertexBuffers: {
  27977. [key: string]: VertexBuffer;
  27978. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27979. /**
  27980. * Bind a specific vertex array object
  27981. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27982. * @param vertexArrayObject defines the vertex array object to bind
  27983. * @param indexBuffer defines the index buffer to bind
  27984. */
  27985. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27986. /**
  27987. * Bind webGl buffers directly to the webGL context
  27988. * @param vertexBuffer defines the vertex buffer to bind
  27989. * @param indexBuffer defines the index buffer to bind
  27990. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27991. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27992. * @param effect defines the effect associated with the vertex buffer
  27993. */
  27994. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27995. private _unbindVertexArrayObject;
  27996. /**
  27997. * Bind a list of vertex buffers to the webGL context
  27998. * @param vertexBuffers defines the list of vertex buffers to bind
  27999. * @param indexBuffer defines the index buffer to bind
  28000. * @param effect defines the effect associated with the vertex buffers
  28001. */
  28002. bindBuffers(vertexBuffers: {
  28003. [key: string]: Nullable<VertexBuffer>;
  28004. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28005. /**
  28006. * Unbind all instance attributes
  28007. */
  28008. unbindInstanceAttributes(): void;
  28009. /**
  28010. * Release and free the memory of a vertex array object
  28011. * @param vao defines the vertex array object to delete
  28012. */
  28013. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28014. /** @hidden */
  28015. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28016. /**
  28017. * Creates a webGL buffer to use with instanciation
  28018. * @param capacity defines the size of the buffer
  28019. * @returns the webGL buffer
  28020. */
  28021. createInstancesBuffer(capacity: number): WebGLBuffer;
  28022. /**
  28023. * Delete a webGL buffer used with instanciation
  28024. * @param buffer defines the webGL buffer to delete
  28025. */
  28026. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28027. /**
  28028. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28029. * @param instancesBuffer defines the webGL buffer to update and bind
  28030. * @param data defines the data to store in the buffer
  28031. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28032. */
  28033. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28034. /**
  28035. * Apply all cached states (depth, culling, stencil and alpha)
  28036. */
  28037. applyStates(): void;
  28038. /**
  28039. * Send a draw order
  28040. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28041. * @param indexStart defines the starting index
  28042. * @param indexCount defines the number of index to draw
  28043. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28044. */
  28045. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28046. /**
  28047. * Draw a list of points
  28048. * @param verticesStart defines the index of first vertex to draw
  28049. * @param verticesCount defines the count of vertices to draw
  28050. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28051. */
  28052. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28053. /**
  28054. * Draw a list of unindexed primitives
  28055. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28056. * @param verticesStart defines the index of first vertex to draw
  28057. * @param verticesCount defines the count of vertices to draw
  28058. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28059. */
  28060. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28061. /**
  28062. * Draw a list of indexed primitives
  28063. * @param fillMode defines the primitive to use
  28064. * @param indexStart defines the starting index
  28065. * @param indexCount defines the number of index to draw
  28066. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28067. */
  28068. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28069. /**
  28070. * Draw a list of unindexed primitives
  28071. * @param fillMode defines the primitive to use
  28072. * @param verticesStart defines the index of first vertex to draw
  28073. * @param verticesCount defines the count of vertices to draw
  28074. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28075. */
  28076. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28077. private _drawMode;
  28078. /** @hidden */
  28079. _releaseEffect(effect: Effect): void;
  28080. /** @hidden */
  28081. _deleteProgram(program: WebGLProgram): void;
  28082. /**
  28083. * Create a new effect (used to store vertex/fragment shaders)
  28084. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28085. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28086. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28087. * @param samplers defines an array of string used to represent textures
  28088. * @param defines defines the string containing the defines to use to compile the shaders
  28089. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28090. * @param onCompiled defines a function to call when the effect creation is successful
  28091. * @param onError defines a function to call when the effect creation has failed
  28092. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28093. * @returns the new Effect
  28094. */
  28095. 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;
  28096. private _compileShader;
  28097. private _compileRawShader;
  28098. /**
  28099. * Directly creates a webGL program
  28100. * @param vertexCode defines the vertex shader code to use
  28101. * @param fragmentCode defines the fragment shader code to use
  28102. * @param context defines the webGL context to use (if not set, the current one will be used)
  28103. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28104. * @returns the new webGL program
  28105. */
  28106. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28107. /**
  28108. * Creates a webGL program
  28109. * @param vertexCode defines the vertex shader code to use
  28110. * @param fragmentCode defines the fragment shader code to use
  28111. * @param defines defines the string containing the defines to use to compile the shaders
  28112. * @param context defines the webGL context to use (if not set, the current one will be used)
  28113. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28114. * @returns the new webGL program
  28115. */
  28116. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28117. private _createShaderProgram;
  28118. private _finalizeProgram;
  28119. /** @hidden */
  28120. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28121. /** @hidden */
  28122. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28123. /**
  28124. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28125. * @param shaderProgram defines the webGL program to use
  28126. * @param uniformsNames defines the list of uniform names
  28127. * @returns an array of webGL uniform locations
  28128. */
  28129. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28130. /**
  28131. * Gets the lsit of active attributes for a given webGL program
  28132. * @param shaderProgram defines the webGL program to use
  28133. * @param attributesNames defines the list of attribute names to get
  28134. * @returns an array of indices indicating the offset of each attribute
  28135. */
  28136. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28137. /**
  28138. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28139. * @param effect defines the effect to activate
  28140. */
  28141. enableEffect(effect: Nullable<Effect>): void;
  28142. /**
  28143. * Set the value of an uniform to an array of int32
  28144. * @param uniform defines the webGL uniform location where to store the value
  28145. * @param array defines the array of int32 to store
  28146. */
  28147. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28148. /**
  28149. * Set the value of an uniform to an array of int32 (stored as vec2)
  28150. * @param uniform defines the webGL uniform location where to store the value
  28151. * @param array defines the array of int32 to store
  28152. */
  28153. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28154. /**
  28155. * Set the value of an uniform to an array of int32 (stored as vec3)
  28156. * @param uniform defines the webGL uniform location where to store the value
  28157. * @param array defines the array of int32 to store
  28158. */
  28159. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28160. /**
  28161. * Set the value of an uniform to an array of int32 (stored as vec4)
  28162. * @param uniform defines the webGL uniform location where to store the value
  28163. * @param array defines the array of int32 to store
  28164. */
  28165. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28166. /**
  28167. * Set the value of an uniform to an array of float32
  28168. * @param uniform defines the webGL uniform location where to store the value
  28169. * @param array defines the array of float32 to store
  28170. */
  28171. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28172. /**
  28173. * Set the value of an uniform to an array of float32 (stored as vec2)
  28174. * @param uniform defines the webGL uniform location where to store the value
  28175. * @param array defines the array of float32 to store
  28176. */
  28177. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28178. /**
  28179. * Set the value of an uniform to an array of float32 (stored as vec3)
  28180. * @param uniform defines the webGL uniform location where to store the value
  28181. * @param array defines the array of float32 to store
  28182. */
  28183. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28184. /**
  28185. * Set the value of an uniform to an array of float32 (stored as vec4)
  28186. * @param uniform defines the webGL uniform location where to store the value
  28187. * @param array defines the array of float32 to store
  28188. */
  28189. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28190. /**
  28191. * Set the value of an uniform to an array of number
  28192. * @param uniform defines the webGL uniform location where to store the value
  28193. * @param array defines the array of number to store
  28194. */
  28195. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28196. /**
  28197. * Set the value of an uniform to an array of number (stored as vec2)
  28198. * @param uniform defines the webGL uniform location where to store the value
  28199. * @param array defines the array of number to store
  28200. */
  28201. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28202. /**
  28203. * Set the value of an uniform to an array of number (stored as vec3)
  28204. * @param uniform defines the webGL uniform location where to store the value
  28205. * @param array defines the array of number to store
  28206. */
  28207. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28208. /**
  28209. * Set the value of an uniform to an array of number (stored as vec4)
  28210. * @param uniform defines the webGL uniform location where to store the value
  28211. * @param array defines the array of number to store
  28212. */
  28213. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28214. /**
  28215. * Set the value of an uniform to an array of float32 (stored as matrices)
  28216. * @param uniform defines the webGL uniform location where to store the value
  28217. * @param matrices defines the array of float32 to store
  28218. */
  28219. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28220. /**
  28221. * Set the value of an uniform to a matrix
  28222. * @param uniform defines the webGL uniform location where to store the value
  28223. * @param matrix defines the matrix to store
  28224. */
  28225. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28226. /**
  28227. * Set the value of an uniform to a matrix (3x3)
  28228. * @param uniform defines the webGL uniform location where to store the value
  28229. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28230. */
  28231. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28232. /**
  28233. * Set the value of an uniform to a matrix (2x2)
  28234. * @param uniform defines the webGL uniform location where to store the value
  28235. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28236. */
  28237. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28238. /**
  28239. * Set the value of an uniform to a number (int)
  28240. * @param uniform defines the webGL uniform location where to store the value
  28241. * @param value defines the int number to store
  28242. */
  28243. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28244. /**
  28245. * Set the value of an uniform to a number (float)
  28246. * @param uniform defines the webGL uniform location where to store the value
  28247. * @param value defines the float number to store
  28248. */
  28249. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28250. /**
  28251. * Set the value of an uniform to a vec2
  28252. * @param uniform defines the webGL uniform location where to store the value
  28253. * @param x defines the 1st component of the value
  28254. * @param y defines the 2nd component of the value
  28255. */
  28256. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28257. /**
  28258. * Set the value of an uniform to a vec3
  28259. * @param uniform defines the webGL uniform location where to store the value
  28260. * @param x defines the 1st component of the value
  28261. * @param y defines the 2nd component of the value
  28262. * @param z defines the 3rd component of the value
  28263. */
  28264. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28265. /**
  28266. * Set the value of an uniform to a boolean
  28267. * @param uniform defines the webGL uniform location where to store the value
  28268. * @param bool defines the boolean to store
  28269. */
  28270. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28271. /**
  28272. * Set the value of an uniform to a vec4
  28273. * @param uniform defines the webGL uniform location where to store the value
  28274. * @param x defines the 1st component of the value
  28275. * @param y defines the 2nd component of the value
  28276. * @param z defines the 3rd component of the value
  28277. * @param w defines the 4th component of the value
  28278. */
  28279. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28280. /**
  28281. * Set the value of an uniform to a Color3
  28282. * @param uniform defines the webGL uniform location where to store the value
  28283. * @param color3 defines the color to store
  28284. */
  28285. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28286. /**
  28287. * Set the value of an uniform to a Color3 and an alpha value
  28288. * @param uniform defines the webGL uniform location where to store the value
  28289. * @param color3 defines the color to store
  28290. * @param alpha defines the alpha component to store
  28291. */
  28292. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28293. /**
  28294. * Sets a Color4 on a uniform variable
  28295. * @param uniform defines the uniform location
  28296. * @param color4 defines the value to be set
  28297. */
  28298. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28299. /**
  28300. * Set various states to the webGL context
  28301. * @param culling defines backface culling state
  28302. * @param zOffset defines the value to apply to zOffset (0 by default)
  28303. * @param force defines if states must be applied even if cache is up to date
  28304. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28305. */
  28306. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28307. /**
  28308. * Set the z offset to apply to current rendering
  28309. * @param value defines the offset to apply
  28310. */
  28311. setZOffset(value: number): void;
  28312. /**
  28313. * Gets the current value of the zOffset
  28314. * @returns the current zOffset state
  28315. */
  28316. getZOffset(): number;
  28317. /**
  28318. * Enable or disable depth buffering
  28319. * @param enable defines the state to set
  28320. */
  28321. setDepthBuffer(enable: boolean): void;
  28322. /**
  28323. * Gets a boolean indicating if depth writing is enabled
  28324. * @returns the current depth writing state
  28325. */
  28326. getDepthWrite(): boolean;
  28327. /**
  28328. * Enable or disable depth writing
  28329. * @param enable defines the state to set
  28330. */
  28331. setDepthWrite(enable: boolean): void;
  28332. /**
  28333. * Enable or disable color writing
  28334. * @param enable defines the state to set
  28335. */
  28336. setColorWrite(enable: boolean): void;
  28337. /**
  28338. * Gets a boolean indicating if color writing is enabled
  28339. * @returns the current color writing state
  28340. */
  28341. getColorWrite(): boolean;
  28342. /**
  28343. * Sets alpha constants used by some alpha blending modes
  28344. * @param r defines the red component
  28345. * @param g defines the green component
  28346. * @param b defines the blue component
  28347. * @param a defines the alpha component
  28348. */
  28349. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28350. /**
  28351. * Sets the current alpha mode
  28352. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28353. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28354. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28355. */
  28356. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28357. /**
  28358. * Gets the current alpha mode
  28359. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28360. * @returns the current alpha mode
  28361. */
  28362. getAlphaMode(): number;
  28363. /**
  28364. * Clears the list of texture accessible through engine.
  28365. * This can help preventing texture load conflict due to name collision.
  28366. */
  28367. clearInternalTexturesCache(): void;
  28368. /**
  28369. * Force the entire cache to be cleared
  28370. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28371. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28372. */
  28373. wipeCaches(bruteForce?: boolean): void;
  28374. /**
  28375. * Set the compressed texture format to use, based on the formats you have, and the formats
  28376. * supported by the hardware / browser.
  28377. *
  28378. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28379. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28380. * to API arguments needed to compressed textures. This puts the burden on the container
  28381. * generator to house the arcane code for determining these for current & future formats.
  28382. *
  28383. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28384. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28385. *
  28386. * Note: The result of this call is not taken into account when a texture is base64.
  28387. *
  28388. * @param formatsAvailable defines the list of those format families you have created
  28389. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28390. *
  28391. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28392. * @returns The extension selected.
  28393. */
  28394. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28395. private _getSamplingParameters;
  28396. private _partialLoadImg;
  28397. private _cascadeLoadImgs;
  28398. /** @hidden */
  28399. _createTexture(): WebGLTexture;
  28400. /**
  28401. * Usually called from Texture.ts.
  28402. * Passed information to create a WebGLTexture
  28403. * @param urlArg defines a value which contains one of the following:
  28404. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28405. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28406. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28407. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28408. * @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)
  28409. * @param scene needed for loading to the correct scene
  28410. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28411. * @param onLoad optional callback to be called upon successful completion
  28412. * @param onError optional callback to be called upon failure
  28413. * @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
  28414. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28415. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28416. * @param forcedExtension defines the extension to use to pick the right loader
  28417. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28418. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28419. */
  28420. 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;
  28421. private _rescaleTexture;
  28422. /**
  28423. * Update a raw texture
  28424. * @param texture defines the texture to update
  28425. * @param data defines the data to store in the texture
  28426. * @param format defines the format of the data
  28427. * @param invertY defines if data must be stored with Y axis inverted
  28428. * @param compression defines the compression used (null by default)
  28429. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28430. */
  28431. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28432. /**
  28433. * Creates a raw texture
  28434. * @param data defines the data to store in the texture
  28435. * @param width defines the width of the texture
  28436. * @param height defines the height of the texture
  28437. * @param format defines the format of the data
  28438. * @param generateMipMaps defines if the engine should generate the mip levels
  28439. * @param invertY defines if data must be stored with Y axis inverted
  28440. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28441. * @param compression defines the compression used (null by default)
  28442. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28443. * @returns the raw texture inside an InternalTexture
  28444. */
  28445. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28446. private _unpackFlipYCached;
  28447. /**
  28448. * In case you are sharing the context with other applications, it might
  28449. * be interested to not cache the unpack flip y state to ensure a consistent
  28450. * value would be set.
  28451. */
  28452. enableUnpackFlipYCached: boolean;
  28453. /** @hidden */
  28454. _unpackFlipY(value: boolean): void;
  28455. /** @hidden */
  28456. _getUnpackAlignement(): number;
  28457. /**
  28458. * Creates a dynamic texture
  28459. * @param width defines the width of the texture
  28460. * @param height defines the height of the texture
  28461. * @param generateMipMaps defines if the engine should generate the mip levels
  28462. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28463. * @returns the dynamic texture inside an InternalTexture
  28464. */
  28465. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28466. /**
  28467. * Update the sampling mode of a given texture
  28468. * @param samplingMode defines the required sampling mode
  28469. * @param texture defines the texture to update
  28470. */
  28471. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28472. /**
  28473. * Update the content of a dynamic texture
  28474. * @param texture defines the texture to update
  28475. * @param canvas defines the canvas containing the source
  28476. * @param invertY defines if data must be stored with Y axis inverted
  28477. * @param premulAlpha defines if alpha is stored as premultiplied
  28478. * @param format defines the format of the data
  28479. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28480. */
  28481. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28482. /**
  28483. * Update a video texture
  28484. * @param texture defines the texture to update
  28485. * @param video defines the video element to use
  28486. * @param invertY defines if data must be stored with Y axis inverted
  28487. */
  28488. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28489. /**
  28490. * Updates a depth texture Comparison Mode and Function.
  28491. * If the comparison Function is equal to 0, the mode will be set to none.
  28492. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28493. * @param texture The texture to set the comparison function for
  28494. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28495. */
  28496. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28497. private _setupDepthStencilTexture;
  28498. /**
  28499. * Creates a depth stencil texture.
  28500. * This is only available in WebGL 2 or with the depth texture extension available.
  28501. * @param size The size of face edge in the texture.
  28502. * @param options The options defining the texture.
  28503. * @returns The texture
  28504. */
  28505. createDepthStencilTexture(size: number | {
  28506. width: number;
  28507. height: number;
  28508. }, options: DepthTextureCreationOptions): InternalTexture;
  28509. /**
  28510. * Creates a depth stencil texture.
  28511. * This is only available in WebGL 2 or with the depth texture extension available.
  28512. * @param size The size of face edge in the texture.
  28513. * @param options The options defining the texture.
  28514. * @returns The texture
  28515. */
  28516. private _createDepthStencilTexture;
  28517. /**
  28518. * Creates a depth stencil cube texture.
  28519. * This is only available in WebGL 2.
  28520. * @param size The size of face edge in the cube texture.
  28521. * @param options The options defining the cube texture.
  28522. * @returns The cube texture
  28523. */
  28524. private _createDepthStencilCubeTexture;
  28525. /**
  28526. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28527. * @param renderTarget The render target to set the frame buffer for
  28528. */
  28529. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28530. /**
  28531. * Creates a new render target texture
  28532. * @param size defines the size of the texture
  28533. * @param options defines the options used to create the texture
  28534. * @returns a new render target texture stored in an InternalTexture
  28535. */
  28536. createRenderTargetTexture(size: number | {
  28537. width: number;
  28538. height: number;
  28539. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28540. /**
  28541. * Create a multi render target texture
  28542. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28543. * @param size defines the size of the texture
  28544. * @param options defines the creation options
  28545. * @returns the cube texture as an InternalTexture
  28546. */
  28547. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28548. private _setupFramebufferDepthAttachments;
  28549. /**
  28550. * Updates the sample count of a render target texture
  28551. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28552. * @param texture defines the texture to update
  28553. * @param samples defines the sample count to set
  28554. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28555. */
  28556. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28557. /**
  28558. * Update the sample count for a given multiple render target texture
  28559. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28560. * @param textures defines the textures to update
  28561. * @param samples defines the sample count to set
  28562. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28563. */
  28564. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28565. /** @hidden */
  28566. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28567. /** @hidden */
  28568. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28569. /** @hidden */
  28570. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28571. /** @hidden */
  28572. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28573. /**
  28574. * Creates a new render target cube texture
  28575. * @param size defines the size of the texture
  28576. * @param options defines the options used to create the texture
  28577. * @returns a new render target cube texture stored in an InternalTexture
  28578. */
  28579. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28580. /**
  28581. * Creates a cube texture
  28582. * @param rootUrl defines the url where the files to load is located
  28583. * @param scene defines the current scene
  28584. * @param files defines the list of files to load (1 per face)
  28585. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28586. * @param onLoad defines an optional callback raised when the texture is loaded
  28587. * @param onError defines an optional callback raised if there is an issue to load the texture
  28588. * @param format defines the format of the data
  28589. * @param forcedExtension defines the extension to use to pick the right loader
  28590. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28591. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28592. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28593. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28594. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28595. * @returns the cube texture as an InternalTexture
  28596. */
  28597. 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;
  28598. /**
  28599. * @hidden
  28600. */
  28601. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28602. /**
  28603. * Update a raw cube texture
  28604. * @param texture defines the texture to udpdate
  28605. * @param data defines the data to store
  28606. * @param format defines the data format
  28607. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28608. * @param invertY defines if data must be stored with Y axis inverted
  28609. * @param compression defines the compression used (null by default)
  28610. * @param level defines which level of the texture to update
  28611. */
  28612. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28613. /**
  28614. * Creates a new raw cube texture
  28615. * @param data defines the array of data to use to create each face
  28616. * @param size defines the size of the textures
  28617. * @param format defines the format of the data
  28618. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28619. * @param generateMipMaps defines if the engine should generate the mip levels
  28620. * @param invertY defines if data must be stored with Y axis inverted
  28621. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28622. * @param compression defines the compression used (null by default)
  28623. * @returns the cube texture as an InternalTexture
  28624. */
  28625. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28626. /**
  28627. * Creates a new raw cube texture from a specified url
  28628. * @param url defines the url where the data is located
  28629. * @param scene defines the current scene
  28630. * @param size defines the size of the textures
  28631. * @param format defines the format of the data
  28632. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28633. * @param noMipmap defines if the engine should avoid generating the mip levels
  28634. * @param callback defines a callback used to extract texture data from loaded data
  28635. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28636. * @param onLoad defines a callback called when texture is loaded
  28637. * @param onError defines a callback called if there is an error
  28638. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28639. * @param invertY defines if data must be stored with Y axis inverted
  28640. * @returns the cube texture as an InternalTexture
  28641. */
  28642. 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;
  28643. /**
  28644. * Update a raw 3D texture
  28645. * @param texture defines the texture to update
  28646. * @param data defines the data to store
  28647. * @param format defines the data format
  28648. * @param invertY defines if data must be stored with Y axis inverted
  28649. * @param compression defines the used compression (can be null)
  28650. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28651. */
  28652. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28653. /**
  28654. * Creates a new raw 3D texture
  28655. * @param data defines the data used to create the texture
  28656. * @param width defines the width of the texture
  28657. * @param height defines the height of the texture
  28658. * @param depth defines the depth of the texture
  28659. * @param format defines the format of the texture
  28660. * @param generateMipMaps defines if the engine must generate mip levels
  28661. * @param invertY defines if data must be stored with Y axis inverted
  28662. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28663. * @param compression defines the compressed used (can be null)
  28664. * @param textureType defines the compressed used (can be null)
  28665. * @returns a new raw 3D texture (stored in an InternalTexture)
  28666. */
  28667. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28668. private _prepareWebGLTextureContinuation;
  28669. private _prepareWebGLTexture;
  28670. private _convertRGBtoRGBATextureData;
  28671. /** @hidden */
  28672. _releaseFramebufferObjects(texture: InternalTexture): void;
  28673. /** @hidden */
  28674. _releaseTexture(texture: InternalTexture): void;
  28675. private setProgram;
  28676. private _boundUniforms;
  28677. /**
  28678. * Binds an effect to the webGL context
  28679. * @param effect defines the effect to bind
  28680. */
  28681. bindSamplers(effect: Effect): void;
  28682. private _moveBoundTextureOnTop;
  28683. private _getCorrectTextureChannel;
  28684. private _linkTrackers;
  28685. private _removeDesignatedSlot;
  28686. private _activateCurrentTexture;
  28687. /** @hidden */
  28688. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28689. /** @hidden */
  28690. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28691. /**
  28692. * Sets a texture to the webGL context from a postprocess
  28693. * @param channel defines the channel to use
  28694. * @param postProcess defines the source postprocess
  28695. */
  28696. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28697. /**
  28698. * Binds the output of the passed in post process to the texture channel specified
  28699. * @param channel The channel the texture should be bound to
  28700. * @param postProcess The post process which's output should be bound
  28701. */
  28702. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28703. /**
  28704. * Unbind all textures from the webGL context
  28705. */
  28706. unbindAllTextures(): void;
  28707. /**
  28708. * Sets a texture to the according uniform.
  28709. * @param channel The texture channel
  28710. * @param uniform The uniform to set
  28711. * @param texture The texture to apply
  28712. */
  28713. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28714. /**
  28715. * Sets a depth stencil texture from a render target to the according uniform.
  28716. * @param channel The texture channel
  28717. * @param uniform The uniform to set
  28718. * @param texture The render target texture containing the depth stencil texture to apply
  28719. */
  28720. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28721. private _bindSamplerUniformToChannel;
  28722. private _getTextureWrapMode;
  28723. private _setTexture;
  28724. /**
  28725. * Sets an array of texture to the webGL context
  28726. * @param channel defines the channel where the texture array must be set
  28727. * @param uniform defines the associated uniform location
  28728. * @param textures defines the array of textures to bind
  28729. */
  28730. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28731. /** @hidden */
  28732. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28733. private _setTextureParameterFloat;
  28734. private _setTextureParameterInteger;
  28735. /**
  28736. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28737. * @param x defines the x coordinate of the rectangle where pixels must be read
  28738. * @param y defines the y coordinate of the rectangle where pixels must be read
  28739. * @param width defines the width of the rectangle where pixels must be read
  28740. * @param height defines the height of the rectangle where pixels must be read
  28741. * @returns a Uint8Array containing RGBA colors
  28742. */
  28743. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28744. /**
  28745. * Add an externaly attached data from its key.
  28746. * This method call will fail and return false, if such key already exists.
  28747. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28748. * @param key the unique key that identifies the data
  28749. * @param data the data object to associate to the key for this Engine instance
  28750. * @return true if no such key were already present and the data was added successfully, false otherwise
  28751. */
  28752. addExternalData<T>(key: string, data: T): boolean;
  28753. /**
  28754. * Get an externaly attached data from its key
  28755. * @param key the unique key that identifies the data
  28756. * @return the associated data, if present (can be null), or undefined if not present
  28757. */
  28758. getExternalData<T>(key: string): T;
  28759. /**
  28760. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28761. * @param key the unique key that identifies the data
  28762. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28763. * @return the associated data, can be null if the factory returned null.
  28764. */
  28765. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28766. /**
  28767. * Remove an externaly attached data from the Engine instance
  28768. * @param key the unique key that identifies the data
  28769. * @return true if the data was successfully removed, false if it doesn't exist
  28770. */
  28771. removeExternalData(key: string): boolean;
  28772. /**
  28773. * Unbind all vertex attributes from the webGL context
  28774. */
  28775. unbindAllAttributes(): void;
  28776. /**
  28777. * 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
  28778. */
  28779. releaseEffects(): void;
  28780. /**
  28781. * Dispose and release all associated resources
  28782. */
  28783. dispose(): void;
  28784. /**
  28785. * Display the loading screen
  28786. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28787. */
  28788. displayLoadingUI(): void;
  28789. /**
  28790. * Hide the loading screen
  28791. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28792. */
  28793. hideLoadingUI(): void;
  28794. /**
  28795. * Gets the current loading screen object
  28796. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28797. */
  28798. /**
  28799. * Sets the current loading screen object
  28800. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28801. */
  28802. loadingScreen: ILoadingScreen;
  28803. /**
  28804. * Sets the current loading screen text
  28805. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28806. */
  28807. loadingUIText: string;
  28808. /**
  28809. * Sets the current loading screen background color
  28810. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28811. */
  28812. loadingUIBackgroundColor: string;
  28813. /**
  28814. * Attach a new callback raised when context lost event is fired
  28815. * @param callback defines the callback to call
  28816. */
  28817. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28818. /**
  28819. * Attach a new callback raised when context restored event is fired
  28820. * @param callback defines the callback to call
  28821. */
  28822. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28823. /**
  28824. * Gets the source code of the vertex shader associated with a specific webGL program
  28825. * @param program defines the program to use
  28826. * @returns a string containing the source code of the vertex shader associated with the program
  28827. */
  28828. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28829. /**
  28830. * Gets the source code of the fragment shader associated with a specific webGL program
  28831. * @param program defines the program to use
  28832. * @returns a string containing the source code of the fragment shader associated with the program
  28833. */
  28834. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28835. /**
  28836. * Get the current error code of the webGL context
  28837. * @returns the error code
  28838. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28839. */
  28840. getError(): number;
  28841. /**
  28842. * Gets the current framerate
  28843. * @returns a number representing the framerate
  28844. */
  28845. getFps(): number;
  28846. /**
  28847. * Gets the time spent between current and previous frame
  28848. * @returns a number representing the delta time in ms
  28849. */
  28850. getDeltaTime(): number;
  28851. private _measureFps;
  28852. /** @hidden */
  28853. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28854. private _canRenderToFloatFramebuffer;
  28855. private _canRenderToHalfFloatFramebuffer;
  28856. private _canRenderToFramebuffer;
  28857. /** @hidden */
  28858. _getWebGLTextureType(type: number): number;
  28859. private _getInternalFormat;
  28860. /** @hidden */
  28861. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28862. /** @hidden */
  28863. _getRGBAMultiSampleBufferFormat(type: number): number;
  28864. /** @hidden */
  28865. _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;
  28866. /** @hidden */
  28867. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28868. private _partialLoadFile;
  28869. private _cascadeLoadFiles;
  28870. /**
  28871. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28872. * @returns true if the engine can be created
  28873. * @ignorenaming
  28874. */
  28875. static isSupported(): boolean;
  28876. }
  28877. }
  28878. declare module "babylonjs/Materials/effect" {
  28879. import { Observable } from "babylonjs/Misc/observable";
  28880. import { Nullable } from "babylonjs/types";
  28881. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28882. import { Engine } from "babylonjs/Engines/engine";
  28883. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28884. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28885. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28886. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28888. /**
  28889. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28890. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28891. */
  28892. export class EffectFallbacks {
  28893. private _defines;
  28894. private _currentRank;
  28895. private _maxRank;
  28896. private _mesh;
  28897. /**
  28898. * Removes the fallback from the bound mesh.
  28899. */
  28900. unBindMesh(): void;
  28901. /**
  28902. * Adds a fallback on the specified property.
  28903. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28904. * @param define The name of the define in the shader
  28905. */
  28906. addFallback(rank: number, define: string): void;
  28907. /**
  28908. * Sets the mesh to use CPU skinning when needing to fallback.
  28909. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28910. * @param mesh The mesh to use the fallbacks.
  28911. */
  28912. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28913. /**
  28914. * Checks to see if more fallbacks are still availible.
  28915. */
  28916. readonly isMoreFallbacks: boolean;
  28917. /**
  28918. * Removes the defines that shoould be removed when falling back.
  28919. * @param currentDefines defines the current define statements for the shader.
  28920. * @param effect defines the current effect we try to compile
  28921. * @returns The resulting defines with defines of the current rank removed.
  28922. */
  28923. reduce(currentDefines: string, effect: Effect): string;
  28924. }
  28925. /**
  28926. * Options to be used when creating an effect.
  28927. */
  28928. export class EffectCreationOptions {
  28929. /**
  28930. * Atrributes that will be used in the shader.
  28931. */
  28932. attributes: string[];
  28933. /**
  28934. * Uniform varible names that will be set in the shader.
  28935. */
  28936. uniformsNames: string[];
  28937. /**
  28938. * Uniform buffer varible names that will be set in the shader.
  28939. */
  28940. uniformBuffersNames: string[];
  28941. /**
  28942. * Sampler texture variable names that will be set in the shader.
  28943. */
  28944. samplers: string[];
  28945. /**
  28946. * Define statements that will be set in the shader.
  28947. */
  28948. defines: any;
  28949. /**
  28950. * Possible fallbacks for this effect to improve performance when needed.
  28951. */
  28952. fallbacks: Nullable<EffectFallbacks>;
  28953. /**
  28954. * Callback that will be called when the shader is compiled.
  28955. */
  28956. onCompiled: Nullable<(effect: Effect) => void>;
  28957. /**
  28958. * Callback that will be called if an error occurs during shader compilation.
  28959. */
  28960. onError: Nullable<(effect: Effect, errors: string) => void>;
  28961. /**
  28962. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28963. */
  28964. indexParameters: any;
  28965. /**
  28966. * Max number of lights that can be used in the shader.
  28967. */
  28968. maxSimultaneousLights: number;
  28969. /**
  28970. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28971. */
  28972. transformFeedbackVaryings: Nullable<string[]>;
  28973. }
  28974. /**
  28975. * Effect containing vertex and fragment shader that can be executed on an object.
  28976. */
  28977. export class Effect {
  28978. /**
  28979. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28980. */
  28981. static ShadersRepository: string;
  28982. /**
  28983. * Name of the effect.
  28984. */
  28985. name: any;
  28986. /**
  28987. * String container all the define statements that should be set on the shader.
  28988. */
  28989. defines: string;
  28990. /**
  28991. * Callback that will be called when the shader is compiled.
  28992. */
  28993. onCompiled: Nullable<(effect: Effect) => void>;
  28994. /**
  28995. * Callback that will be called if an error occurs during shader compilation.
  28996. */
  28997. onError: Nullable<(effect: Effect, errors: string) => void>;
  28998. /**
  28999. * Callback that will be called when effect is bound.
  29000. */
  29001. onBind: Nullable<(effect: Effect) => void>;
  29002. /**
  29003. * Unique ID of the effect.
  29004. */
  29005. uniqueId: number;
  29006. /**
  29007. * Observable that will be called when the shader is compiled.
  29008. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29009. */
  29010. onCompileObservable: Observable<Effect>;
  29011. /**
  29012. * Observable that will be called if an error occurs during shader compilation.
  29013. */
  29014. onErrorObservable: Observable<Effect>;
  29015. /** @hidden */
  29016. _onBindObservable: Nullable<Observable<Effect>>;
  29017. /**
  29018. * Observable that will be called when effect is bound.
  29019. */
  29020. readonly onBindObservable: Observable<Effect>;
  29021. /** @hidden */
  29022. _bonesComputationForcedToCPU: boolean;
  29023. private static _uniqueIdSeed;
  29024. private _engine;
  29025. private _uniformBuffersNames;
  29026. private _uniformsNames;
  29027. private _samplers;
  29028. private _isReady;
  29029. private _compilationError;
  29030. private _attributesNames;
  29031. private _attributes;
  29032. private _uniforms;
  29033. /**
  29034. * Key for the effect.
  29035. * @hidden
  29036. */
  29037. _key: string;
  29038. private _indexParameters;
  29039. private _fallbacks;
  29040. private _vertexSourceCode;
  29041. private _fragmentSourceCode;
  29042. private _vertexSourceCodeOverride;
  29043. private _fragmentSourceCodeOverride;
  29044. private _transformFeedbackVaryings;
  29045. /**
  29046. * Compiled shader to webGL program.
  29047. * @hidden
  29048. */
  29049. _program: WebGLProgram;
  29050. private _valueCache;
  29051. private static _baseCache;
  29052. /**
  29053. * Instantiates an effect.
  29054. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29055. * @param baseName Name of the effect.
  29056. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29057. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29058. * @param samplers List of sampler variables that will be passed to the shader.
  29059. * @param engine Engine to be used to render the effect
  29060. * @param defines Define statements to be added to the shader.
  29061. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29062. * @param onCompiled Callback that will be called when the shader is compiled.
  29063. * @param onError Callback that will be called if an error occurs during shader compilation.
  29064. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29065. */
  29066. 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);
  29067. /**
  29068. * Unique key for this effect
  29069. */
  29070. readonly key: string;
  29071. /**
  29072. * If the effect has been compiled and prepared.
  29073. * @returns if the effect is compiled and prepared.
  29074. */
  29075. isReady(): boolean;
  29076. /**
  29077. * The engine the effect was initialized with.
  29078. * @returns the engine.
  29079. */
  29080. getEngine(): Engine;
  29081. /**
  29082. * The compiled webGL program for the effect
  29083. * @returns the webGL program.
  29084. */
  29085. getProgram(): WebGLProgram;
  29086. /**
  29087. * The set of names of attribute variables for the shader.
  29088. * @returns An array of attribute names.
  29089. */
  29090. getAttributesNames(): string[];
  29091. /**
  29092. * Returns the attribute at the given index.
  29093. * @param index The index of the attribute.
  29094. * @returns The location of the attribute.
  29095. */
  29096. getAttributeLocation(index: number): number;
  29097. /**
  29098. * Returns the attribute based on the name of the variable.
  29099. * @param name of the attribute to look up.
  29100. * @returns the attribute location.
  29101. */
  29102. getAttributeLocationByName(name: string): number;
  29103. /**
  29104. * The number of attributes.
  29105. * @returns the numnber of attributes.
  29106. */
  29107. getAttributesCount(): number;
  29108. /**
  29109. * Gets the index of a uniform variable.
  29110. * @param uniformName of the uniform to look up.
  29111. * @returns the index.
  29112. */
  29113. getUniformIndex(uniformName: string): number;
  29114. /**
  29115. * Returns the attribute based on the name of the variable.
  29116. * @param uniformName of the uniform to look up.
  29117. * @returns the location of the uniform.
  29118. */
  29119. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29120. /**
  29121. * Returns an array of sampler variable names
  29122. * @returns The array of sampler variable neames.
  29123. */
  29124. getSamplers(): string[];
  29125. /**
  29126. * The error from the last compilation.
  29127. * @returns the error string.
  29128. */
  29129. getCompilationError(): string;
  29130. /**
  29131. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29132. * @param func The callback to be used.
  29133. */
  29134. executeWhenCompiled(func: (effect: Effect) => void): void;
  29135. private _checkIsReady;
  29136. /** @hidden */
  29137. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29138. /** @hidden */
  29139. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29140. /** @hidden */
  29141. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29142. private _processShaderConversion;
  29143. private _processIncludes;
  29144. private _processPrecision;
  29145. /**
  29146. * Recompiles the webGL program
  29147. * @param vertexSourceCode The source code for the vertex shader.
  29148. * @param fragmentSourceCode The source code for the fragment shader.
  29149. * @param onCompiled Callback called when completed.
  29150. * @param onError Callback called on error.
  29151. * @hidden
  29152. */
  29153. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29154. /**
  29155. * Gets the uniform locations of the the specified variable names
  29156. * @param names THe names of the variables to lookup.
  29157. * @returns Array of locations in the same order as variable names.
  29158. */
  29159. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29160. /**
  29161. * Prepares the effect
  29162. * @hidden
  29163. */
  29164. _prepareEffect(): void;
  29165. /**
  29166. * Checks if the effect is supported. (Must be called after compilation)
  29167. */
  29168. readonly isSupported: boolean;
  29169. /**
  29170. * Binds a texture to the engine to be used as output of the shader.
  29171. * @param channel Name of the output variable.
  29172. * @param texture Texture to bind.
  29173. * @hidden
  29174. */
  29175. _bindTexture(channel: string, texture: InternalTexture): void;
  29176. /**
  29177. * Sets a texture on the engine to be used in the shader.
  29178. * @param channel Name of the sampler variable.
  29179. * @param texture Texture to set.
  29180. */
  29181. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29182. /**
  29183. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29184. * @param channel Name of the sampler variable.
  29185. * @param texture Texture to set.
  29186. */
  29187. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29188. /**
  29189. * Sets an array of textures on the engine to be used in the shader.
  29190. * @param channel Name of the variable.
  29191. * @param textures Textures to set.
  29192. */
  29193. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29194. /**
  29195. * 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)
  29196. * @param channel Name of the sampler variable.
  29197. * @param postProcess Post process to get the input texture from.
  29198. */
  29199. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29200. /**
  29201. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29202. * 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)
  29203. * @param channel Name of the sampler variable.
  29204. * @param postProcess Post process to get the output texture from.
  29205. */
  29206. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29207. /** @hidden */
  29208. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29209. /** @hidden */
  29210. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29211. /** @hidden */
  29212. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29213. /** @hidden */
  29214. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29215. /**
  29216. * Binds a buffer to a uniform.
  29217. * @param buffer Buffer to bind.
  29218. * @param name Name of the uniform variable to bind to.
  29219. */
  29220. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29221. /**
  29222. * Binds block to a uniform.
  29223. * @param blockName Name of the block to bind.
  29224. * @param index Index to bind.
  29225. */
  29226. bindUniformBlock(blockName: string, index: number): void;
  29227. /**
  29228. * Sets an interger value on a uniform variable.
  29229. * @param uniformName Name of the variable.
  29230. * @param value Value to be set.
  29231. * @returns this effect.
  29232. */
  29233. setInt(uniformName: string, value: number): Effect;
  29234. /**
  29235. * Sets an int array on a uniform variable.
  29236. * @param uniformName Name of the variable.
  29237. * @param array array to be set.
  29238. * @returns this effect.
  29239. */
  29240. setIntArray(uniformName: string, array: Int32Array): Effect;
  29241. /**
  29242. * 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)
  29243. * @param uniformName Name of the variable.
  29244. * @param array array to be set.
  29245. * @returns this effect.
  29246. */
  29247. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29248. /**
  29249. * 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)
  29250. * @param uniformName Name of the variable.
  29251. * @param array array to be set.
  29252. * @returns this effect.
  29253. */
  29254. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29255. /**
  29256. * 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)
  29257. * @param uniformName Name of the variable.
  29258. * @param array array to be set.
  29259. * @returns this effect.
  29260. */
  29261. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29262. /**
  29263. * Sets an float array on a uniform variable.
  29264. * @param uniformName Name of the variable.
  29265. * @param array array to be set.
  29266. * @returns this effect.
  29267. */
  29268. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29269. /**
  29270. * 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)
  29271. * @param uniformName Name of the variable.
  29272. * @param array array to be set.
  29273. * @returns this effect.
  29274. */
  29275. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29276. /**
  29277. * 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)
  29278. * @param uniformName Name of the variable.
  29279. * @param array array to be set.
  29280. * @returns this effect.
  29281. */
  29282. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29283. /**
  29284. * 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)
  29285. * @param uniformName Name of the variable.
  29286. * @param array array to be set.
  29287. * @returns this effect.
  29288. */
  29289. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29290. /**
  29291. * Sets an array on a uniform variable.
  29292. * @param uniformName Name of the variable.
  29293. * @param array array to be set.
  29294. * @returns this effect.
  29295. */
  29296. setArray(uniformName: string, array: number[]): Effect;
  29297. /**
  29298. * 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)
  29299. * @param uniformName Name of the variable.
  29300. * @param array array to be set.
  29301. * @returns this effect.
  29302. */
  29303. setArray2(uniformName: string, array: number[]): Effect;
  29304. /**
  29305. * 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)
  29306. * @param uniformName Name of the variable.
  29307. * @param array array to be set.
  29308. * @returns this effect.
  29309. */
  29310. setArray3(uniformName: string, array: number[]): Effect;
  29311. /**
  29312. * 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)
  29313. * @param uniformName Name of the variable.
  29314. * @param array array to be set.
  29315. * @returns this effect.
  29316. */
  29317. setArray4(uniformName: string, array: number[]): Effect;
  29318. /**
  29319. * Sets matrices on a uniform variable.
  29320. * @param uniformName Name of the variable.
  29321. * @param matrices matrices to be set.
  29322. * @returns this effect.
  29323. */
  29324. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29325. /**
  29326. * Sets matrix on a uniform variable.
  29327. * @param uniformName Name of the variable.
  29328. * @param matrix matrix to be set.
  29329. * @returns this effect.
  29330. */
  29331. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29332. /**
  29333. * 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)
  29334. * @param uniformName Name of the variable.
  29335. * @param matrix matrix to be set.
  29336. * @returns this effect.
  29337. */
  29338. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29339. /**
  29340. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29341. * @param uniformName Name of the variable.
  29342. * @param matrix matrix to be set.
  29343. * @returns this effect.
  29344. */
  29345. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29346. /**
  29347. * Sets a float on a uniform variable.
  29348. * @param uniformName Name of the variable.
  29349. * @param value value to be set.
  29350. * @returns this effect.
  29351. */
  29352. setFloat(uniformName: string, value: number): Effect;
  29353. /**
  29354. * Sets a boolean on a uniform variable.
  29355. * @param uniformName Name of the variable.
  29356. * @param bool value to be set.
  29357. * @returns this effect.
  29358. */
  29359. setBool(uniformName: string, bool: boolean): Effect;
  29360. /**
  29361. * Sets a Vector2 on a uniform variable.
  29362. * @param uniformName Name of the variable.
  29363. * @param vector2 vector2 to be set.
  29364. * @returns this effect.
  29365. */
  29366. setVector2(uniformName: string, vector2: Vector2): Effect;
  29367. /**
  29368. * Sets a float2 on a uniform variable.
  29369. * @param uniformName Name of the variable.
  29370. * @param x First float in float2.
  29371. * @param y Second float in float2.
  29372. * @returns this effect.
  29373. */
  29374. setFloat2(uniformName: string, x: number, y: number): Effect;
  29375. /**
  29376. * Sets a Vector3 on a uniform variable.
  29377. * @param uniformName Name of the variable.
  29378. * @param vector3 Value to be set.
  29379. * @returns this effect.
  29380. */
  29381. setVector3(uniformName: string, vector3: Vector3): Effect;
  29382. /**
  29383. * Sets a float3 on a uniform variable.
  29384. * @param uniformName Name of the variable.
  29385. * @param x First float in float3.
  29386. * @param y Second float in float3.
  29387. * @param z Third float in float3.
  29388. * @returns this effect.
  29389. */
  29390. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29391. /**
  29392. * Sets a Vector4 on a uniform variable.
  29393. * @param uniformName Name of the variable.
  29394. * @param vector4 Value to be set.
  29395. * @returns this effect.
  29396. */
  29397. setVector4(uniformName: string, vector4: Vector4): Effect;
  29398. /**
  29399. * Sets a float4 on a uniform variable.
  29400. * @param uniformName Name of the variable.
  29401. * @param x First float in float4.
  29402. * @param y Second float in float4.
  29403. * @param z Third float in float4.
  29404. * @param w Fourth float in float4.
  29405. * @returns this effect.
  29406. */
  29407. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29408. /**
  29409. * Sets a Color3 on a uniform variable.
  29410. * @param uniformName Name of the variable.
  29411. * @param color3 Value to be set.
  29412. * @returns this effect.
  29413. */
  29414. setColor3(uniformName: string, color3: Color3): Effect;
  29415. /**
  29416. * Sets a Color4 on a uniform variable.
  29417. * @param uniformName Name of the variable.
  29418. * @param color3 Value to be set.
  29419. * @param alpha Alpha value to be set.
  29420. * @returns this effect.
  29421. */
  29422. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29423. /**
  29424. * Sets a Color4 on a uniform variable
  29425. * @param uniformName defines the name of the variable
  29426. * @param color4 defines the value to be set
  29427. * @returns this effect.
  29428. */
  29429. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29430. /**
  29431. * This function will add a new shader to the shader store
  29432. * @param name the name of the shader
  29433. * @param pixelShader optional pixel shader content
  29434. * @param vertexShader optional vertex shader content
  29435. */
  29436. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29437. /**
  29438. * Store of each shader (The can be looked up using effect.key)
  29439. */
  29440. static ShadersStore: {
  29441. [key: string]: string;
  29442. };
  29443. /**
  29444. * Store of each included file for a shader (The can be looked up using effect.key)
  29445. */
  29446. static IncludesShadersStore: {
  29447. [key: string]: string;
  29448. };
  29449. /**
  29450. * Resets the cache of effects.
  29451. */
  29452. static ResetCache(): void;
  29453. }
  29454. }
  29455. declare module "babylonjs/Materials/colorCurves" {
  29456. import { Effect } from "babylonjs/Materials/effect";
  29457. /**
  29458. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29459. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29460. * 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;
  29461. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29462. */
  29463. export class ColorCurves {
  29464. private _dirty;
  29465. private _tempColor;
  29466. private _globalCurve;
  29467. private _highlightsCurve;
  29468. private _midtonesCurve;
  29469. private _shadowsCurve;
  29470. private _positiveCurve;
  29471. private _negativeCurve;
  29472. private _globalHue;
  29473. private _globalDensity;
  29474. private _globalSaturation;
  29475. private _globalExposure;
  29476. /**
  29477. * Gets the global Hue value.
  29478. * 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).
  29479. */
  29480. /**
  29481. * Sets the global Hue value.
  29482. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  29483. */
  29484. globalHue: number;
  29485. /**
  29486. * Gets the global Density value.
  29487. * 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.
  29488. * Values less than zero provide a filter of opposite hue.
  29489. */
  29490. /**
  29491. * Sets the global Density value.
  29492. * 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.
  29493. * Values less than zero provide a filter of opposite hue.
  29494. */
  29495. globalDensity: number;
  29496. /**
  29497. * Gets the global Saturation value.
  29498. * 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.
  29499. */
  29500. /**
  29501. * Sets the global Saturation value.
  29502. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29503. */
  29504. globalSaturation: number;
  29505. /**
  29506. * Gets the global Exposure value.
  29507. * 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.
  29508. */
  29509. /**
  29510. * Sets the global Exposure value.
  29511. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29512. */
  29513. globalExposure: number;
  29514. private _highlightsHue;
  29515. private _highlightsDensity;
  29516. private _highlightsSaturation;
  29517. private _highlightsExposure;
  29518. /**
  29519. * Gets the highlights Hue value.
  29520. * 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).
  29521. */
  29522. /**
  29523. * Sets the highlights Hue value.
  29524. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  29525. */
  29526. highlightsHue: number;
  29527. /**
  29528. * Gets the highlights Density value.
  29529. * 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.
  29530. * Values less than zero provide a filter of opposite hue.
  29531. */
  29532. /**
  29533. * Sets the highlights Density value.
  29534. * 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.
  29535. * Values less than zero provide a filter of opposite hue.
  29536. */
  29537. highlightsDensity: number;
  29538. /**
  29539. * Gets the highlights Saturation value.
  29540. * 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.
  29541. */
  29542. /**
  29543. * Sets the highlights Saturation value.
  29544. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29545. */
  29546. highlightsSaturation: number;
  29547. /**
  29548. * Gets the highlights Exposure value.
  29549. * 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.
  29550. */
  29551. /**
  29552. * Sets the highlights Exposure value.
  29553. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29554. */
  29555. highlightsExposure: number;
  29556. private _midtonesHue;
  29557. private _midtonesDensity;
  29558. private _midtonesSaturation;
  29559. private _midtonesExposure;
  29560. /**
  29561. * Gets the midtones Hue value.
  29562. * 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).
  29563. */
  29564. /**
  29565. * Sets the midtones Hue value.
  29566. * 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).
  29567. */
  29568. midtonesHue: number;
  29569. /**
  29570. * Gets the midtones Density value.
  29571. * 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.
  29572. * Values less than zero provide a filter of opposite hue.
  29573. */
  29574. /**
  29575. * Sets the midtones Density value.
  29576. * 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.
  29577. * Values less than zero provide a filter of opposite hue.
  29578. */
  29579. midtonesDensity: number;
  29580. /**
  29581. * Gets the midtones Saturation value.
  29582. * 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.
  29583. */
  29584. /**
  29585. * Sets the midtones Saturation value.
  29586. * 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.
  29587. */
  29588. midtonesSaturation: number;
  29589. /**
  29590. * Gets the midtones Exposure value.
  29591. * 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.
  29592. */
  29593. /**
  29594. * Sets the midtones Exposure value.
  29595. * 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.
  29596. */
  29597. midtonesExposure: number;
  29598. private _shadowsHue;
  29599. private _shadowsDensity;
  29600. private _shadowsSaturation;
  29601. private _shadowsExposure;
  29602. /**
  29603. * Gets the shadows Hue value.
  29604. * 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).
  29605. */
  29606. /**
  29607. * Sets the shadows Hue value.
  29608. * 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).
  29609. */
  29610. shadowsHue: number;
  29611. /**
  29612. * Gets the shadows Density value.
  29613. * 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.
  29614. * Values less than zero provide a filter of opposite hue.
  29615. */
  29616. /**
  29617. * Sets the shadows Density value.
  29618. * 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.
  29619. * Values less than zero provide a filter of opposite hue.
  29620. */
  29621. shadowsDensity: number;
  29622. /**
  29623. * Gets the shadows Saturation value.
  29624. * 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.
  29625. */
  29626. /**
  29627. * Sets the shadows Saturation value.
  29628. * 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.
  29629. */
  29630. shadowsSaturation: number;
  29631. /**
  29632. * Gets the shadows Exposure value.
  29633. * 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.
  29634. */
  29635. /**
  29636. * Sets the shadows Exposure value.
  29637. * 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.
  29638. */
  29639. shadowsExposure: number;
  29640. /**
  29641. * Returns the class name
  29642. * @returns The class name
  29643. */
  29644. getClassName(): string;
  29645. /**
  29646. * Binds the color curves to the shader.
  29647. * @param colorCurves The color curve to bind
  29648. * @param effect The effect to bind to
  29649. * @param positiveUniform The positive uniform shader parameter
  29650. * @param neutralUniform The neutral uniform shader parameter
  29651. * @param negativeUniform The negative uniform shader parameter
  29652. */
  29653. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29654. /**
  29655. * Prepare the list of uniforms associated with the ColorCurves effects.
  29656. * @param uniformsList The list of uniforms used in the effect
  29657. */
  29658. static PrepareUniforms(uniformsList: string[]): void;
  29659. /**
  29660. * Returns color grading data based on a hue, density, saturation and exposure value.
  29661. * @param filterHue The hue of the color filter.
  29662. * @param filterDensity The density of the color filter.
  29663. * @param saturation The saturation.
  29664. * @param exposure The exposure.
  29665. * @param result The result data container.
  29666. */
  29667. private getColorGradingDataToRef;
  29668. /**
  29669. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29670. * @param value The input slider value in range [-100,100].
  29671. * @returns Adjusted value.
  29672. */
  29673. private static applyColorGradingSliderNonlinear;
  29674. /**
  29675. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29676. * @param hue The hue (H) input.
  29677. * @param saturation The saturation (S) input.
  29678. * @param brightness The brightness (B) input.
  29679. * @result An RGBA color represented as Vector4.
  29680. */
  29681. private static fromHSBToRef;
  29682. /**
  29683. * Returns a value clamped between min and max
  29684. * @param value The value to clamp
  29685. * @param min The minimum of value
  29686. * @param max The maximum of value
  29687. * @returns The clamped value.
  29688. */
  29689. private static clamp;
  29690. /**
  29691. * Clones the current color curve instance.
  29692. * @return The cloned curves
  29693. */
  29694. clone(): ColorCurves;
  29695. /**
  29696. * Serializes the current color curve instance to a json representation.
  29697. * @return a JSON representation
  29698. */
  29699. serialize(): any;
  29700. /**
  29701. * Parses the color curve from a json representation.
  29702. * @param source the JSON source to parse
  29703. * @return The parsed curves
  29704. */
  29705. static Parse(source: any): ColorCurves;
  29706. }
  29707. }
  29708. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29709. import { Observable } from "babylonjs/Misc/observable";
  29710. import { Nullable } from "babylonjs/types";
  29711. import { Color4 } from "babylonjs/Maths/math";
  29712. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29713. import { Effect } from "babylonjs/Materials/effect";
  29714. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29715. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29716. /**
  29717. * Interface to follow in your material defines to integrate easily the
  29718. * Image proccessing functions.
  29719. * @hidden
  29720. */
  29721. export interface IImageProcessingConfigurationDefines {
  29722. IMAGEPROCESSING: boolean;
  29723. VIGNETTE: boolean;
  29724. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29725. VIGNETTEBLENDMODEOPAQUE: boolean;
  29726. TONEMAPPING: boolean;
  29727. TONEMAPPING_ACES: boolean;
  29728. CONTRAST: boolean;
  29729. EXPOSURE: boolean;
  29730. COLORCURVES: boolean;
  29731. COLORGRADING: boolean;
  29732. COLORGRADING3D: boolean;
  29733. SAMPLER3DGREENDEPTH: boolean;
  29734. SAMPLER3DBGRMAP: boolean;
  29735. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29736. }
  29737. /**
  29738. * @hidden
  29739. */
  29740. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29741. IMAGEPROCESSING: boolean;
  29742. VIGNETTE: boolean;
  29743. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29744. VIGNETTEBLENDMODEOPAQUE: boolean;
  29745. TONEMAPPING: boolean;
  29746. TONEMAPPING_ACES: boolean;
  29747. CONTRAST: boolean;
  29748. COLORCURVES: boolean;
  29749. COLORGRADING: boolean;
  29750. COLORGRADING3D: boolean;
  29751. SAMPLER3DGREENDEPTH: boolean;
  29752. SAMPLER3DBGRMAP: boolean;
  29753. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29754. EXPOSURE: boolean;
  29755. constructor();
  29756. }
  29757. /**
  29758. * This groups together the common properties used for image processing either in direct forward pass
  29759. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29760. * or not.
  29761. */
  29762. export class ImageProcessingConfiguration {
  29763. /**
  29764. * Default tone mapping applied in BabylonJS.
  29765. */
  29766. static readonly TONEMAPPING_STANDARD: number;
  29767. /**
  29768. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29769. * to other engines rendering to increase portability.
  29770. */
  29771. static readonly TONEMAPPING_ACES: number;
  29772. /**
  29773. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29774. */
  29775. colorCurves: Nullable<ColorCurves>;
  29776. private _colorCurvesEnabled;
  29777. /**
  29778. * Gets wether the color curves effect is enabled.
  29779. */
  29780. /**
  29781. * Sets wether the color curves effect is enabled.
  29782. */
  29783. colorCurvesEnabled: boolean;
  29784. private _colorGradingTexture;
  29785. /**
  29786. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29787. */
  29788. /**
  29789. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29790. */
  29791. colorGradingTexture: Nullable<BaseTexture>;
  29792. private _colorGradingEnabled;
  29793. /**
  29794. * Gets wether the color grading effect is enabled.
  29795. */
  29796. /**
  29797. * Sets wether the color grading effect is enabled.
  29798. */
  29799. colorGradingEnabled: boolean;
  29800. private _colorGradingWithGreenDepth;
  29801. /**
  29802. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29803. */
  29804. /**
  29805. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29806. */
  29807. colorGradingWithGreenDepth: boolean;
  29808. private _colorGradingBGR;
  29809. /**
  29810. * Gets wether the color grading texture contains BGR values.
  29811. */
  29812. /**
  29813. * Sets wether the color grading texture contains BGR values.
  29814. */
  29815. colorGradingBGR: boolean;
  29816. /** @hidden */
  29817. _exposure: number;
  29818. /**
  29819. * Gets the Exposure used in the effect.
  29820. */
  29821. /**
  29822. * Sets the Exposure used in the effect.
  29823. */
  29824. exposure: number;
  29825. private _toneMappingEnabled;
  29826. /**
  29827. * Gets wether the tone mapping effect is enabled.
  29828. */
  29829. /**
  29830. * Sets wether the tone mapping effect is enabled.
  29831. */
  29832. toneMappingEnabled: boolean;
  29833. private _toneMappingType;
  29834. /**
  29835. * Gets the type of tone mapping effect.
  29836. */
  29837. /**
  29838. * Sets the type of tone mapping effect used in BabylonJS.
  29839. */
  29840. toneMappingType: number;
  29841. protected _contrast: number;
  29842. /**
  29843. * Gets the contrast used in the effect.
  29844. */
  29845. /**
  29846. * Sets the contrast used in the effect.
  29847. */
  29848. contrast: number;
  29849. /**
  29850. * Vignette stretch size.
  29851. */
  29852. vignetteStretch: number;
  29853. /**
  29854. * Vignette centre X Offset.
  29855. */
  29856. vignetteCentreX: number;
  29857. /**
  29858. * Vignette centre Y Offset.
  29859. */
  29860. vignetteCentreY: number;
  29861. /**
  29862. * Vignette weight or intensity of the vignette effect.
  29863. */
  29864. vignetteWeight: number;
  29865. /**
  29866. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29867. * if vignetteEnabled is set to true.
  29868. */
  29869. vignetteColor: Color4;
  29870. /**
  29871. * Camera field of view used by the Vignette effect.
  29872. */
  29873. vignetteCameraFov: number;
  29874. private _vignetteBlendMode;
  29875. /**
  29876. * Gets the vignette blend mode allowing different kind of effect.
  29877. */
  29878. /**
  29879. * Sets the vignette blend mode allowing different kind of effect.
  29880. */
  29881. vignetteBlendMode: number;
  29882. private _vignetteEnabled;
  29883. /**
  29884. * Gets wether the vignette effect is enabled.
  29885. */
  29886. /**
  29887. * Sets wether the vignette effect is enabled.
  29888. */
  29889. vignetteEnabled: boolean;
  29890. private _applyByPostProcess;
  29891. /**
  29892. * Gets wether the image processing is applied through a post process or not.
  29893. */
  29894. /**
  29895. * Sets wether the image processing is applied through a post process or not.
  29896. */
  29897. applyByPostProcess: boolean;
  29898. private _isEnabled;
  29899. /**
  29900. * Gets wether the image processing is enabled or not.
  29901. */
  29902. /**
  29903. * Sets wether the image processing is enabled or not.
  29904. */
  29905. isEnabled: boolean;
  29906. /**
  29907. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29908. */
  29909. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29910. /**
  29911. * Method called each time the image processing information changes requires to recompile the effect.
  29912. */
  29913. protected _updateParameters(): void;
  29914. /**
  29915. * Gets the current class name.
  29916. * @return "ImageProcessingConfiguration"
  29917. */
  29918. getClassName(): string;
  29919. /**
  29920. * Prepare the list of uniforms associated with the Image Processing effects.
  29921. * @param uniforms The list of uniforms used in the effect
  29922. * @param defines the list of defines currently in use
  29923. */
  29924. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29925. /**
  29926. * Prepare the list of samplers associated with the Image Processing effects.
  29927. * @param samplersList The list of uniforms used in the effect
  29928. * @param defines the list of defines currently in use
  29929. */
  29930. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29931. /**
  29932. * Prepare the list of defines associated to the shader.
  29933. * @param defines the list of defines to complete
  29934. * @param forPostProcess Define if we are currently in post process mode or not
  29935. */
  29936. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29937. /**
  29938. * Returns true if all the image processing information are ready.
  29939. * @returns True if ready, otherwise, false
  29940. */
  29941. isReady(): boolean;
  29942. /**
  29943. * Binds the image processing to the shader.
  29944. * @param effect The effect to bind to
  29945. * @param aspectRatio Define the current aspect ratio of the effect
  29946. */
  29947. bind(effect: Effect, aspectRatio?: number): void;
  29948. /**
  29949. * Clones the current image processing instance.
  29950. * @return The cloned image processing
  29951. */
  29952. clone(): ImageProcessingConfiguration;
  29953. /**
  29954. * Serializes the current image processing instance to a json representation.
  29955. * @return a JSON representation
  29956. */
  29957. serialize(): any;
  29958. /**
  29959. * Parses the image processing from a json representation.
  29960. * @param source the JSON source to parse
  29961. * @return The parsed image processing
  29962. */
  29963. static Parse(source: any): ImageProcessingConfiguration;
  29964. private static _VIGNETTEMODE_MULTIPLY;
  29965. private static _VIGNETTEMODE_OPAQUE;
  29966. /**
  29967. * Used to apply the vignette as a mix with the pixel color.
  29968. */
  29969. static readonly VIGNETTEMODE_MULTIPLY: number;
  29970. /**
  29971. * Used to apply the vignette as a replacement of the pixel color.
  29972. */
  29973. static readonly VIGNETTEMODE_OPAQUE: number;
  29974. }
  29975. }
  29976. declare module "babylonjs/Materials/fresnelParameters" {
  29977. import { Color3 } from "babylonjs/Maths/math";
  29978. /**
  29979. * This represents all the required information to add a fresnel effect on a material:
  29980. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29981. */
  29982. export class FresnelParameters {
  29983. private _isEnabled;
  29984. /**
  29985. * Define if the fresnel effect is enable or not.
  29986. */
  29987. isEnabled: boolean;
  29988. /**
  29989. * Define the color used on edges (grazing angle)
  29990. */
  29991. leftColor: Color3;
  29992. /**
  29993. * Define the color used on center
  29994. */
  29995. rightColor: Color3;
  29996. /**
  29997. * Define bias applied to computed fresnel term
  29998. */
  29999. bias: number;
  30000. /**
  30001. * Defined the power exponent applied to fresnel term
  30002. */
  30003. power: number;
  30004. /**
  30005. * Clones the current fresnel and its valuues
  30006. * @returns a clone fresnel configuration
  30007. */
  30008. clone(): FresnelParameters;
  30009. /**
  30010. * Serializes the current fresnel parameters to a JSON representation.
  30011. * @return the JSON serialization
  30012. */
  30013. serialize(): any;
  30014. /**
  30015. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30016. * @param parsedFresnelParameters Define the JSON representation
  30017. * @returns the parsed parameters
  30018. */
  30019. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30020. }
  30021. }
  30022. declare module "babylonjs/Misc/decorators" {
  30023. import { Nullable } from "babylonjs/types";
  30024. import { Scene } from "babylonjs/scene";
  30025. import { IAnimatable } from "babylonjs/Misc/tools";
  30026. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30027. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30028. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30029. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30030. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30031. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30032. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30033. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30034. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30035. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30036. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30037. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30038. /**
  30039. * Decorator used to define property that can be serialized as reference to a camera
  30040. * @param sourceName defines the name of the property to decorate
  30041. */
  30042. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30043. /**
  30044. * Class used to help serialization objects
  30045. */
  30046. export class SerializationHelper {
  30047. /** hidden */
  30048. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30049. /** hidden */
  30050. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30051. /** hidden */
  30052. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30053. /** hidden */
  30054. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30055. /**
  30056. * Appends the serialized animations from the source animations
  30057. * @param source Source containing the animations
  30058. * @param destination Target to store the animations
  30059. */
  30060. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30061. /**
  30062. * Static function used to serialized a specific entity
  30063. * @param entity defines the entity to serialize
  30064. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30065. * @returns a JSON compatible object representing the serialization of the entity
  30066. */
  30067. static Serialize<T>(entity: T, serializationObject?: any): any;
  30068. /**
  30069. * Creates a new entity from a serialization data object
  30070. * @param creationFunction defines a function used to instanciated the new entity
  30071. * @param source defines the source serialization data
  30072. * @param scene defines the hosting scene
  30073. * @param rootUrl defines the root url for resources
  30074. * @returns a new entity
  30075. */
  30076. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30077. /**
  30078. * Clones an object
  30079. * @param creationFunction defines the function used to instanciate the new object
  30080. * @param source defines the source object
  30081. * @returns the cloned object
  30082. */
  30083. static Clone<T>(creationFunction: () => T, source: T): T;
  30084. /**
  30085. * Instanciates a new object based on a source one (some data will be shared between both object)
  30086. * @param creationFunction defines the function used to instanciate the new object
  30087. * @param source defines the source object
  30088. * @returns the new object
  30089. */
  30090. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30091. }
  30092. }
  30093. declare module "babylonjs/Cameras/camera" {
  30094. import { SmartArray } from "babylonjs/Misc/smartArray";
  30095. import { Observable } from "babylonjs/Misc/observable";
  30096. import { Nullable } from "babylonjs/types";
  30097. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30098. import { Scene } from "babylonjs/scene";
  30099. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30100. import { Node } from "babylonjs/node";
  30101. import { Mesh } from "babylonjs/Meshes/mesh";
  30102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30103. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30104. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30106. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30107. import { Ray } from "babylonjs/Culling/ray";
  30108. /**
  30109. * This is the base class of all the camera used in the application.
  30110. * @see http://doc.babylonjs.com/features/cameras
  30111. */
  30112. export class Camera extends Node {
  30113. /** @hidden */
  30114. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30115. /**
  30116. * This is the default projection mode used by the cameras.
  30117. * It helps recreating a feeling of perspective and better appreciate depth.
  30118. * This is the best way to simulate real life cameras.
  30119. */
  30120. static readonly PERSPECTIVE_CAMERA: number;
  30121. /**
  30122. * This helps creating camera with an orthographic mode.
  30123. * 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.
  30124. */
  30125. static readonly ORTHOGRAPHIC_CAMERA: number;
  30126. /**
  30127. * This is the default FOV mode for perspective cameras.
  30128. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30129. */
  30130. static readonly FOVMODE_VERTICAL_FIXED: number;
  30131. /**
  30132. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30133. */
  30134. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30135. /**
  30136. * This specifies ther is no need for a camera rig.
  30137. * Basically only one eye is rendered corresponding to the camera.
  30138. */
  30139. static readonly RIG_MODE_NONE: number;
  30140. /**
  30141. * Simulates a camera Rig with one blue eye and one red eye.
  30142. * This can be use with 3d blue and red glasses.
  30143. */
  30144. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30145. /**
  30146. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30147. */
  30148. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30149. /**
  30150. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30151. */
  30152. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30153. /**
  30154. * Defines that both eyes of the camera will be rendered over under each other.
  30155. */
  30156. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30157. /**
  30158. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30159. */
  30160. static readonly RIG_MODE_VR: number;
  30161. /**
  30162. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30163. */
  30164. static readonly RIG_MODE_WEBVR: number;
  30165. /**
  30166. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30167. */
  30168. static readonly RIG_MODE_CUSTOM: number;
  30169. /**
  30170. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30171. */
  30172. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30173. /**
  30174. * @hidden
  30175. * Might be removed once multiview will be a thing
  30176. */
  30177. static UseAlternateWebVRRendering: boolean;
  30178. /**
  30179. * Define the input manager associated with the camera.
  30180. */
  30181. inputs: CameraInputsManager<Camera>;
  30182. /** @hidden */
  30183. _position: Vector3;
  30184. /**
  30185. * Define the current local position of the camera in the scene
  30186. */
  30187. position: Vector3;
  30188. /**
  30189. * The vector the camera should consider as up.
  30190. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30191. */
  30192. upVector: Vector3;
  30193. /**
  30194. * Define the current limit on the left side for an orthographic camera
  30195. * In scene unit
  30196. */
  30197. orthoLeft: Nullable<number>;
  30198. /**
  30199. * Define the current limit on the right side for an orthographic camera
  30200. * In scene unit
  30201. */
  30202. orthoRight: Nullable<number>;
  30203. /**
  30204. * Define the current limit on the bottom side for an orthographic camera
  30205. * In scene unit
  30206. */
  30207. orthoBottom: Nullable<number>;
  30208. /**
  30209. * Define the current limit on the top side for an orthographic camera
  30210. * In scene unit
  30211. */
  30212. orthoTop: Nullable<number>;
  30213. /**
  30214. * Field Of View is set in Radians. (default is 0.8)
  30215. */
  30216. fov: number;
  30217. /**
  30218. * Define the minimum distance the camera can see from.
  30219. * This is important to note that the depth buffer are not infinite and the closer it starts
  30220. * the more your scene might encounter depth fighting issue.
  30221. */
  30222. minZ: number;
  30223. /**
  30224. * Define the maximum distance the camera can see to.
  30225. * This is important to note that the depth buffer are not infinite and the further it end
  30226. * the more your scene might encounter depth fighting issue.
  30227. */
  30228. maxZ: number;
  30229. /**
  30230. * Define the default inertia of the camera.
  30231. * This helps giving a smooth feeling to the camera movement.
  30232. */
  30233. inertia: number;
  30234. /**
  30235. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30236. */
  30237. mode: number;
  30238. /**
  30239. * Define wether the camera is intermediate.
  30240. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30241. */
  30242. isIntermediate: boolean;
  30243. /**
  30244. * Define the viewport of the camera.
  30245. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30246. */
  30247. viewport: Viewport;
  30248. /**
  30249. * Restricts the camera to viewing objects with the same layerMask.
  30250. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30251. */
  30252. layerMask: number;
  30253. /**
  30254. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30255. */
  30256. fovMode: number;
  30257. /**
  30258. * Rig mode of the camera.
  30259. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30260. * This is normally controlled byt the camera themselves as internal use.
  30261. */
  30262. cameraRigMode: number;
  30263. /**
  30264. * Defines the distance between both "eyes" in case of a RIG
  30265. */
  30266. interaxialDistance: number;
  30267. /**
  30268. * Defines if stereoscopic rendering is done side by side or over under.
  30269. */
  30270. isStereoscopicSideBySide: boolean;
  30271. /**
  30272. * 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
  30273. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30274. * else in the scene.
  30275. */
  30276. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30277. /**
  30278. * When set, the camera will render to this render target instead of the default canvas
  30279. */
  30280. outputRenderTarget: Nullable<RenderTargetTexture>;
  30281. /**
  30282. * Observable triggered when the camera view matrix has changed.
  30283. */
  30284. onViewMatrixChangedObservable: Observable<Camera>;
  30285. /**
  30286. * Observable triggered when the camera Projection matrix has changed.
  30287. */
  30288. onProjectionMatrixChangedObservable: Observable<Camera>;
  30289. /**
  30290. * Observable triggered when the inputs have been processed.
  30291. */
  30292. onAfterCheckInputsObservable: Observable<Camera>;
  30293. /**
  30294. * Observable triggered when reset has been called and applied to the camera.
  30295. */
  30296. onRestoreStateObservable: Observable<Camera>;
  30297. /** @hidden */
  30298. _cameraRigParams: any;
  30299. /** @hidden */
  30300. _rigCameras: Camera[];
  30301. /** @hidden */
  30302. _rigPostProcess: Nullable<PostProcess>;
  30303. protected _webvrViewMatrix: Matrix;
  30304. /** @hidden */
  30305. _skipRendering: boolean;
  30306. /** @hidden */
  30307. _alternateCamera: Camera;
  30308. /** @hidden */
  30309. _projectionMatrix: Matrix;
  30310. /** @hidden */
  30311. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30312. /** @hidden */
  30313. _activeMeshes: SmartArray<AbstractMesh>;
  30314. protected _globalPosition: Vector3;
  30315. /** hidden */
  30316. _computedViewMatrix: Matrix;
  30317. private _doNotComputeProjectionMatrix;
  30318. private _transformMatrix;
  30319. private _frustumPlanes;
  30320. private _refreshFrustumPlanes;
  30321. private _storedFov;
  30322. private _stateStored;
  30323. /**
  30324. * Instantiates a new camera object.
  30325. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30326. * @see http://doc.babylonjs.com/features/cameras
  30327. * @param name Defines the name of the camera in the scene
  30328. * @param position Defines the position of the camera
  30329. * @param scene Defines the scene the camera belongs too
  30330. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30331. */
  30332. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30333. /**
  30334. * Store current camera state (fov, position, etc..)
  30335. * @returns the camera
  30336. */
  30337. storeState(): Camera;
  30338. /**
  30339. * Restores the camera state values if it has been stored. You must call storeState() first
  30340. */
  30341. protected _restoreStateValues(): boolean;
  30342. /**
  30343. * Restored camera state. You must call storeState() first.
  30344. * @returns true if restored and false otherwise
  30345. */
  30346. restoreState(): boolean;
  30347. /**
  30348. * Gets the class name of the camera.
  30349. * @returns the class name
  30350. */
  30351. getClassName(): string;
  30352. /** @hidden */
  30353. readonly _isCamera: boolean;
  30354. /**
  30355. * Gets a string representation of the camera useful for debug purpose.
  30356. * @param fullDetails Defines that a more verboe level of logging is required
  30357. * @returns the string representation
  30358. */
  30359. toString(fullDetails?: boolean): string;
  30360. /**
  30361. * Gets the current world space position of the camera.
  30362. */
  30363. readonly globalPosition: Vector3;
  30364. /**
  30365. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30366. * @returns the active meshe list
  30367. */
  30368. getActiveMeshes(): SmartArray<AbstractMesh>;
  30369. /**
  30370. * Check wether a mesh is part of the current active mesh list of the camera
  30371. * @param mesh Defines the mesh to check
  30372. * @returns true if active, false otherwise
  30373. */
  30374. isActiveMesh(mesh: Mesh): boolean;
  30375. /**
  30376. * Is this camera ready to be used/rendered
  30377. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30378. * @return true if the camera is ready
  30379. */
  30380. isReady(completeCheck?: boolean): boolean;
  30381. /** @hidden */
  30382. _initCache(): void;
  30383. /** @hidden */
  30384. _updateCache(ignoreParentClass?: boolean): void;
  30385. /** @hidden */
  30386. _isSynchronized(): boolean;
  30387. /** @hidden */
  30388. _isSynchronizedViewMatrix(): boolean;
  30389. /** @hidden */
  30390. _isSynchronizedProjectionMatrix(): boolean;
  30391. /**
  30392. * Attach the input controls to a specific dom element to get the input from.
  30393. * @param element Defines the element the controls should be listened from
  30394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30395. */
  30396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30397. /**
  30398. * Detach the current controls from the specified dom element.
  30399. * @param element Defines the element to stop listening the inputs from
  30400. */
  30401. detachControl(element: HTMLElement): void;
  30402. /**
  30403. * Update the camera state according to the different inputs gathered during the frame.
  30404. */
  30405. update(): void;
  30406. /** @hidden */
  30407. _checkInputs(): void;
  30408. /** @hidden */
  30409. readonly rigCameras: Camera[];
  30410. /**
  30411. * Gets the post process used by the rig cameras
  30412. */
  30413. readonly rigPostProcess: Nullable<PostProcess>;
  30414. /**
  30415. * Internal, gets the first post proces.
  30416. * @returns the first post process to be run on this camera.
  30417. */
  30418. _getFirstPostProcess(): Nullable<PostProcess>;
  30419. private _cascadePostProcessesToRigCams;
  30420. /**
  30421. * Attach a post process to the camera.
  30422. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30423. * @param postProcess The post process to attach to the camera
  30424. * @param insertAt The position of the post process in case several of them are in use in the scene
  30425. * @returns the position the post process has been inserted at
  30426. */
  30427. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30428. /**
  30429. * Detach a post process to the camera.
  30430. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30431. * @param postProcess The post process to detach from the camera
  30432. */
  30433. detachPostProcess(postProcess: PostProcess): void;
  30434. /**
  30435. * Gets the current world matrix of the camera
  30436. */
  30437. getWorldMatrix(): Matrix;
  30438. /** @hidden */
  30439. _getViewMatrix(): Matrix;
  30440. /**
  30441. * Gets the current view matrix of the camera.
  30442. * @param force forces the camera to recompute the matrix without looking at the cached state
  30443. * @returns the view matrix
  30444. */
  30445. getViewMatrix(force?: boolean): Matrix;
  30446. /**
  30447. * Freeze the projection matrix.
  30448. * It will prevent the cache check of the camera projection compute and can speed up perf
  30449. * if no parameter of the camera are meant to change
  30450. * @param projection Defines manually a projection if necessary
  30451. */
  30452. freezeProjectionMatrix(projection?: Matrix): void;
  30453. /**
  30454. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30455. */
  30456. unfreezeProjectionMatrix(): void;
  30457. /**
  30458. * Gets the current projection matrix of the camera.
  30459. * @param force forces the camera to recompute the matrix without looking at the cached state
  30460. * @returns the projection matrix
  30461. */
  30462. getProjectionMatrix(force?: boolean): Matrix;
  30463. /**
  30464. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30465. * @returns a Matrix
  30466. */
  30467. getTransformationMatrix(): Matrix;
  30468. private _updateFrustumPlanes;
  30469. /**
  30470. * Checks if a cullable object (mesh...) is in the camera frustum
  30471. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30472. * @param target The object to check
  30473. * @returns true if the object is in frustum otherwise false
  30474. */
  30475. isInFrustum(target: ICullable): boolean;
  30476. /**
  30477. * Checks if a cullable object (mesh...) is in the camera frustum
  30478. * Unlike isInFrustum this cheks the full bounding box
  30479. * @param target The object to check
  30480. * @returns true if the object is in frustum otherwise false
  30481. */
  30482. isCompletelyInFrustum(target: ICullable): boolean;
  30483. /**
  30484. * Gets a ray in the forward direction from the camera.
  30485. * @param length Defines the length of the ray to create
  30486. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30487. * @param origin Defines the start point of the ray which defaults to the camera position
  30488. * @returns the forward ray
  30489. */
  30490. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30491. /**
  30492. * Releases resources associated with this node.
  30493. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30494. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30495. */
  30496. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30497. /** @hidden */
  30498. _isLeftCamera: boolean;
  30499. /**
  30500. * Gets the left camera of a rig setup in case of Rigged Camera
  30501. */
  30502. readonly isLeftCamera: boolean;
  30503. /** @hidden */
  30504. _isRightCamera: boolean;
  30505. /**
  30506. * Gets the right camera of a rig setup in case of Rigged Camera
  30507. */
  30508. readonly isRightCamera: boolean;
  30509. /**
  30510. * Gets the left camera of a rig setup in case of Rigged Camera
  30511. */
  30512. readonly leftCamera: Nullable<FreeCamera>;
  30513. /**
  30514. * Gets the right camera of a rig setup in case of Rigged Camera
  30515. */
  30516. readonly rightCamera: Nullable<FreeCamera>;
  30517. /**
  30518. * Gets the left camera target of a rig setup in case of Rigged Camera
  30519. * @returns the target position
  30520. */
  30521. getLeftTarget(): Nullable<Vector3>;
  30522. /**
  30523. * Gets the right camera target of a rig setup in case of Rigged Camera
  30524. * @returns the target position
  30525. */
  30526. getRightTarget(): Nullable<Vector3>;
  30527. /**
  30528. * @hidden
  30529. */
  30530. setCameraRigMode(mode: number, rigParams: any): void;
  30531. /** @hidden */
  30532. static _setStereoscopicRigMode(camera: Camera): void;
  30533. /** @hidden */
  30534. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30535. /** @hidden */
  30536. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30537. /** @hidden */
  30538. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30539. /** @hidden */
  30540. _getVRProjectionMatrix(): Matrix;
  30541. protected _updateCameraRotationMatrix(): void;
  30542. protected _updateWebVRCameraRotationMatrix(): void;
  30543. /**
  30544. * This function MUST be overwritten by the different WebVR cameras available.
  30545. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30546. * @hidden
  30547. */
  30548. _getWebVRProjectionMatrix(): Matrix;
  30549. /**
  30550. * This function MUST be overwritten by the different WebVR cameras available.
  30551. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30552. * @hidden
  30553. */
  30554. _getWebVRViewMatrix(): Matrix;
  30555. /** @hidden */
  30556. setCameraRigParameter(name: string, value: any): void;
  30557. /**
  30558. * needs to be overridden by children so sub has required properties to be copied
  30559. * @hidden
  30560. */
  30561. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30562. /**
  30563. * May need to be overridden by children
  30564. * @hidden
  30565. */
  30566. _updateRigCameras(): void;
  30567. /** @hidden */
  30568. _setupInputs(): void;
  30569. /**
  30570. * Serialiaze the camera setup to a json represention
  30571. * @returns the JSON representation
  30572. */
  30573. serialize(): any;
  30574. /**
  30575. * Clones the current camera.
  30576. * @param name The cloned camera name
  30577. * @returns the cloned camera
  30578. */
  30579. clone(name: string): Camera;
  30580. /**
  30581. * Gets the direction of the camera relative to a given local axis.
  30582. * @param localAxis Defines the reference axis to provide a relative direction.
  30583. * @return the direction
  30584. */
  30585. getDirection(localAxis: Vector3): Vector3;
  30586. /**
  30587. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30588. * @param localAxis Defines the reference axis to provide a relative direction.
  30589. * @param result Defines the vector to store the result in
  30590. */
  30591. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30592. /**
  30593. * Gets a camera constructor for a given camera type
  30594. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30595. * @param name The name of the camera the result will be able to instantiate
  30596. * @param scene The scene the result will construct the camera in
  30597. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30598. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30599. * @returns a factory method to construc the camera
  30600. */
  30601. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30602. /**
  30603. * Compute the world matrix of the camera.
  30604. * @returns the camera workd matrix
  30605. */
  30606. computeWorldMatrix(): Matrix;
  30607. /**
  30608. * Parse a JSON and creates the camera from the parsed information
  30609. * @param parsedCamera The JSON to parse
  30610. * @param scene The scene to instantiate the camera in
  30611. * @returns the newly constructed camera
  30612. */
  30613. static Parse(parsedCamera: any, scene: Scene): Camera;
  30614. }
  30615. }
  30616. declare module "babylonjs/Misc/tools" {
  30617. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30618. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30619. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30620. import { Observable } from "babylonjs/Misc/observable";
  30621. import { DomManagement } from "babylonjs/Misc/domManagement";
  30622. import { Camera } from "babylonjs/Cameras/camera";
  30623. import { Engine } from "babylonjs/Engines/engine";
  30624. import { Animation } from "babylonjs/Animations/animation";
  30625. /**
  30626. * Interface for any object that can request an animation frame
  30627. */
  30628. export interface ICustomAnimationFrameRequester {
  30629. /**
  30630. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30631. */
  30632. renderFunction?: Function;
  30633. /**
  30634. * Called to request the next frame to render to
  30635. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30636. */
  30637. requestAnimationFrame: Function;
  30638. /**
  30639. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30640. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30641. */
  30642. requestID?: number;
  30643. }
  30644. /**
  30645. * Interface containing an array of animations
  30646. */
  30647. export interface IAnimatable {
  30648. /**
  30649. * Array of animations
  30650. */
  30651. animations: Array<Animation>;
  30652. }
  30653. /** Interface used by value gradients (color, factor, ...) */
  30654. export interface IValueGradient {
  30655. /**
  30656. * Gets or sets the gradient value (between 0 and 1)
  30657. */
  30658. gradient: number;
  30659. }
  30660. /** Class used to store color4 gradient */
  30661. export class ColorGradient implements IValueGradient {
  30662. /**
  30663. * Gets or sets the gradient value (between 0 and 1)
  30664. */
  30665. gradient: number;
  30666. /**
  30667. * Gets or sets first associated color
  30668. */
  30669. color1: Color4;
  30670. /**
  30671. * Gets or sets second associated color
  30672. */
  30673. color2?: Color4;
  30674. /**
  30675. * Will get a color picked randomly between color1 and color2.
  30676. * If color2 is undefined then color1 will be used
  30677. * @param result defines the target Color4 to store the result in
  30678. */
  30679. getColorToRef(result: Color4): void;
  30680. }
  30681. /** Class used to store color 3 gradient */
  30682. export class Color3Gradient implements IValueGradient {
  30683. /**
  30684. * Gets or sets the gradient value (between 0 and 1)
  30685. */
  30686. gradient: number;
  30687. /**
  30688. * Gets or sets the associated color
  30689. */
  30690. color: Color3;
  30691. }
  30692. /** Class used to store factor gradient */
  30693. export class FactorGradient implements IValueGradient {
  30694. /**
  30695. * Gets or sets the gradient value (between 0 and 1)
  30696. */
  30697. gradient: number;
  30698. /**
  30699. * Gets or sets first associated factor
  30700. */
  30701. factor1: number;
  30702. /**
  30703. * Gets or sets second associated factor
  30704. */
  30705. factor2?: number;
  30706. /**
  30707. * Will get a number picked randomly between factor1 and factor2.
  30708. * If factor2 is undefined then factor1 will be used
  30709. * @returns the picked number
  30710. */
  30711. getFactor(): number;
  30712. }
  30713. /**
  30714. * @ignore
  30715. * Application error to support additional information when loading a file
  30716. */
  30717. export class LoadFileError extends Error {
  30718. /** defines the optional XHR request */
  30719. request?: XMLHttpRequest | undefined;
  30720. private static _setPrototypeOf;
  30721. /**
  30722. * Creates a new LoadFileError
  30723. * @param message defines the message of the error
  30724. * @param request defines the optional XHR request
  30725. */
  30726. constructor(message: string,
  30727. /** defines the optional XHR request */
  30728. request?: XMLHttpRequest | undefined);
  30729. }
  30730. /**
  30731. * Class used to define a retry strategy when error happens while loading assets
  30732. */
  30733. export class RetryStrategy {
  30734. /**
  30735. * Function used to defines an exponential back off strategy
  30736. * @param maxRetries defines the maximum number of retries (3 by default)
  30737. * @param baseInterval defines the interval between retries
  30738. * @returns the strategy function to use
  30739. */
  30740. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30741. }
  30742. /**
  30743. * File request interface
  30744. */
  30745. export interface IFileRequest {
  30746. /**
  30747. * Raised when the request is complete (success or error).
  30748. */
  30749. onCompleteObservable: Observable<IFileRequest>;
  30750. /**
  30751. * Aborts the request for a file.
  30752. */
  30753. abort: () => void;
  30754. }
  30755. /**
  30756. * Class containing a set of static utilities functions
  30757. */
  30758. export class Tools {
  30759. /**
  30760. * Gets or sets the base URL to use to load assets
  30761. */
  30762. static BaseUrl: string;
  30763. /**
  30764. * Enable/Disable Custom HTTP Request Headers globally.
  30765. * default = false
  30766. * @see CustomRequestHeaders
  30767. */
  30768. static UseCustomRequestHeaders: boolean;
  30769. /**
  30770. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30771. * i.e. when loading files, where the server/service expects an Authorization header.
  30772. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30773. */
  30774. static CustomRequestHeaders: {
  30775. [key: string]: string;
  30776. };
  30777. /**
  30778. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30779. */
  30780. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30781. /**
  30782. * Default behaviour for cors in the application.
  30783. * It can be a string if the expected behavior is identical in the entire app.
  30784. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30785. */
  30786. static CorsBehavior: string | ((url: string | string[]) => string);
  30787. /**
  30788. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30789. * @ignorenaming
  30790. */
  30791. static UseFallbackTexture: boolean;
  30792. /**
  30793. * Use this object to register external classes like custom textures or material
  30794. * to allow the laoders to instantiate them
  30795. */
  30796. static RegisteredExternalClasses: {
  30797. [key: string]: Object;
  30798. };
  30799. /**
  30800. * Texture content used if a texture cannot loaded
  30801. * @ignorenaming
  30802. */
  30803. static fallbackTexture: string;
  30804. /**
  30805. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30806. * @param u defines the coordinate on X axis
  30807. * @param v defines the coordinate on Y axis
  30808. * @param width defines the width of the source data
  30809. * @param height defines the height of the source data
  30810. * @param pixels defines the source byte array
  30811. * @param color defines the output color
  30812. */
  30813. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30814. /**
  30815. * Interpolates between a and b via alpha
  30816. * @param a The lower value (returned when alpha = 0)
  30817. * @param b The upper value (returned when alpha = 1)
  30818. * @param alpha The interpolation-factor
  30819. * @return The mixed value
  30820. */
  30821. static Mix(a: number, b: number, alpha: number): number;
  30822. /**
  30823. * Tries to instantiate a new object from a given class name
  30824. * @param className defines the class name to instantiate
  30825. * @returns the new object or null if the system was not able to do the instantiation
  30826. */
  30827. static Instantiate(className: string): any;
  30828. /**
  30829. * Provides a slice function that will work even on IE
  30830. * @param data defines the array to slice
  30831. * @param start defines the start of the data (optional)
  30832. * @param end defines the end of the data (optional)
  30833. * @returns the new sliced array
  30834. */
  30835. static Slice<T>(data: T, start?: number, end?: number): T;
  30836. /**
  30837. * Polyfill for setImmediate
  30838. * @param action defines the action to execute after the current execution block
  30839. */
  30840. static SetImmediate(action: () => void): void;
  30841. /**
  30842. * Function indicating if a number is an exponent of 2
  30843. * @param value defines the value to test
  30844. * @returns true if the value is an exponent of 2
  30845. */
  30846. static IsExponentOfTwo(value: number): boolean;
  30847. private static _tmpFloatArray;
  30848. /**
  30849. * Returns the nearest 32-bit single precision float representation of a Number
  30850. * @param value A Number. If the parameter is of a different type, it will get converted
  30851. * to a number or to NaN if it cannot be converted
  30852. * @returns number
  30853. */
  30854. static FloatRound(value: number): number;
  30855. /**
  30856. * Find the next highest power of two.
  30857. * @param x Number to start search from.
  30858. * @return Next highest power of two.
  30859. */
  30860. static CeilingPOT(x: number): number;
  30861. /**
  30862. * Find the next lowest power of two.
  30863. * @param x Number to start search from.
  30864. * @return Next lowest power of two.
  30865. */
  30866. static FloorPOT(x: number): number;
  30867. /**
  30868. * Find the nearest power of two.
  30869. * @param x Number to start search from.
  30870. * @return Next nearest power of two.
  30871. */
  30872. static NearestPOT(x: number): number;
  30873. /**
  30874. * Get the closest exponent of two
  30875. * @param value defines the value to approximate
  30876. * @param max defines the maximum value to return
  30877. * @param mode defines how to define the closest value
  30878. * @returns closest exponent of two of the given value
  30879. */
  30880. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30881. /**
  30882. * Extracts the filename from a path
  30883. * @param path defines the path to use
  30884. * @returns the filename
  30885. */
  30886. static GetFilename(path: string): string;
  30887. /**
  30888. * Extracts the "folder" part of a path (everything before the filename).
  30889. * @param uri The URI to extract the info from
  30890. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30891. * @returns The "folder" part of the path
  30892. */
  30893. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30894. /**
  30895. * Extracts text content from a DOM element hierarchy
  30896. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30897. */
  30898. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30899. /**
  30900. * Convert an angle in radians to degrees
  30901. * @param angle defines the angle to convert
  30902. * @returns the angle in degrees
  30903. */
  30904. static ToDegrees(angle: number): number;
  30905. /**
  30906. * Convert an angle in degrees to radians
  30907. * @param angle defines the angle to convert
  30908. * @returns the angle in radians
  30909. */
  30910. static ToRadians(angle: number): number;
  30911. /**
  30912. * Encode a buffer to a base64 string
  30913. * @param buffer defines the buffer to encode
  30914. * @returns the encoded string
  30915. */
  30916. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30917. /**
  30918. * Extracts minimum and maximum values from a list of indexed positions
  30919. * @param positions defines the positions to use
  30920. * @param indices defines the indices to the positions
  30921. * @param indexStart defines the start index
  30922. * @param indexCount defines the end index
  30923. * @param bias defines bias value to add to the result
  30924. * @return minimum and maximum values
  30925. */
  30926. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30927. minimum: Vector3;
  30928. maximum: Vector3;
  30929. };
  30930. /**
  30931. * Extracts minimum and maximum values from a list of positions
  30932. * @param positions defines the positions to use
  30933. * @param start defines the start index in the positions array
  30934. * @param count defines the number of positions to handle
  30935. * @param bias defines bias value to add to the result
  30936. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30937. * @return minimum and maximum values
  30938. */
  30939. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30940. minimum: Vector3;
  30941. maximum: Vector3;
  30942. };
  30943. /**
  30944. * Returns an array if obj is not an array
  30945. * @param obj defines the object to evaluate as an array
  30946. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30947. * @returns either obj directly if obj is an array or a new array containing obj
  30948. */
  30949. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30950. /**
  30951. * Gets the pointer prefix to use
  30952. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30953. */
  30954. static GetPointerPrefix(): string;
  30955. /**
  30956. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30957. * @param func - the function to be called
  30958. * @param requester - the object that will request the next frame. Falls back to window.
  30959. * @returns frame number
  30960. */
  30961. static QueueNewFrame(func: () => void, requester?: any): number;
  30962. /**
  30963. * Ask the browser to promote the current element to fullscreen rendering mode
  30964. * @param element defines the DOM element to promote
  30965. */
  30966. static RequestFullscreen(element: HTMLElement): void;
  30967. /**
  30968. * Asks the browser to exit fullscreen mode
  30969. */
  30970. static ExitFullscreen(): void;
  30971. /**
  30972. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30973. * @param url define the url we are trying
  30974. * @param element define the dom element where to configure the cors policy
  30975. */
  30976. static SetCorsBehavior(url: string | string[], element: {
  30977. crossOrigin: string | null;
  30978. }): void;
  30979. /**
  30980. * Removes unwanted characters from an url
  30981. * @param url defines the url to clean
  30982. * @returns the cleaned url
  30983. */
  30984. static CleanUrl(url: string): string;
  30985. /**
  30986. * Gets or sets a function used to pre-process url before using them to load assets
  30987. */
  30988. static PreprocessUrl: (url: string) => string;
  30989. /**
  30990. * Loads an image as an HTMLImageElement.
  30991. * @param input url string, ArrayBuffer, or Blob to load
  30992. * @param onLoad callback called when the image successfully loads
  30993. * @param onError callback called when the image fails to load
  30994. * @param offlineProvider offline provider for caching
  30995. * @returns the HTMLImageElement of the loaded image
  30996. */
  30997. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30998. /**
  30999. * Loads a file
  31000. * @param url url string, ArrayBuffer, or Blob to load
  31001. * @param onSuccess callback called when the file successfully loads
  31002. * @param onProgress callback called while file is loading (if the server supports this mode)
  31003. * @param offlineProvider defines the offline provider for caching
  31004. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31005. * @param onError callback called when the file fails to load
  31006. * @returns a file request object
  31007. */
  31008. 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;
  31009. /**
  31010. * Load a script (identified by an url). When the url returns, the
  31011. * content of this file is added into a new script element, attached to the DOM (body element)
  31012. * @param scriptUrl defines the url of the script to laod
  31013. * @param onSuccess defines the callback called when the script is loaded
  31014. * @param onError defines the callback to call if an error occurs
  31015. */
  31016. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31017. /**
  31018. * Loads a file from a blob
  31019. * @param fileToLoad defines the blob to use
  31020. * @param callback defines the callback to call when data is loaded
  31021. * @param progressCallback defines the callback to call during loading process
  31022. * @returns a file request object
  31023. */
  31024. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31025. /**
  31026. * Loads a file
  31027. * @param fileToLoad defines the file to load
  31028. * @param callback defines the callback to call when data is loaded
  31029. * @param progressCallBack defines the callback to call during loading process
  31030. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31031. * @returns a file request object
  31032. */
  31033. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31034. /**
  31035. * Creates a data url from a given string content
  31036. * @param content defines the content to convert
  31037. * @returns the new data url link
  31038. */
  31039. static FileAsURL(content: string): string;
  31040. /**
  31041. * Format the given number to a specific decimal format
  31042. * @param value defines the number to format
  31043. * @param decimals defines the number of decimals to use
  31044. * @returns the formatted string
  31045. */
  31046. static Format(value: number, decimals?: number): string;
  31047. /**
  31048. * Checks if a given vector is inside a specific range
  31049. * @param v defines the vector to test
  31050. * @param min defines the minimum range
  31051. * @param max defines the maximum range
  31052. */
  31053. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31054. /**
  31055. * Tries to copy an object by duplicating every property
  31056. * @param source defines the source object
  31057. * @param destination defines the target object
  31058. * @param doNotCopyList defines a list of properties to avoid
  31059. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31060. */
  31061. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31062. /**
  31063. * Gets a boolean indicating if the given object has no own property
  31064. * @param obj defines the object to test
  31065. * @returns true if object has no own property
  31066. */
  31067. static IsEmpty(obj: any): boolean;
  31068. /**
  31069. * Function used to register events at window level
  31070. * @param events defines the events to register
  31071. */
  31072. static RegisterTopRootEvents(events: {
  31073. name: string;
  31074. handler: Nullable<(e: FocusEvent) => any>;
  31075. }[]): void;
  31076. /**
  31077. * Function used to unregister events from window level
  31078. * @param events defines the events to unregister
  31079. */
  31080. static UnregisterTopRootEvents(events: {
  31081. name: string;
  31082. handler: Nullable<(e: FocusEvent) => any>;
  31083. }[]): void;
  31084. /**
  31085. * @ignore
  31086. */
  31087. static _ScreenshotCanvas: HTMLCanvasElement;
  31088. /**
  31089. * Dumps the current bound framebuffer
  31090. * @param width defines the rendering width
  31091. * @param height defines the rendering height
  31092. * @param engine defines the hosting engine
  31093. * @param successCallback defines the callback triggered once the data are available
  31094. * @param mimeType defines the mime type of the result
  31095. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31096. */
  31097. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31098. /**
  31099. * Converts the canvas data to blob.
  31100. * This acts as a polyfill for browsers not supporting the to blob function.
  31101. * @param canvas Defines the canvas to extract the data from
  31102. * @param successCallback Defines the callback triggered once the data are available
  31103. * @param mimeType Defines the mime type of the result
  31104. */
  31105. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31106. /**
  31107. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31108. * @param successCallback defines the callback triggered once the data are available
  31109. * @param mimeType defines the mime type of the result
  31110. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31111. */
  31112. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31113. /**
  31114. * Downloads a blob in the browser
  31115. * @param blob defines the blob to download
  31116. * @param fileName defines the name of the downloaded file
  31117. */
  31118. static Download(blob: Blob, fileName: string): void;
  31119. /**
  31120. * Captures a screenshot of the current rendering
  31121. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31122. * @param engine defines the rendering engine
  31123. * @param camera defines the source camera
  31124. * @param size This parameter can be set to a single number or to an object with the
  31125. * following (optional) properties: precision, width, height. If a single number is passed,
  31126. * it will be used for both width and height. If an object is passed, the screenshot size
  31127. * will be derived from the parameters. The precision property is a multiplier allowing
  31128. * rendering at a higher or lower resolution
  31129. * @param successCallback defines the callback receives a single parameter which contains the
  31130. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31131. * src parameter of an <img> to display it
  31132. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31133. * Check your browser for supported MIME types
  31134. */
  31135. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31136. /**
  31137. * Generates an image screenshot from the specified camera.
  31138. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31139. * @param engine The engine to use for rendering
  31140. * @param camera The camera to use for rendering
  31141. * @param size This parameter can be set to a single number or to an object with the
  31142. * following (optional) properties: precision, width, height. If a single number is passed,
  31143. * it will be used for both width and height. If an object is passed, the screenshot size
  31144. * will be derived from the parameters. The precision property is a multiplier allowing
  31145. * rendering at a higher or lower resolution
  31146. * @param successCallback The callback receives a single parameter which contains the
  31147. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31148. * src parameter of an <img> to display it
  31149. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31150. * Check your browser for supported MIME types
  31151. * @param samples Texture samples (default: 1)
  31152. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31153. * @param fileName A name for for the downloaded file.
  31154. */
  31155. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31156. /**
  31157. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31158. * Be aware Math.random() could cause collisions, but:
  31159. * "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"
  31160. * @returns a pseudo random id
  31161. */
  31162. static RandomId(): string;
  31163. /**
  31164. * Test if the given uri is a base64 string
  31165. * @param uri The uri to test
  31166. * @return True if the uri is a base64 string or false otherwise
  31167. */
  31168. static IsBase64(uri: string): boolean;
  31169. /**
  31170. * Decode the given base64 uri.
  31171. * @param uri The uri to decode
  31172. * @return The decoded base64 data.
  31173. */
  31174. static DecodeBase64(uri: string): ArrayBuffer;
  31175. /**
  31176. * No log
  31177. */
  31178. static readonly NoneLogLevel: number;
  31179. /**
  31180. * Only message logs
  31181. */
  31182. static readonly MessageLogLevel: number;
  31183. /**
  31184. * Only warning logs
  31185. */
  31186. static readonly WarningLogLevel: number;
  31187. /**
  31188. * Only error logs
  31189. */
  31190. static readonly ErrorLogLevel: number;
  31191. /**
  31192. * All logs
  31193. */
  31194. static readonly AllLogLevel: number;
  31195. /**
  31196. * Gets a value indicating the number of loading errors
  31197. * @ignorenaming
  31198. */
  31199. static readonly errorsCount: number;
  31200. /**
  31201. * Callback called when a new log is added
  31202. */
  31203. static OnNewCacheEntry: (entry: string) => void;
  31204. /**
  31205. * Log a message to the console
  31206. * @param message defines the message to log
  31207. */
  31208. static Log(message: string): void;
  31209. /**
  31210. * Write a warning message to the console
  31211. * @param message defines the message to log
  31212. */
  31213. static Warn(message: string): void;
  31214. /**
  31215. * Write an error message to the console
  31216. * @param message defines the message to log
  31217. */
  31218. static Error(message: string): void;
  31219. /**
  31220. * Gets current log cache (list of logs)
  31221. */
  31222. static readonly LogCache: string;
  31223. /**
  31224. * Clears the log cache
  31225. */
  31226. static ClearLogCache(): void;
  31227. /**
  31228. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31229. */
  31230. static LogLevels: number;
  31231. /**
  31232. * Checks if the loaded document was accessed via `file:`-Protocol.
  31233. * @returns boolean
  31234. */
  31235. static IsFileURL(): boolean;
  31236. /**
  31237. * Checks if the window object exists
  31238. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31239. */
  31240. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31241. /**
  31242. * No performance log
  31243. */
  31244. static readonly PerformanceNoneLogLevel: number;
  31245. /**
  31246. * Use user marks to log performance
  31247. */
  31248. static readonly PerformanceUserMarkLogLevel: number;
  31249. /**
  31250. * Log performance to the console
  31251. */
  31252. static readonly PerformanceConsoleLogLevel: number;
  31253. private static _performance;
  31254. /**
  31255. * Sets the current performance log level
  31256. */
  31257. static PerformanceLogLevel: number;
  31258. private static _StartPerformanceCounterDisabled;
  31259. private static _EndPerformanceCounterDisabled;
  31260. private static _StartUserMark;
  31261. private static _EndUserMark;
  31262. private static _StartPerformanceConsole;
  31263. private static _EndPerformanceConsole;
  31264. /**
  31265. * Injects the @see CustomRequestHeaders into the given request
  31266. * @param request the request that should be used for injection
  31267. */
  31268. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31269. /**
  31270. * Starts a performance counter
  31271. */
  31272. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31273. /**
  31274. * Ends a specific performance coutner
  31275. */
  31276. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31277. /**
  31278. * Gets either window.performance.now() if supported or Date.now() else
  31279. */
  31280. static readonly Now: number;
  31281. /**
  31282. * This method will return the name of the class used to create the instance of the given object.
  31283. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31284. * @param object the object to get the class name from
  31285. * @param isType defines if the object is actually a type
  31286. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31287. */
  31288. static GetClassName(object: any, isType?: boolean): string;
  31289. /**
  31290. * Gets the first element of an array satisfying a given predicate
  31291. * @param array defines the array to browse
  31292. * @param predicate defines the predicate to use
  31293. * @returns null if not found or the element
  31294. */
  31295. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31296. /**
  31297. * This method will return the name of the full name of the class, including its owning module (if any).
  31298. * 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).
  31299. * @param object the object to get the class name from
  31300. * @param isType defines if the object is actually a type
  31301. * @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.
  31302. * @ignorenaming
  31303. */
  31304. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31305. /**
  31306. * Returns a promise that resolves after the given amount of time.
  31307. * @param delay Number of milliseconds to delay
  31308. * @returns Promise that resolves after the given amount of time
  31309. */
  31310. static DelayAsync(delay: number): Promise<void>;
  31311. /**
  31312. * Gets the current gradient from an array of IValueGradient
  31313. * @param ratio defines the current ratio to get
  31314. * @param gradients defines the array of IValueGradient
  31315. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31316. */
  31317. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31318. }
  31319. /**
  31320. * This class is used to track a performance counter which is number based.
  31321. * The user has access to many properties which give statistics of different nature.
  31322. *
  31323. * The implementer can track two kinds of Performance Counter: time and count.
  31324. * 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.
  31325. * 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.
  31326. */
  31327. export class PerfCounter {
  31328. /**
  31329. * Gets or sets a global boolean to turn on and off all the counters
  31330. */
  31331. static Enabled: boolean;
  31332. /**
  31333. * Returns the smallest value ever
  31334. */
  31335. readonly min: number;
  31336. /**
  31337. * Returns the biggest value ever
  31338. */
  31339. readonly max: number;
  31340. /**
  31341. * Returns the average value since the performance counter is running
  31342. */
  31343. readonly average: number;
  31344. /**
  31345. * Returns the average value of the last second the counter was monitored
  31346. */
  31347. readonly lastSecAverage: number;
  31348. /**
  31349. * Returns the current value
  31350. */
  31351. readonly current: number;
  31352. /**
  31353. * Gets the accumulated total
  31354. */
  31355. readonly total: number;
  31356. /**
  31357. * Gets the total value count
  31358. */
  31359. readonly count: number;
  31360. /**
  31361. * Creates a new counter
  31362. */
  31363. constructor();
  31364. /**
  31365. * Call this method to start monitoring a new frame.
  31366. * 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.
  31367. */
  31368. fetchNewFrame(): void;
  31369. /**
  31370. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31371. * @param newCount the count value to add to the monitored count
  31372. * @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.
  31373. */
  31374. addCount(newCount: number, fetchResult: boolean): void;
  31375. /**
  31376. * Start monitoring this performance counter
  31377. */
  31378. beginMonitoring(): void;
  31379. /**
  31380. * Compute the time lapsed since the previous beginMonitoring() call.
  31381. * @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
  31382. */
  31383. endMonitoring(newFrame?: boolean): void;
  31384. private _fetchResult;
  31385. private _startMonitoringTime;
  31386. private _min;
  31387. private _max;
  31388. private _average;
  31389. private _current;
  31390. private _totalValueCount;
  31391. private _totalAccumulated;
  31392. private _lastSecAverage;
  31393. private _lastSecAccumulated;
  31394. private _lastSecTime;
  31395. private _lastSecValueCount;
  31396. }
  31397. /**
  31398. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31399. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31400. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31401. * @param name The name of the class, case should be preserved
  31402. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31403. */
  31404. export function className(name: string, module?: string): (target: Object) => void;
  31405. /**
  31406. * An implementation of a loop for asynchronous functions.
  31407. */
  31408. export class AsyncLoop {
  31409. /**
  31410. * Defines the number of iterations for the loop
  31411. */
  31412. iterations: number;
  31413. /**
  31414. * Defines the current index of the loop.
  31415. */
  31416. index: number;
  31417. private _done;
  31418. private _fn;
  31419. private _successCallback;
  31420. /**
  31421. * Constructor.
  31422. * @param iterations the number of iterations.
  31423. * @param func the function to run each iteration
  31424. * @param successCallback the callback that will be called upon succesful execution
  31425. * @param offset starting offset.
  31426. */
  31427. constructor(
  31428. /**
  31429. * Defines the number of iterations for the loop
  31430. */
  31431. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31432. /**
  31433. * Execute the next iteration. Must be called after the last iteration was finished.
  31434. */
  31435. executeNext(): void;
  31436. /**
  31437. * Break the loop and run the success callback.
  31438. */
  31439. breakLoop(): void;
  31440. /**
  31441. * Create and run an async loop.
  31442. * @param iterations the number of iterations.
  31443. * @param fn the function to run each iteration
  31444. * @param successCallback the callback that will be called upon succesful execution
  31445. * @param offset starting offset.
  31446. * @returns the created async loop object
  31447. */
  31448. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31449. /**
  31450. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31451. * @param iterations total number of iterations
  31452. * @param syncedIterations number of synchronous iterations in each async iteration.
  31453. * @param fn the function to call each iteration.
  31454. * @param callback a success call back that will be called when iterating stops.
  31455. * @param breakFunction a break condition (optional)
  31456. * @param timeout timeout settings for the setTimeout function. default - 0.
  31457. * @returns the created async loop object
  31458. */
  31459. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31460. }
  31461. }
  31462. declare module "babylonjs/Collisions/collisionCoordinator" {
  31463. import { Nullable } from "babylonjs/types";
  31464. import { Scene } from "babylonjs/scene";
  31465. import { Vector3 } from "babylonjs/Maths/math";
  31466. import { Collider } from "babylonjs/Collisions/collider";
  31467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31468. /** @hidden */
  31469. export interface ICollisionCoordinator {
  31470. createCollider(): Collider;
  31471. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31472. init(scene: Scene): void;
  31473. }
  31474. /** @hidden */
  31475. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31476. private _scene;
  31477. private _scaledPosition;
  31478. private _scaledVelocity;
  31479. private _finalPosition;
  31480. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31481. createCollider(): Collider;
  31482. init(scene: Scene): void;
  31483. private _collideWithWorld;
  31484. }
  31485. }
  31486. declare module "babylonjs/Animations/animationGroup" {
  31487. import { Animatable } from "babylonjs/Animations/animatable";
  31488. import { Animation } from "babylonjs/Animations/animation";
  31489. import { Scene, IDisposable } from "babylonjs/scene";
  31490. import { Observable } from "babylonjs/Misc/observable";
  31491. import { Nullable } from "babylonjs/types";
  31492. /**
  31493. * This class defines the direct association between an animation and a target
  31494. */
  31495. export class TargetedAnimation {
  31496. /**
  31497. * Animation to perform
  31498. */
  31499. animation: Animation;
  31500. /**
  31501. * Target to animate
  31502. */
  31503. target: any;
  31504. }
  31505. /**
  31506. * Use this class to create coordinated animations on multiple targets
  31507. */
  31508. export class AnimationGroup implements IDisposable {
  31509. /** The name of the animation group */
  31510. name: string;
  31511. private _scene;
  31512. private _targetedAnimations;
  31513. private _animatables;
  31514. private _from;
  31515. private _to;
  31516. private _isStarted;
  31517. private _isPaused;
  31518. private _speedRatio;
  31519. /**
  31520. * Gets or sets the unique id of the node
  31521. */
  31522. uniqueId: number;
  31523. /**
  31524. * This observable will notify when one animation have ended
  31525. */
  31526. onAnimationEndObservable: Observable<TargetedAnimation>;
  31527. /**
  31528. * Observer raised when one animation loops
  31529. */
  31530. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31531. /**
  31532. * This observable will notify when all animations have ended.
  31533. */
  31534. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31535. /**
  31536. * This observable will notify when all animations have paused.
  31537. */
  31538. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31539. /**
  31540. * This observable will notify when all animations are playing.
  31541. */
  31542. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31543. /**
  31544. * Gets the first frame
  31545. */
  31546. readonly from: number;
  31547. /**
  31548. * Gets the last frame
  31549. */
  31550. readonly to: number;
  31551. /**
  31552. * Define if the animations are started
  31553. */
  31554. readonly isStarted: boolean;
  31555. /**
  31556. * Gets a value indicating that the current group is playing
  31557. */
  31558. readonly isPlaying: boolean;
  31559. /**
  31560. * Gets or sets the speed ratio to use for all animations
  31561. */
  31562. /**
  31563. * Gets or sets the speed ratio to use for all animations
  31564. */
  31565. speedRatio: number;
  31566. /**
  31567. * Gets the targeted animations for this animation group
  31568. */
  31569. readonly targetedAnimations: Array<TargetedAnimation>;
  31570. /**
  31571. * returning the list of animatables controlled by this animation group.
  31572. */
  31573. readonly animatables: Array<Animatable>;
  31574. /**
  31575. * Instantiates a new Animation Group.
  31576. * This helps managing several animations at once.
  31577. * @see http://doc.babylonjs.com/how_to/group
  31578. * @param name Defines the name of the group
  31579. * @param scene Defines the scene the group belongs to
  31580. */
  31581. constructor(
  31582. /** The name of the animation group */
  31583. name: string, scene?: Nullable<Scene>);
  31584. /**
  31585. * Add an animation (with its target) in the group
  31586. * @param animation defines the animation we want to add
  31587. * @param target defines the target of the animation
  31588. * @returns the TargetedAnimation object
  31589. */
  31590. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31591. /**
  31592. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31593. * It can add constant keys at begin or end
  31594. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31595. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31596. * @returns the animation group
  31597. */
  31598. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31599. /**
  31600. * Start all animations on given targets
  31601. * @param loop defines if animations must loop
  31602. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31603. * @param from defines the from key (optional)
  31604. * @param to defines the to key (optional)
  31605. * @returns the current animation group
  31606. */
  31607. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31608. /**
  31609. * Pause all animations
  31610. * @returns the animation group
  31611. */
  31612. pause(): AnimationGroup;
  31613. /**
  31614. * Play all animations to initial state
  31615. * This function will start() the animations if they were not started or will restart() them if they were paused
  31616. * @param loop defines if animations must loop
  31617. * @returns the animation group
  31618. */
  31619. play(loop?: boolean): AnimationGroup;
  31620. /**
  31621. * Reset all animations to initial state
  31622. * @returns the animation group
  31623. */
  31624. reset(): AnimationGroup;
  31625. /**
  31626. * Restart animations from key 0
  31627. * @returns the animation group
  31628. */
  31629. restart(): AnimationGroup;
  31630. /**
  31631. * Stop all animations
  31632. * @returns the animation group
  31633. */
  31634. stop(): AnimationGroup;
  31635. /**
  31636. * Set animation weight for all animatables
  31637. * @param weight defines the weight to use
  31638. * @return the animationGroup
  31639. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31640. */
  31641. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31642. /**
  31643. * Synchronize and normalize all animatables with a source animatable
  31644. * @param root defines the root animatable to synchronize with
  31645. * @return the animationGroup
  31646. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31647. */
  31648. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31649. /**
  31650. * Goes to a specific frame in this animation group
  31651. * @param frame the frame number to go to
  31652. * @return the animationGroup
  31653. */
  31654. goToFrame(frame: number): AnimationGroup;
  31655. /**
  31656. * Dispose all associated resources
  31657. */
  31658. dispose(): void;
  31659. private _checkAnimationGroupEnded;
  31660. /**
  31661. * Clone the current animation group and returns a copy
  31662. * @param newName defines the name of the new group
  31663. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31664. * @returns the new aniamtion group
  31665. */
  31666. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31667. /**
  31668. * Returns a new AnimationGroup object parsed from the source provided.
  31669. * @param parsedAnimationGroup defines the source
  31670. * @param scene defines the scene that will receive the animationGroup
  31671. * @returns a new AnimationGroup
  31672. */
  31673. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31674. /**
  31675. * Returns the string "AnimationGroup"
  31676. * @returns "AnimationGroup"
  31677. */
  31678. getClassName(): string;
  31679. /**
  31680. * Creates a detailled string about the object
  31681. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31682. * @returns a string representing the object
  31683. */
  31684. toString(fullDetails?: boolean): string;
  31685. }
  31686. }
  31687. declare module "babylonjs/scene" {
  31688. import { Nullable } from "babylonjs/types";
  31689. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31690. import { Observable } from "babylonjs/Misc/observable";
  31691. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31692. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31693. import { Geometry } from "babylonjs/Meshes/geometry";
  31694. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31695. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31697. import { Mesh } from "babylonjs/Meshes/mesh";
  31698. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31699. import { Bone } from "babylonjs/Bones/bone";
  31700. import { Skeleton } from "babylonjs/Bones/skeleton";
  31701. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31702. import { Camera } from "babylonjs/Cameras/camera";
  31703. import { AbstractScene } from "babylonjs/abstractScene";
  31704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31705. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31706. import { Material } from "babylonjs/Materials/material";
  31707. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31708. import { Effect } from "babylonjs/Materials/effect";
  31709. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31710. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31711. import { Light } from "babylonjs/Lights/light";
  31712. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31713. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31714. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31715. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31716. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31717. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31718. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31719. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31720. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31721. import { Engine } from "babylonjs/Engines/engine";
  31722. import { Node } from "babylonjs/node";
  31723. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31724. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31725. import { Ray } from "babylonjs/Culling/ray";
  31726. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31727. import { Animation } from "babylonjs/Animations/animation";
  31728. import { Animatable } from "babylonjs/Animations/animatable";
  31729. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31730. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31731. import { Collider } from "babylonjs/Collisions/collider";
  31732. /**
  31733. * Define an interface for all classes that will hold resources
  31734. */
  31735. export interface IDisposable {
  31736. /**
  31737. * Releases all held resources
  31738. */
  31739. dispose(): void;
  31740. }
  31741. /** Interface defining initialization parameters for Scene class */
  31742. export interface SceneOptions {
  31743. /**
  31744. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31745. * It will improve performance when the number of geometries becomes important.
  31746. */
  31747. useGeometryUniqueIdsMap?: boolean;
  31748. /**
  31749. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31750. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31751. */
  31752. useMaterialMeshMap?: boolean;
  31753. /**
  31754. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31755. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31756. */
  31757. useClonedMeshhMap?: boolean;
  31758. }
  31759. /**
  31760. * Represents a scene to be rendered by the engine.
  31761. * @see http://doc.babylonjs.com/features/scene
  31762. */
  31763. export class Scene extends AbstractScene implements IAnimatable {
  31764. private static _uniqueIdCounter;
  31765. /** The fog is deactivated */
  31766. static readonly FOGMODE_NONE: number;
  31767. /** The fog density is following an exponential function */
  31768. static readonly FOGMODE_EXP: number;
  31769. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31770. static readonly FOGMODE_EXP2: number;
  31771. /** The fog density is following a linear function. */
  31772. static readonly FOGMODE_LINEAR: number;
  31773. /**
  31774. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31775. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31776. */
  31777. static MinDeltaTime: number;
  31778. /**
  31779. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31780. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31781. */
  31782. static MaxDeltaTime: number;
  31783. /**
  31784. * Factory used to create the default material.
  31785. * @param name The name of the material to create
  31786. * @param scene The scene to create the material for
  31787. * @returns The default material
  31788. */
  31789. static DefaultMaterialFactory(scene: Scene): Material;
  31790. /**
  31791. * Factory used to create the a collision coordinator.
  31792. * @returns The collision coordinator
  31793. */
  31794. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31795. /** @hidden */
  31796. readonly _isScene: boolean;
  31797. /**
  31798. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31799. */
  31800. autoClear: boolean;
  31801. /**
  31802. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31803. */
  31804. autoClearDepthAndStencil: boolean;
  31805. /**
  31806. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31807. */
  31808. clearColor: Color4;
  31809. /**
  31810. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31811. */
  31812. ambientColor: Color3;
  31813. /** @hidden */
  31814. _environmentBRDFTexture: BaseTexture;
  31815. /** @hidden */
  31816. protected _environmentTexture: Nullable<BaseTexture>;
  31817. /**
  31818. * Texture used in all pbr material as the reflection texture.
  31819. * As in the majority of the scene they are the same (exception for multi room and so on),
  31820. * this is easier to reference from here than from all the materials.
  31821. */
  31822. /**
  31823. * Texture used in all pbr material as the reflection texture.
  31824. * As in the majority of the scene they are the same (exception for multi room and so on),
  31825. * this is easier to set here than in all the materials.
  31826. */
  31827. environmentTexture: Nullable<BaseTexture>;
  31828. /** @hidden */
  31829. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31830. /**
  31831. * Default image processing configuration used either in the rendering
  31832. * Forward main pass or through the imageProcessingPostProcess if present.
  31833. * As in the majority of the scene they are the same (exception for multi camera),
  31834. * this is easier to reference from here than from all the materials and post process.
  31835. *
  31836. * No setter as we it is a shared configuration, you can set the values instead.
  31837. */
  31838. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31839. private _forceWireframe;
  31840. /**
  31841. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31842. */
  31843. forceWireframe: boolean;
  31844. private _forcePointsCloud;
  31845. /**
  31846. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31847. */
  31848. forcePointsCloud: boolean;
  31849. /**
  31850. * Gets or sets the active clipplane 1
  31851. */
  31852. clipPlane: Nullable<Plane>;
  31853. /**
  31854. * Gets or sets the active clipplane 2
  31855. */
  31856. clipPlane2: Nullable<Plane>;
  31857. /**
  31858. * Gets or sets the active clipplane 3
  31859. */
  31860. clipPlane3: Nullable<Plane>;
  31861. /**
  31862. * Gets or sets the active clipplane 4
  31863. */
  31864. clipPlane4: Nullable<Plane>;
  31865. /**
  31866. * Gets or sets a boolean indicating if animations are enabled
  31867. */
  31868. animationsEnabled: boolean;
  31869. private _animationPropertiesOverride;
  31870. /**
  31871. * Gets or sets the animation properties override
  31872. */
  31873. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31874. /**
  31875. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31876. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31877. */
  31878. useConstantAnimationDeltaTime: boolean;
  31879. /**
  31880. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31881. * Please note that it requires to run a ray cast through the scene on every frame
  31882. */
  31883. constantlyUpdateMeshUnderPointer: boolean;
  31884. /**
  31885. * Defines the HTML cursor to use when hovering over interactive elements
  31886. */
  31887. hoverCursor: string;
  31888. /**
  31889. * Defines the HTML default cursor to use (empty by default)
  31890. */
  31891. defaultCursor: string;
  31892. /**
  31893. * This is used to call preventDefault() on pointer down
  31894. * in order to block unwanted artifacts like system double clicks
  31895. */
  31896. preventDefaultOnPointerDown: boolean;
  31897. /**
  31898. * This is used to call preventDefault() on pointer up
  31899. * in order to block unwanted artifacts like system double clicks
  31900. */
  31901. preventDefaultOnPointerUp: boolean;
  31902. /**
  31903. * Gets or sets user defined metadata
  31904. */
  31905. metadata: any;
  31906. /**
  31907. * For internal use only. Please do not use.
  31908. */
  31909. reservedDataStore: any;
  31910. /**
  31911. * Gets the name of the plugin used to load this scene (null by default)
  31912. */
  31913. loadingPluginName: string;
  31914. /**
  31915. * Use this array to add regular expressions used to disable offline support for specific urls
  31916. */
  31917. disableOfflineSupportExceptionRules: RegExp[];
  31918. /**
  31919. * An event triggered when the scene is disposed.
  31920. */
  31921. onDisposeObservable: Observable<Scene>;
  31922. private _onDisposeObserver;
  31923. /** Sets a function to be executed when this scene is disposed. */
  31924. onDispose: () => void;
  31925. /**
  31926. * An event triggered before rendering the scene (right after animations and physics)
  31927. */
  31928. onBeforeRenderObservable: Observable<Scene>;
  31929. private _onBeforeRenderObserver;
  31930. /** Sets a function to be executed before rendering this scene */
  31931. beforeRender: Nullable<() => void>;
  31932. /**
  31933. * An event triggered after rendering the scene
  31934. */
  31935. onAfterRenderObservable: Observable<Scene>;
  31936. private _onAfterRenderObserver;
  31937. /** Sets a function to be executed after rendering this scene */
  31938. afterRender: Nullable<() => void>;
  31939. /**
  31940. * An event triggered before animating the scene
  31941. */
  31942. onBeforeAnimationsObservable: Observable<Scene>;
  31943. /**
  31944. * An event triggered after animations processing
  31945. */
  31946. onAfterAnimationsObservable: Observable<Scene>;
  31947. /**
  31948. * An event triggered before draw calls are ready to be sent
  31949. */
  31950. onBeforeDrawPhaseObservable: Observable<Scene>;
  31951. /**
  31952. * An event triggered after draw calls have been sent
  31953. */
  31954. onAfterDrawPhaseObservable: Observable<Scene>;
  31955. /**
  31956. * An event triggered when the scene is ready
  31957. */
  31958. onReadyObservable: Observable<Scene>;
  31959. /**
  31960. * An event triggered before rendering a camera
  31961. */
  31962. onBeforeCameraRenderObservable: Observable<Camera>;
  31963. private _onBeforeCameraRenderObserver;
  31964. /** Sets a function to be executed before rendering a camera*/
  31965. beforeCameraRender: () => void;
  31966. /**
  31967. * An event triggered after rendering a camera
  31968. */
  31969. onAfterCameraRenderObservable: Observable<Camera>;
  31970. private _onAfterCameraRenderObserver;
  31971. /** Sets a function to be executed after rendering a camera*/
  31972. afterCameraRender: () => void;
  31973. /**
  31974. * An event triggered when active meshes evaluation is about to start
  31975. */
  31976. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31977. /**
  31978. * An event triggered when active meshes evaluation is done
  31979. */
  31980. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31981. /**
  31982. * An event triggered when particles rendering is about to start
  31983. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31984. */
  31985. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31986. /**
  31987. * An event triggered when particles rendering is done
  31988. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31989. */
  31990. onAfterParticlesRenderingObservable: Observable<Scene>;
  31991. /**
  31992. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31993. */
  31994. onDataLoadedObservable: Observable<Scene>;
  31995. /**
  31996. * An event triggered when a camera is created
  31997. */
  31998. onNewCameraAddedObservable: Observable<Camera>;
  31999. /**
  32000. * An event triggered when a camera is removed
  32001. */
  32002. onCameraRemovedObservable: Observable<Camera>;
  32003. /**
  32004. * An event triggered when a light is created
  32005. */
  32006. onNewLightAddedObservable: Observable<Light>;
  32007. /**
  32008. * An event triggered when a light is removed
  32009. */
  32010. onLightRemovedObservable: Observable<Light>;
  32011. /**
  32012. * An event triggered when a geometry is created
  32013. */
  32014. onNewGeometryAddedObservable: Observable<Geometry>;
  32015. /**
  32016. * An event triggered when a geometry is removed
  32017. */
  32018. onGeometryRemovedObservable: Observable<Geometry>;
  32019. /**
  32020. * An event triggered when a transform node is created
  32021. */
  32022. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32023. /**
  32024. * An event triggered when a transform node is removed
  32025. */
  32026. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32027. /**
  32028. * An event triggered when a mesh is created
  32029. */
  32030. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32031. /**
  32032. * An event triggered when a mesh is removed
  32033. */
  32034. onMeshRemovedObservable: Observable<AbstractMesh>;
  32035. /**
  32036. * An event triggered when a material is created
  32037. */
  32038. onNewMaterialAddedObservable: Observable<Material>;
  32039. /**
  32040. * An event triggered when a material is removed
  32041. */
  32042. onMaterialRemovedObservable: Observable<Material>;
  32043. /**
  32044. * An event triggered when a texture is created
  32045. */
  32046. onNewTextureAddedObservable: Observable<BaseTexture>;
  32047. /**
  32048. * An event triggered when a texture is removed
  32049. */
  32050. onTextureRemovedObservable: Observable<BaseTexture>;
  32051. /**
  32052. * An event triggered when render targets are about to be rendered
  32053. * Can happen multiple times per frame.
  32054. */
  32055. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32056. /**
  32057. * An event triggered when render targets were rendered.
  32058. * Can happen multiple times per frame.
  32059. */
  32060. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32061. /**
  32062. * An event triggered before calculating deterministic simulation step
  32063. */
  32064. onBeforeStepObservable: Observable<Scene>;
  32065. /**
  32066. * An event triggered after calculating deterministic simulation step
  32067. */
  32068. onAfterStepObservable: Observable<Scene>;
  32069. /**
  32070. * An event triggered when the activeCamera property is updated
  32071. */
  32072. onActiveCameraChanged: Observable<Scene>;
  32073. /**
  32074. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32075. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32076. * 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)
  32077. */
  32078. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32079. /**
  32080. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32081. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32082. * 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)
  32083. */
  32084. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32085. /**
  32086. * This Observable will when a mesh has been imported into the scene.
  32087. */
  32088. onMeshImportedObservable: Observable<AbstractMesh>;
  32089. /**
  32090. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32091. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32092. */
  32093. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32094. /** @hidden */
  32095. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32096. /**
  32097. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32098. */
  32099. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32100. /**
  32101. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32102. */
  32103. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32104. /**
  32105. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32106. */
  32107. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32108. private _onPointerMove;
  32109. private _onPointerDown;
  32110. private _onPointerUp;
  32111. /** Callback called when a pointer move is detected */
  32112. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32113. /** Callback called when a pointer down is detected */
  32114. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32115. /** Callback called when a pointer up is detected */
  32116. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32117. /** Callback called when a pointer pick is detected */
  32118. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32119. /**
  32120. * 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).
  32121. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32122. */
  32123. onPrePointerObservable: Observable<PointerInfoPre>;
  32124. /**
  32125. * Observable event triggered each time an input event is received from the rendering canvas
  32126. */
  32127. onPointerObservable: Observable<PointerInfo>;
  32128. /**
  32129. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32130. */
  32131. readonly unTranslatedPointer: Vector2;
  32132. /** The distance in pixel that you have to move to prevent some events */
  32133. static DragMovementThreshold: number;
  32134. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32135. static LongPressDelay: number;
  32136. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32137. static DoubleClickDelay: number;
  32138. /** If you need to check double click without raising a single click at first click, enable this flag */
  32139. static ExclusiveDoubleClickMode: boolean;
  32140. private _initClickEvent;
  32141. private _initActionManager;
  32142. private _delayedSimpleClick;
  32143. private _delayedSimpleClickTimeout;
  32144. private _previousDelayedSimpleClickTimeout;
  32145. private _meshPickProceed;
  32146. private _previousButtonPressed;
  32147. private _currentPickResult;
  32148. private _previousPickResult;
  32149. private _totalPointersPressed;
  32150. private _doubleClickOccured;
  32151. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32152. cameraToUseForPointers: Nullable<Camera>;
  32153. private _pointerX;
  32154. private _pointerY;
  32155. private _unTranslatedPointerX;
  32156. private _unTranslatedPointerY;
  32157. private _startingPointerPosition;
  32158. private _previousStartingPointerPosition;
  32159. private _startingPointerTime;
  32160. private _previousStartingPointerTime;
  32161. private _pointerCaptures;
  32162. private _timeAccumulator;
  32163. private _currentStepId;
  32164. private _currentInternalStep;
  32165. /** @hidden */
  32166. _mirroredCameraPosition: Nullable<Vector3>;
  32167. /**
  32168. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32169. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32170. */
  32171. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32172. /**
  32173. * Observable event triggered each time an keyboard event is received from the hosting window
  32174. */
  32175. onKeyboardObservable: Observable<KeyboardInfo>;
  32176. private _onKeyDown;
  32177. private _onKeyUp;
  32178. private _onCanvasFocusObserver;
  32179. private _onCanvasBlurObserver;
  32180. private _useRightHandedSystem;
  32181. /**
  32182. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32183. */
  32184. useRightHandedSystem: boolean;
  32185. /**
  32186. * Sets the step Id used by deterministic lock step
  32187. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32188. * @param newStepId defines the step Id
  32189. */
  32190. setStepId(newStepId: number): void;
  32191. /**
  32192. * Gets the step Id used by deterministic lock step
  32193. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32194. * @returns the step Id
  32195. */
  32196. getStepId(): number;
  32197. /**
  32198. * Gets the internal step used by deterministic lock step
  32199. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32200. * @returns the internal step
  32201. */
  32202. getInternalStep(): number;
  32203. private _fogEnabled;
  32204. /**
  32205. * Gets or sets a boolean indicating if fog is enabled on this scene
  32206. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32207. * (Default is true)
  32208. */
  32209. fogEnabled: boolean;
  32210. private _fogMode;
  32211. /**
  32212. * Gets or sets the fog mode to use
  32213. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32214. * | mode | value |
  32215. * | --- | --- |
  32216. * | FOGMODE_NONE | 0 |
  32217. * | FOGMODE_EXP | 1 |
  32218. * | FOGMODE_EXP2 | 2 |
  32219. * | FOGMODE_LINEAR | 3 |
  32220. */
  32221. fogMode: number;
  32222. /**
  32223. * Gets or sets the fog color to use
  32224. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32225. * (Default is Color3(0.2, 0.2, 0.3))
  32226. */
  32227. fogColor: Color3;
  32228. /**
  32229. * Gets or sets the fog density to use
  32230. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32231. * (Default is 0.1)
  32232. */
  32233. fogDensity: number;
  32234. /**
  32235. * Gets or sets the fog start distance to use
  32236. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32237. * (Default is 0)
  32238. */
  32239. fogStart: number;
  32240. /**
  32241. * Gets or sets the fog end distance to use
  32242. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32243. * (Default is 1000)
  32244. */
  32245. fogEnd: number;
  32246. private _shadowsEnabled;
  32247. /**
  32248. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32249. */
  32250. shadowsEnabled: boolean;
  32251. private _lightsEnabled;
  32252. /**
  32253. * Gets or sets a boolean indicating if lights are enabled on this scene
  32254. */
  32255. lightsEnabled: boolean;
  32256. /** All of the active cameras added to this scene. */
  32257. activeCameras: Camera[];
  32258. private _activeCamera;
  32259. /** Gets or sets the current active camera */
  32260. activeCamera: Nullable<Camera>;
  32261. private _defaultMaterial;
  32262. /** The default material used on meshes when no material is affected */
  32263. /** The default material used on meshes when no material is affected */
  32264. defaultMaterial: Material;
  32265. private _texturesEnabled;
  32266. /**
  32267. * Gets or sets a boolean indicating if textures are enabled on this scene
  32268. */
  32269. texturesEnabled: boolean;
  32270. /**
  32271. * Gets or sets a boolean indicating if particles are enabled on this scene
  32272. */
  32273. particlesEnabled: boolean;
  32274. /**
  32275. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32276. */
  32277. spritesEnabled: boolean;
  32278. private _skeletonsEnabled;
  32279. /**
  32280. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32281. */
  32282. skeletonsEnabled: boolean;
  32283. /**
  32284. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32285. */
  32286. lensFlaresEnabled: boolean;
  32287. /**
  32288. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32289. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32290. */
  32291. collisionsEnabled: boolean;
  32292. private _collisionCoordinator;
  32293. /** @hidden */
  32294. readonly collisionCoordinator: ICollisionCoordinator;
  32295. /**
  32296. * Defines the gravity applied to this scene (used only for collisions)
  32297. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32298. */
  32299. gravity: Vector3;
  32300. /**
  32301. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32302. */
  32303. postProcessesEnabled: boolean;
  32304. /**
  32305. * The list of postprocesses added to the scene
  32306. */
  32307. postProcesses: PostProcess[];
  32308. /**
  32309. * Gets the current postprocess manager
  32310. */
  32311. postProcessManager: PostProcessManager;
  32312. /**
  32313. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32314. */
  32315. renderTargetsEnabled: boolean;
  32316. /**
  32317. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32318. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32319. */
  32320. dumpNextRenderTargets: boolean;
  32321. /**
  32322. * The list of user defined render targets added to the scene
  32323. */
  32324. customRenderTargets: RenderTargetTexture[];
  32325. /**
  32326. * Defines if texture loading must be delayed
  32327. * If true, textures will only be loaded when they need to be rendered
  32328. */
  32329. useDelayedTextureLoading: boolean;
  32330. /**
  32331. * Gets the list of meshes imported to the scene through SceneLoader
  32332. */
  32333. importedMeshesFiles: String[];
  32334. /**
  32335. * Gets or sets a boolean indicating if probes are enabled on this scene
  32336. */
  32337. probesEnabled: boolean;
  32338. /**
  32339. * Gets or sets the current offline provider to use to store scene data
  32340. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32341. */
  32342. offlineProvider: IOfflineProvider;
  32343. /**
  32344. * Gets or sets the action manager associated with the scene
  32345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32346. */
  32347. actionManager: AbstractActionManager;
  32348. private _meshesForIntersections;
  32349. /**
  32350. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32351. */
  32352. proceduralTexturesEnabled: boolean;
  32353. private _engine;
  32354. private _totalVertices;
  32355. /** @hidden */
  32356. _activeIndices: PerfCounter;
  32357. /** @hidden */
  32358. _activeParticles: PerfCounter;
  32359. /** @hidden */
  32360. _activeBones: PerfCounter;
  32361. private _animationRatio;
  32362. /** @hidden */
  32363. _animationTimeLast: number;
  32364. /** @hidden */
  32365. _animationTime: number;
  32366. /**
  32367. * Gets or sets a general scale for animation speed
  32368. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32369. */
  32370. animationTimeScale: number;
  32371. /** @hidden */
  32372. _cachedMaterial: Nullable<Material>;
  32373. /** @hidden */
  32374. _cachedEffect: Nullable<Effect>;
  32375. /** @hidden */
  32376. _cachedVisibility: Nullable<number>;
  32377. private _renderId;
  32378. private _frameId;
  32379. private _executeWhenReadyTimeoutId;
  32380. private _intermediateRendering;
  32381. private _viewUpdateFlag;
  32382. private _projectionUpdateFlag;
  32383. private _alternateViewUpdateFlag;
  32384. private _alternateProjectionUpdateFlag;
  32385. /** @hidden */
  32386. _toBeDisposed: Nullable<IDisposable>[];
  32387. private _activeRequests;
  32388. /** @hidden */
  32389. _pendingData: any[];
  32390. private _isDisposed;
  32391. /**
  32392. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32393. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32394. */
  32395. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32396. private _activeMeshes;
  32397. private _processedMaterials;
  32398. private _renderTargets;
  32399. /** @hidden */
  32400. _activeParticleSystems: SmartArray<IParticleSystem>;
  32401. private _activeSkeletons;
  32402. private _softwareSkinnedMeshes;
  32403. private _renderingManager;
  32404. /** @hidden */
  32405. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32406. private _transformMatrix;
  32407. private _sceneUbo;
  32408. private _alternateSceneUbo;
  32409. private _viewMatrix;
  32410. private _projectionMatrix;
  32411. private _alternateViewMatrix;
  32412. private _alternateProjectionMatrix;
  32413. private _alternateTransformMatrix;
  32414. private _useAlternateCameraConfiguration;
  32415. private _alternateRendering;
  32416. private _wheelEventName;
  32417. /** @hidden */
  32418. _forcedViewPosition: Nullable<Vector3>;
  32419. /** @hidden */
  32420. readonly _isAlternateRenderingEnabled: boolean;
  32421. private _frustumPlanes;
  32422. /**
  32423. * Gets the list of frustum planes (built from the active camera)
  32424. */
  32425. readonly frustumPlanes: Plane[];
  32426. /**
  32427. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32428. * This is useful if there are more lights that the maximum simulteanous authorized
  32429. */
  32430. requireLightSorting: boolean;
  32431. /** @hidden */
  32432. readonly useMaterialMeshMap: boolean;
  32433. /** @hidden */
  32434. readonly useClonedMeshhMap: boolean;
  32435. private _pointerOverMesh;
  32436. private _pickedDownMesh;
  32437. private _pickedUpMesh;
  32438. private _externalData;
  32439. private _uid;
  32440. /**
  32441. * @hidden
  32442. * Backing store of defined scene components.
  32443. */
  32444. _components: ISceneComponent[];
  32445. /**
  32446. * @hidden
  32447. * Backing store of defined scene components.
  32448. */
  32449. _serializableComponents: ISceneSerializableComponent[];
  32450. /**
  32451. * List of components to register on the next registration step.
  32452. */
  32453. private _transientComponents;
  32454. /**
  32455. * Registers the transient components if needed.
  32456. */
  32457. private _registerTransientComponents;
  32458. /**
  32459. * @hidden
  32460. * Add a component to the scene.
  32461. * Note that the ccomponent could be registered on th next frame if this is called after
  32462. * the register component stage.
  32463. * @param component Defines the component to add to the scene
  32464. */
  32465. _addComponent(component: ISceneComponent): void;
  32466. /**
  32467. * @hidden
  32468. * Gets a component from the scene.
  32469. * @param name defines the name of the component to retrieve
  32470. * @returns the component or null if not present
  32471. */
  32472. _getComponent(name: string): Nullable<ISceneComponent>;
  32473. /**
  32474. * @hidden
  32475. * Defines the actions happening before camera updates.
  32476. */
  32477. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32478. /**
  32479. * @hidden
  32480. * Defines the actions happening before clear the canvas.
  32481. */
  32482. _beforeClearStage: Stage<SimpleStageAction>;
  32483. /**
  32484. * @hidden
  32485. * Defines the actions when collecting render targets for the frame.
  32486. */
  32487. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32488. /**
  32489. * @hidden
  32490. * Defines the actions happening for one camera in the frame.
  32491. */
  32492. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32493. /**
  32494. * @hidden
  32495. * Defines the actions happening during the per mesh ready checks.
  32496. */
  32497. _isReadyForMeshStage: Stage<MeshStageAction>;
  32498. /**
  32499. * @hidden
  32500. * Defines the actions happening before evaluate active mesh checks.
  32501. */
  32502. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32503. /**
  32504. * @hidden
  32505. * Defines the actions happening during the evaluate sub mesh checks.
  32506. */
  32507. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32508. /**
  32509. * @hidden
  32510. * Defines the actions happening during the active mesh stage.
  32511. */
  32512. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32513. /**
  32514. * @hidden
  32515. * Defines the actions happening during the per camera render target step.
  32516. */
  32517. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32518. /**
  32519. * @hidden
  32520. * Defines the actions happening just before the active camera is drawing.
  32521. */
  32522. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32523. /**
  32524. * @hidden
  32525. * Defines the actions happening just before a render target is drawing.
  32526. */
  32527. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32528. /**
  32529. * @hidden
  32530. * Defines the actions happening just before a rendering group is drawing.
  32531. */
  32532. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32533. /**
  32534. * @hidden
  32535. * Defines the actions happening just before a mesh is drawing.
  32536. */
  32537. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32538. /**
  32539. * @hidden
  32540. * Defines the actions happening just after a mesh has been drawn.
  32541. */
  32542. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32543. /**
  32544. * @hidden
  32545. * Defines the actions happening just after a rendering group has been drawn.
  32546. */
  32547. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32548. /**
  32549. * @hidden
  32550. * Defines the actions happening just after the active camera has been drawn.
  32551. */
  32552. _afterCameraDrawStage: Stage<CameraStageAction>;
  32553. /**
  32554. * @hidden
  32555. * Defines the actions happening just after a render target has been drawn.
  32556. */
  32557. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32558. /**
  32559. * @hidden
  32560. * Defines the actions happening just after rendering all cameras and computing intersections.
  32561. */
  32562. _afterRenderStage: Stage<SimpleStageAction>;
  32563. /**
  32564. * @hidden
  32565. * Defines the actions happening when a pointer move event happens.
  32566. */
  32567. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32568. /**
  32569. * @hidden
  32570. * Defines the actions happening when a pointer down event happens.
  32571. */
  32572. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32573. /**
  32574. * @hidden
  32575. * Defines the actions happening when a pointer up event happens.
  32576. */
  32577. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32578. /**
  32579. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32580. */
  32581. private geometriesByUniqueId;
  32582. /**
  32583. * Creates a new Scene
  32584. * @param engine defines the engine to use to render this scene
  32585. * @param options defines the scene options
  32586. */
  32587. constructor(engine: Engine, options?: SceneOptions);
  32588. private _defaultMeshCandidates;
  32589. /**
  32590. * @hidden
  32591. */
  32592. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32593. private _defaultSubMeshCandidates;
  32594. /**
  32595. * @hidden
  32596. */
  32597. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32598. /**
  32599. * Sets the default candidate providers for the scene.
  32600. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32601. * and getCollidingSubMeshCandidates to their default function
  32602. */
  32603. setDefaultCandidateProviders(): void;
  32604. /**
  32605. * Gets the mesh that is currently under the pointer
  32606. */
  32607. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32608. /**
  32609. * Gets or sets the current on-screen X position of the pointer
  32610. */
  32611. pointerX: number;
  32612. /**
  32613. * Gets or sets the current on-screen Y position of the pointer
  32614. */
  32615. pointerY: number;
  32616. /**
  32617. * Gets the cached material (ie. the latest rendered one)
  32618. * @returns the cached material
  32619. */
  32620. getCachedMaterial(): Nullable<Material>;
  32621. /**
  32622. * Gets the cached effect (ie. the latest rendered one)
  32623. * @returns the cached effect
  32624. */
  32625. getCachedEffect(): Nullable<Effect>;
  32626. /**
  32627. * Gets the cached visibility state (ie. the latest rendered one)
  32628. * @returns the cached visibility state
  32629. */
  32630. getCachedVisibility(): Nullable<number>;
  32631. /**
  32632. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32633. * @param material defines the current material
  32634. * @param effect defines the current effect
  32635. * @param visibility defines the current visibility state
  32636. * @returns true if one parameter is not cached
  32637. */
  32638. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32639. /**
  32640. * Gets the engine associated with the scene
  32641. * @returns an Engine
  32642. */
  32643. getEngine(): Engine;
  32644. /**
  32645. * Gets the total number of vertices rendered per frame
  32646. * @returns the total number of vertices rendered per frame
  32647. */
  32648. getTotalVertices(): number;
  32649. /**
  32650. * Gets the performance counter for total vertices
  32651. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32652. */
  32653. readonly totalVerticesPerfCounter: PerfCounter;
  32654. /**
  32655. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32656. * @returns the total number of active indices rendered per frame
  32657. */
  32658. getActiveIndices(): number;
  32659. /**
  32660. * Gets the performance counter for active indices
  32661. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32662. */
  32663. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32664. /**
  32665. * Gets the total number of active particles rendered per frame
  32666. * @returns the total number of active particles rendered per frame
  32667. */
  32668. getActiveParticles(): number;
  32669. /**
  32670. * Gets the performance counter for active particles
  32671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32672. */
  32673. readonly activeParticlesPerfCounter: PerfCounter;
  32674. /**
  32675. * Gets the total number of active bones rendered per frame
  32676. * @returns the total number of active bones rendered per frame
  32677. */
  32678. getActiveBones(): number;
  32679. /**
  32680. * Gets the performance counter for active bones
  32681. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32682. */
  32683. readonly activeBonesPerfCounter: PerfCounter;
  32684. /**
  32685. * Gets the array of active meshes
  32686. * @returns an array of AbstractMesh
  32687. */
  32688. getActiveMeshes(): SmartArray<AbstractMesh>;
  32689. /**
  32690. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32691. * @returns a number
  32692. */
  32693. getAnimationRatio(): number;
  32694. /**
  32695. * Gets an unique Id for the current render phase
  32696. * @returns a number
  32697. */
  32698. getRenderId(): number;
  32699. /**
  32700. * Gets an unique Id for the current frame
  32701. * @returns a number
  32702. */
  32703. getFrameId(): number;
  32704. /** Call this function if you want to manually increment the render Id*/
  32705. incrementRenderId(): void;
  32706. private _updatePointerPosition;
  32707. private _createUbo;
  32708. private _createAlternateUbo;
  32709. private _setRayOnPointerInfo;
  32710. /**
  32711. * Use this method to simulate a pointer move on a mesh
  32712. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32713. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32714. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32715. * @returns the current scene
  32716. */
  32717. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32718. private _processPointerMove;
  32719. private _checkPrePointerObservable;
  32720. /**
  32721. * Use this method to simulate a pointer down on a mesh
  32722. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32723. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32724. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32725. * @returns the current scene
  32726. */
  32727. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32728. private _processPointerDown;
  32729. /**
  32730. * Use this method to simulate a pointer up on a mesh
  32731. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32732. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32733. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32734. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32735. * @returns the current scene
  32736. */
  32737. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32738. private _processPointerUp;
  32739. /**
  32740. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32741. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32742. * @returns true if the pointer was captured
  32743. */
  32744. isPointerCaptured(pointerId?: number): boolean;
  32745. /** @hidden */
  32746. _isPointerSwiping(): boolean;
  32747. /**
  32748. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32749. * @param attachUp defines if you want to attach events to pointerup
  32750. * @param attachDown defines if you want to attach events to pointerdown
  32751. * @param attachMove defines if you want to attach events to pointermove
  32752. */
  32753. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32754. /** Detaches all event handlers*/
  32755. detachControl(): void;
  32756. /**
  32757. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32758. * Delay loaded resources are not taking in account
  32759. * @return true if all required resources are ready
  32760. */
  32761. isReady(): boolean;
  32762. /** Resets all cached information relative to material (including effect and visibility) */
  32763. resetCachedMaterial(): void;
  32764. /**
  32765. * Registers a function to be called before every frame render
  32766. * @param func defines the function to register
  32767. */
  32768. registerBeforeRender(func: () => void): void;
  32769. /**
  32770. * Unregisters a function called before every frame render
  32771. * @param func defines the function to unregister
  32772. */
  32773. unregisterBeforeRender(func: () => void): void;
  32774. /**
  32775. * Registers a function to be called after every frame render
  32776. * @param func defines the function to register
  32777. */
  32778. registerAfterRender(func: () => void): void;
  32779. /**
  32780. * Unregisters a function called after every frame render
  32781. * @param func defines the function to unregister
  32782. */
  32783. unregisterAfterRender(func: () => void): void;
  32784. private _executeOnceBeforeRender;
  32785. /**
  32786. * The provided function will run before render once and will be disposed afterwards.
  32787. * A timeout delay can be provided so that the function will be executed in N ms.
  32788. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32789. * @param func The function to be executed.
  32790. * @param timeout optional delay in ms
  32791. */
  32792. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32793. /** @hidden */
  32794. _addPendingData(data: any): void;
  32795. /** @hidden */
  32796. _removePendingData(data: any): void;
  32797. /**
  32798. * Returns the number of items waiting to be loaded
  32799. * @returns the number of items waiting to be loaded
  32800. */
  32801. getWaitingItemsCount(): number;
  32802. /**
  32803. * Returns a boolean indicating if the scene is still loading data
  32804. */
  32805. readonly isLoading: boolean;
  32806. /**
  32807. * Registers a function to be executed when the scene is ready
  32808. * @param {Function} func - the function to be executed
  32809. */
  32810. executeWhenReady(func: () => void): void;
  32811. /**
  32812. * Returns a promise that resolves when the scene is ready
  32813. * @returns A promise that resolves when the scene is ready
  32814. */
  32815. whenReadyAsync(): Promise<void>;
  32816. /** @hidden */
  32817. _checkIsReady(): void;
  32818. /**
  32819. * Gets all animatable attached to the scene
  32820. */
  32821. readonly animatables: Animatable[];
  32822. /**
  32823. * Resets the last animation time frame.
  32824. * Useful to override when animations start running when loading a scene for the first time.
  32825. */
  32826. resetLastAnimationTimeFrame(): void;
  32827. /** @hidden */
  32828. _switchToAlternateCameraConfiguration(active: boolean): void;
  32829. /**
  32830. * Gets the current view matrix
  32831. * @returns a Matrix
  32832. */
  32833. getViewMatrix(): Matrix;
  32834. /**
  32835. * Gets the current projection matrix
  32836. * @returns a Matrix
  32837. */
  32838. getProjectionMatrix(): Matrix;
  32839. /**
  32840. * Gets the current transform matrix
  32841. * @returns a Matrix made of View * Projection
  32842. */
  32843. getTransformMatrix(): Matrix;
  32844. /**
  32845. * Sets the current transform matrix
  32846. * @param view defines the View matrix to use
  32847. * @param projection defines the Projection matrix to use
  32848. */
  32849. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32850. /** @hidden */
  32851. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32852. /**
  32853. * Gets the uniform buffer used to store scene data
  32854. * @returns a UniformBuffer
  32855. */
  32856. getSceneUniformBuffer(): UniformBuffer;
  32857. /**
  32858. * Gets an unique (relatively to the current scene) Id
  32859. * @returns an unique number for the scene
  32860. */
  32861. getUniqueId(): number;
  32862. /**
  32863. * Add a mesh to the list of scene's meshes
  32864. * @param newMesh defines the mesh to add
  32865. * @param recursive if all child meshes should also be added to the scene
  32866. */
  32867. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32868. /**
  32869. * Remove a mesh for the list of scene's meshes
  32870. * @param toRemove defines the mesh to remove
  32871. * @param recursive if all child meshes should also be removed from the scene
  32872. * @returns the index where the mesh was in the mesh list
  32873. */
  32874. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32875. /**
  32876. * Add a transform node to the list of scene's transform nodes
  32877. * @param newTransformNode defines the transform node to add
  32878. */
  32879. addTransformNode(newTransformNode: TransformNode): void;
  32880. /**
  32881. * Remove a transform node for the list of scene's transform nodes
  32882. * @param toRemove defines the transform node to remove
  32883. * @returns the index where the transform node was in the transform node list
  32884. */
  32885. removeTransformNode(toRemove: TransformNode): number;
  32886. /**
  32887. * Remove a skeleton for the list of scene's skeletons
  32888. * @param toRemove defines the skeleton to remove
  32889. * @returns the index where the skeleton was in the skeleton list
  32890. */
  32891. removeSkeleton(toRemove: Skeleton): number;
  32892. /**
  32893. * Remove a morph target for the list of scene's morph targets
  32894. * @param toRemove defines the morph target to remove
  32895. * @returns the index where the morph target was in the morph target list
  32896. */
  32897. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32898. /**
  32899. * Remove a light for the list of scene's lights
  32900. * @param toRemove defines the light to remove
  32901. * @returns the index where the light was in the light list
  32902. */
  32903. removeLight(toRemove: Light): number;
  32904. /**
  32905. * Remove a camera for the list of scene's cameras
  32906. * @param toRemove defines the camera to remove
  32907. * @returns the index where the camera was in the camera list
  32908. */
  32909. removeCamera(toRemove: Camera): number;
  32910. /**
  32911. * Remove a particle system for the list of scene's particle systems
  32912. * @param toRemove defines the particle system to remove
  32913. * @returns the index where the particle system was in the particle system list
  32914. */
  32915. removeParticleSystem(toRemove: IParticleSystem): number;
  32916. /**
  32917. * Remove a animation for the list of scene's animations
  32918. * @param toRemove defines the animation to remove
  32919. * @returns the index where the animation was in the animation list
  32920. */
  32921. removeAnimation(toRemove: Animation): number;
  32922. /**
  32923. * Removes the given animation group from this scene.
  32924. * @param toRemove The animation group to remove
  32925. * @returns The index of the removed animation group
  32926. */
  32927. removeAnimationGroup(toRemove: AnimationGroup): number;
  32928. /**
  32929. * Removes the given multi-material from this scene.
  32930. * @param toRemove The multi-material to remove
  32931. * @returns The index of the removed multi-material
  32932. */
  32933. removeMultiMaterial(toRemove: MultiMaterial): number;
  32934. /**
  32935. * Removes the given material from this scene.
  32936. * @param toRemove The material to remove
  32937. * @returns The index of the removed material
  32938. */
  32939. removeMaterial(toRemove: Material): number;
  32940. /**
  32941. * Removes the given action manager from this scene.
  32942. * @param toRemove The action manager to remove
  32943. * @returns The index of the removed action manager
  32944. */
  32945. removeActionManager(toRemove: AbstractActionManager): number;
  32946. /**
  32947. * Removes the given texture from this scene.
  32948. * @param toRemove The texture to remove
  32949. * @returns The index of the removed texture
  32950. */
  32951. removeTexture(toRemove: BaseTexture): number;
  32952. /**
  32953. * Adds the given light to this scene
  32954. * @param newLight The light to add
  32955. */
  32956. addLight(newLight: Light): void;
  32957. /**
  32958. * Sorts the list list based on light priorities
  32959. */
  32960. sortLightsByPriority(): void;
  32961. /**
  32962. * Adds the given camera to this scene
  32963. * @param newCamera The camera to add
  32964. */
  32965. addCamera(newCamera: Camera): void;
  32966. /**
  32967. * Adds the given skeleton to this scene
  32968. * @param newSkeleton The skeleton to add
  32969. */
  32970. addSkeleton(newSkeleton: Skeleton): void;
  32971. /**
  32972. * Adds the given particle system to this scene
  32973. * @param newParticleSystem The particle system to add
  32974. */
  32975. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32976. /**
  32977. * Adds the given animation to this scene
  32978. * @param newAnimation The animation to add
  32979. */
  32980. addAnimation(newAnimation: Animation): void;
  32981. /**
  32982. * Adds the given animation group to this scene.
  32983. * @param newAnimationGroup The animation group to add
  32984. */
  32985. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32986. /**
  32987. * Adds the given multi-material to this scene
  32988. * @param newMultiMaterial The multi-material to add
  32989. */
  32990. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32991. /**
  32992. * Adds the given material to this scene
  32993. * @param newMaterial The material to add
  32994. */
  32995. addMaterial(newMaterial: Material): void;
  32996. /**
  32997. * Adds the given morph target to this scene
  32998. * @param newMorphTargetManager The morph target to add
  32999. */
  33000. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33001. /**
  33002. * Adds the given geometry to this scene
  33003. * @param newGeometry The geometry to add
  33004. */
  33005. addGeometry(newGeometry: Geometry): void;
  33006. /**
  33007. * Adds the given action manager to this scene
  33008. * @param newActionManager The action manager to add
  33009. */
  33010. addActionManager(newActionManager: AbstractActionManager): void;
  33011. /**
  33012. * Adds the given texture to this scene.
  33013. * @param newTexture The texture to add
  33014. */
  33015. addTexture(newTexture: BaseTexture): void;
  33016. /**
  33017. * Switch active camera
  33018. * @param newCamera defines the new active camera
  33019. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33020. */
  33021. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33022. /**
  33023. * sets the active camera of the scene using its ID
  33024. * @param id defines the camera's ID
  33025. * @return the new active camera or null if none found.
  33026. */
  33027. setActiveCameraByID(id: string): Nullable<Camera>;
  33028. /**
  33029. * sets the active camera of the scene using its name
  33030. * @param name defines the camera's name
  33031. * @returns the new active camera or null if none found.
  33032. */
  33033. setActiveCameraByName(name: string): Nullable<Camera>;
  33034. /**
  33035. * get an animation group using its name
  33036. * @param name defines the material's name
  33037. * @return the animation group or null if none found.
  33038. */
  33039. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33040. /**
  33041. * get a material using its id
  33042. * @param id defines the material's ID
  33043. * @return the material or null if none found.
  33044. */
  33045. getMaterialByID(id: string): Nullable<Material>;
  33046. /**
  33047. * Gets a material using its name
  33048. * @param name defines the material's name
  33049. * @return the material or null if none found.
  33050. */
  33051. getMaterialByName(name: string): Nullable<Material>;
  33052. /**
  33053. * Gets a camera using its id
  33054. * @param id defines the id to look for
  33055. * @returns the camera or null if not found
  33056. */
  33057. getCameraByID(id: string): Nullable<Camera>;
  33058. /**
  33059. * Gets a camera using its unique id
  33060. * @param uniqueId defines the unique id to look for
  33061. * @returns the camera or null if not found
  33062. */
  33063. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33064. /**
  33065. * Gets a camera using its name
  33066. * @param name defines the camera's name
  33067. * @return the camera or null if none found.
  33068. */
  33069. getCameraByName(name: string): Nullable<Camera>;
  33070. /**
  33071. * Gets a bone using its id
  33072. * @param id defines the bone's id
  33073. * @return the bone or null if not found
  33074. */
  33075. getBoneByID(id: string): Nullable<Bone>;
  33076. /**
  33077. * Gets a bone using its id
  33078. * @param name defines the bone's name
  33079. * @return the bone or null if not found
  33080. */
  33081. getBoneByName(name: string): Nullable<Bone>;
  33082. /**
  33083. * Gets a light node using its name
  33084. * @param name defines the the light's name
  33085. * @return the light or null if none found.
  33086. */
  33087. getLightByName(name: string): Nullable<Light>;
  33088. /**
  33089. * Gets a light node using its id
  33090. * @param id defines the light's id
  33091. * @return the light or null if none found.
  33092. */
  33093. getLightByID(id: string): Nullable<Light>;
  33094. /**
  33095. * Gets a light node using its scene-generated unique ID
  33096. * @param uniqueId defines the light's unique id
  33097. * @return the light or null if none found.
  33098. */
  33099. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33100. /**
  33101. * Gets a particle system by id
  33102. * @param id defines the particle system id
  33103. * @return the corresponding system or null if none found
  33104. */
  33105. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33106. /**
  33107. * Gets a geometry using its ID
  33108. * @param id defines the geometry's id
  33109. * @return the geometry or null if none found.
  33110. */
  33111. getGeometryByID(id: string): Nullable<Geometry>;
  33112. private _getGeometryByUniqueID;
  33113. /**
  33114. * Add a new geometry to this scene
  33115. * @param geometry defines the geometry to be added to the scene.
  33116. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33117. * @return a boolean defining if the geometry was added or not
  33118. */
  33119. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33120. /**
  33121. * Removes an existing geometry
  33122. * @param geometry defines the geometry to be removed from the scene
  33123. * @return a boolean defining if the geometry was removed or not
  33124. */
  33125. removeGeometry(geometry: Geometry): boolean;
  33126. /**
  33127. * Gets the list of geometries attached to the scene
  33128. * @returns an array of Geometry
  33129. */
  33130. getGeometries(): Geometry[];
  33131. /**
  33132. * Gets the first added mesh found of a given ID
  33133. * @param id defines the id to search for
  33134. * @return the mesh found or null if not found at all
  33135. */
  33136. getMeshByID(id: string): Nullable<AbstractMesh>;
  33137. /**
  33138. * Gets a list of meshes using their id
  33139. * @param id defines the id to search for
  33140. * @returns a list of meshes
  33141. */
  33142. getMeshesByID(id: string): Array<AbstractMesh>;
  33143. /**
  33144. * Gets the first added transform node found of a given ID
  33145. * @param id defines the id to search for
  33146. * @return the found transform node or null if not found at all.
  33147. */
  33148. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33149. /**
  33150. * Gets a list of transform nodes using their id
  33151. * @param id defines the id to search for
  33152. * @returns a list of transform nodes
  33153. */
  33154. getTransformNodesByID(id: string): Array<TransformNode>;
  33155. /**
  33156. * Gets a mesh with its auto-generated unique id
  33157. * @param uniqueId defines the unique id to search for
  33158. * @return the found mesh or null if not found at all.
  33159. */
  33160. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33161. /**
  33162. * Gets a the last added mesh using a given id
  33163. * @param id defines the id to search for
  33164. * @return the found mesh or null if not found at all.
  33165. */
  33166. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33167. /**
  33168. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33169. * @param id defines the id to search for
  33170. * @return the found node or null if not found at all
  33171. */
  33172. getLastEntryByID(id: string): Nullable<Node>;
  33173. /**
  33174. * Gets a node (Mesh, Camera, Light) using a given id
  33175. * @param id defines the id to search for
  33176. * @return the found node or null if not found at all
  33177. */
  33178. getNodeByID(id: string): Nullable<Node>;
  33179. /**
  33180. * Gets a node (Mesh, Camera, Light) using a given name
  33181. * @param name defines the name to search for
  33182. * @return the found node or null if not found at all.
  33183. */
  33184. getNodeByName(name: string): Nullable<Node>;
  33185. /**
  33186. * Gets a mesh using a given name
  33187. * @param name defines the name to search for
  33188. * @return the found mesh or null if not found at all.
  33189. */
  33190. getMeshByName(name: string): Nullable<AbstractMesh>;
  33191. /**
  33192. * Gets a transform node using a given name
  33193. * @param name defines the name to search for
  33194. * @return the found transform node or null if not found at all.
  33195. */
  33196. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33197. /**
  33198. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33199. * @param id defines the id to search for
  33200. * @return the found skeleton or null if not found at all.
  33201. */
  33202. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33203. /**
  33204. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33205. * @param id defines the id to search for
  33206. * @return the found skeleton or null if not found at all.
  33207. */
  33208. getSkeletonById(id: string): Nullable<Skeleton>;
  33209. /**
  33210. * Gets a skeleton using a given name
  33211. * @param name defines the name to search for
  33212. * @return the found skeleton or null if not found at all.
  33213. */
  33214. getSkeletonByName(name: string): Nullable<Skeleton>;
  33215. /**
  33216. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33217. * @param id defines the id to search for
  33218. * @return the found morph target manager or null if not found at all.
  33219. */
  33220. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33221. /**
  33222. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33223. * @param id defines the id to search for
  33224. * @return the found morph target or null if not found at all.
  33225. */
  33226. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33227. /**
  33228. * Gets a boolean indicating if the given mesh is active
  33229. * @param mesh defines the mesh to look for
  33230. * @returns true if the mesh is in the active list
  33231. */
  33232. isActiveMesh(mesh: AbstractMesh): boolean;
  33233. /**
  33234. * Return a unique id as a string which can serve as an identifier for the scene
  33235. */
  33236. readonly uid: string;
  33237. /**
  33238. * Add an externaly attached data from its key.
  33239. * This method call will fail and return false, if such key already exists.
  33240. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33241. * @param key the unique key that identifies the data
  33242. * @param data the data object to associate to the key for this Engine instance
  33243. * @return true if no such key were already present and the data was added successfully, false otherwise
  33244. */
  33245. addExternalData<T>(key: string, data: T): boolean;
  33246. /**
  33247. * Get an externaly attached data from its key
  33248. * @param key the unique key that identifies the data
  33249. * @return the associated data, if present (can be null), or undefined if not present
  33250. */
  33251. getExternalData<T>(key: string): Nullable<T>;
  33252. /**
  33253. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33254. * @param key the unique key that identifies the data
  33255. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33256. * @return the associated data, can be null if the factory returned null.
  33257. */
  33258. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33259. /**
  33260. * Remove an externaly attached data from the Engine instance
  33261. * @param key the unique key that identifies the data
  33262. * @return true if the data was successfully removed, false if it doesn't exist
  33263. */
  33264. removeExternalData(key: string): boolean;
  33265. private _evaluateSubMesh;
  33266. /**
  33267. * Clear the processed materials smart array preventing retention point in material dispose.
  33268. */
  33269. freeProcessedMaterials(): void;
  33270. private _preventFreeActiveMeshesAndRenderingGroups;
  33271. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33272. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33273. * when disposing several meshes in a row or a hierarchy of meshes.
  33274. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33275. */
  33276. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33277. /**
  33278. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33279. */
  33280. freeActiveMeshes(): void;
  33281. /**
  33282. * Clear the info related to rendering groups preventing retention points during dispose.
  33283. */
  33284. freeRenderingGroups(): void;
  33285. /** @hidden */
  33286. _isInIntermediateRendering(): boolean;
  33287. /**
  33288. * Lambda returning the list of potentially active meshes.
  33289. */
  33290. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33291. /**
  33292. * Lambda returning the list of potentially active sub meshes.
  33293. */
  33294. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33295. /**
  33296. * Lambda returning the list of potentially intersecting sub meshes.
  33297. */
  33298. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33299. /**
  33300. * Lambda returning the list of potentially colliding sub meshes.
  33301. */
  33302. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33303. private _activeMeshesFrozen;
  33304. /**
  33305. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33306. * @returns the current scene
  33307. */
  33308. freezeActiveMeshes(): Scene;
  33309. /**
  33310. * Use this function to restart evaluating active meshes on every frame
  33311. * @returns the current scene
  33312. */
  33313. unfreezeActiveMeshes(): Scene;
  33314. private _evaluateActiveMeshes;
  33315. private _activeMesh;
  33316. /**
  33317. * Update the transform matrix to update from the current active camera
  33318. * @param force defines a boolean used to force the update even if cache is up to date
  33319. */
  33320. updateTransformMatrix(force?: boolean): void;
  33321. /**
  33322. * 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)
  33323. * @param alternateCamera defines the camera to use
  33324. */
  33325. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33326. /** @hidden */
  33327. _allowPostProcessClearColor: boolean;
  33328. private _renderForCamera;
  33329. private _processSubCameras;
  33330. private _checkIntersections;
  33331. /** @hidden */
  33332. _advancePhysicsEngineStep(step: number): void;
  33333. /**
  33334. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33335. */
  33336. getDeterministicFrameTime: () => number;
  33337. /** @hidden */
  33338. _animate(): void;
  33339. /**
  33340. * Render the scene
  33341. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33342. */
  33343. render(updateCameras?: boolean): void;
  33344. /**
  33345. * Freeze all materials
  33346. * A frozen material will not be updatable but should be faster to render
  33347. */
  33348. freezeMaterials(): void;
  33349. /**
  33350. * Unfreeze all materials
  33351. * A frozen material will not be updatable but should be faster to render
  33352. */
  33353. unfreezeMaterials(): void;
  33354. /**
  33355. * Releases all held ressources
  33356. */
  33357. dispose(): void;
  33358. /**
  33359. * Gets if the scene is already disposed
  33360. */
  33361. readonly isDisposed: boolean;
  33362. /**
  33363. * Call this function to reduce memory footprint of the scene.
  33364. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33365. */
  33366. clearCachedVertexData(): void;
  33367. /**
  33368. * This function will remove the local cached buffer data from texture.
  33369. * It will save memory but will prevent the texture from being rebuilt
  33370. */
  33371. cleanCachedTextureBuffer(): void;
  33372. /**
  33373. * Get the world extend vectors with an optional filter
  33374. *
  33375. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33376. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33377. */
  33378. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33379. min: Vector3;
  33380. max: Vector3;
  33381. };
  33382. /**
  33383. * Creates a ray that can be used to pick in the scene
  33384. * @param x defines the x coordinate of the origin (on-screen)
  33385. * @param y defines the y coordinate of the origin (on-screen)
  33386. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33387. * @param camera defines the camera to use for the picking
  33388. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33389. * @returns a Ray
  33390. */
  33391. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33392. /**
  33393. * Creates a ray that can be used to pick in the scene
  33394. * @param x defines the x coordinate of the origin (on-screen)
  33395. * @param y defines the y coordinate of the origin (on-screen)
  33396. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33397. * @param result defines the ray where to store the picking ray
  33398. * @param camera defines the camera to use for the picking
  33399. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33400. * @returns the current scene
  33401. */
  33402. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33403. /**
  33404. * Creates a ray that can be used to pick in the scene
  33405. * @param x defines the x coordinate of the origin (on-screen)
  33406. * @param y defines the y coordinate of the origin (on-screen)
  33407. * @param camera defines the camera to use for the picking
  33408. * @returns a Ray
  33409. */
  33410. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33411. /**
  33412. * Creates a ray that can be used to pick in the scene
  33413. * @param x defines the x coordinate of the origin (on-screen)
  33414. * @param y defines the y coordinate of the origin (on-screen)
  33415. * @param result defines the ray where to store the picking ray
  33416. * @param camera defines the camera to use for the picking
  33417. * @returns the current scene
  33418. */
  33419. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33420. /** Launch a ray to try to pick a mesh in the scene
  33421. * @param x position on screen
  33422. * @param y position on screen
  33423. * @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
  33424. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33425. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33426. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33427. * @returns a PickingInfo
  33428. */
  33429. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33430. /** Use the given ray to pick a mesh in the scene
  33431. * @param ray The ray to use to pick meshes
  33432. * @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
  33433. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33434. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33435. * @returns a PickingInfo
  33436. */
  33437. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33438. /**
  33439. * Launch a ray to try to pick a mesh in the scene
  33440. * @param x X position on screen
  33441. * @param y Y position on screen
  33442. * @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
  33443. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33444. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33445. * @returns an array of PickingInfo
  33446. */
  33447. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33448. /**
  33449. * Launch a ray to try to pick a mesh in the scene
  33450. * @param ray Ray to use
  33451. * @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
  33452. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33453. * @returns an array of PickingInfo
  33454. */
  33455. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33456. /**
  33457. * Force the value of meshUnderPointer
  33458. * @param mesh defines the mesh to use
  33459. */
  33460. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33461. /**
  33462. * Gets the mesh under the pointer
  33463. * @returns a Mesh or null if no mesh is under the pointer
  33464. */
  33465. getPointerOverMesh(): Nullable<AbstractMesh>;
  33466. /** @hidden */
  33467. _rebuildGeometries(): void;
  33468. /** @hidden */
  33469. _rebuildTextures(): void;
  33470. private _getByTags;
  33471. /**
  33472. * Get a list of meshes by tags
  33473. * @param tagsQuery defines the tags query to use
  33474. * @param forEach defines a predicate used to filter results
  33475. * @returns an array of Mesh
  33476. */
  33477. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33478. /**
  33479. * Get a list of cameras by tags
  33480. * @param tagsQuery defines the tags query to use
  33481. * @param forEach defines a predicate used to filter results
  33482. * @returns an array of Camera
  33483. */
  33484. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33485. /**
  33486. * Get a list of lights by tags
  33487. * @param tagsQuery defines the tags query to use
  33488. * @param forEach defines a predicate used to filter results
  33489. * @returns an array of Light
  33490. */
  33491. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33492. /**
  33493. * Get a list of materials by tags
  33494. * @param tagsQuery defines the tags query to use
  33495. * @param forEach defines a predicate used to filter results
  33496. * @returns an array of Material
  33497. */
  33498. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33499. /**
  33500. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33501. * This allowed control for front to back rendering or reversly depending of the special needs.
  33502. *
  33503. * @param renderingGroupId The rendering group id corresponding to its index
  33504. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33505. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33506. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33507. */
  33508. 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;
  33509. /**
  33510. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33511. *
  33512. * @param renderingGroupId The rendering group id corresponding to its index
  33513. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33514. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33515. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33516. */
  33517. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33518. /**
  33519. * Gets the current auto clear configuration for one rendering group of the rendering
  33520. * manager.
  33521. * @param index the rendering group index to get the information for
  33522. * @returns The auto clear setup for the requested rendering group
  33523. */
  33524. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33525. private _blockMaterialDirtyMechanism;
  33526. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33527. blockMaterialDirtyMechanism: boolean;
  33528. /**
  33529. * Will flag all materials as dirty to trigger new shader compilation
  33530. * @param flag defines the flag used to specify which material part must be marked as dirty
  33531. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33532. */
  33533. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33534. /** @hidden */
  33535. _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;
  33536. /** @hidden */
  33537. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33538. }
  33539. }
  33540. declare module "babylonjs/assetContainer" {
  33541. import { AbstractScene } from "babylonjs/abstractScene";
  33542. import { Scene } from "babylonjs/scene";
  33543. import { Mesh } from "babylonjs/Meshes/mesh";
  33544. /**
  33545. * Set of assets to keep when moving a scene into an asset container.
  33546. */
  33547. export class KeepAssets extends AbstractScene {
  33548. }
  33549. /**
  33550. * Container with a set of assets that can be added or removed from a scene.
  33551. */
  33552. export class AssetContainer extends AbstractScene {
  33553. /**
  33554. * The scene the AssetContainer belongs to.
  33555. */
  33556. scene: Scene;
  33557. /**
  33558. * Instantiates an AssetContainer.
  33559. * @param scene The scene the AssetContainer belongs to.
  33560. */
  33561. constructor(scene: Scene);
  33562. /**
  33563. * Adds all the assets from the container to the scene.
  33564. */
  33565. addAllToScene(): void;
  33566. /**
  33567. * Removes all the assets in the container from the scene
  33568. */
  33569. removeAllFromScene(): void;
  33570. /**
  33571. * Disposes all the assets in the container
  33572. */
  33573. dispose(): void;
  33574. private _moveAssets;
  33575. /**
  33576. * Removes all the assets contained in the scene and adds them to the container.
  33577. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33578. */
  33579. moveAllFromScene(keepAssets?: KeepAssets): void;
  33580. /**
  33581. * 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.
  33582. * @returns the root mesh
  33583. */
  33584. createRootMesh(): Mesh;
  33585. }
  33586. }
  33587. declare module "babylonjs/abstractScene" {
  33588. import { Scene } from "babylonjs/scene";
  33589. import { Nullable } from "babylonjs/types";
  33590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33591. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33592. import { Geometry } from "babylonjs/Meshes/geometry";
  33593. import { Skeleton } from "babylonjs/Bones/skeleton";
  33594. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33595. import { AssetContainer } from "babylonjs/assetContainer";
  33596. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33597. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33598. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33599. import { Material } from "babylonjs/Materials/material";
  33600. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33601. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33602. import { Camera } from "babylonjs/Cameras/camera";
  33603. import { Light } from "babylonjs/Lights/light";
  33604. import { Node } from "babylonjs/node";
  33605. import { Animation } from "babylonjs/Animations/animation";
  33606. /**
  33607. * Defines how the parser contract is defined.
  33608. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33609. */
  33610. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33611. /**
  33612. * Defines how the individual parser contract is defined.
  33613. * These parser can parse an individual asset
  33614. */
  33615. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33616. /**
  33617. * Base class of the scene acting as a container for the different elements composing a scene.
  33618. * This class is dynamically extended by the different components of the scene increasing
  33619. * flexibility and reducing coupling
  33620. */
  33621. export abstract class AbstractScene {
  33622. /**
  33623. * Stores the list of available parsers in the application.
  33624. */
  33625. private static _BabylonFileParsers;
  33626. /**
  33627. * Stores the list of available individual parsers in the application.
  33628. */
  33629. private static _IndividualBabylonFileParsers;
  33630. /**
  33631. * Adds a parser in the list of available ones
  33632. * @param name Defines the name of the parser
  33633. * @param parser Defines the parser to add
  33634. */
  33635. static AddParser(name: string, parser: BabylonFileParser): void;
  33636. /**
  33637. * Gets a general parser from the list of avaialble ones
  33638. * @param name Defines the name of the parser
  33639. * @returns the requested parser or null
  33640. */
  33641. static GetParser(name: string): Nullable<BabylonFileParser>;
  33642. /**
  33643. * Adds n individual parser in the list of available ones
  33644. * @param name Defines the name of the parser
  33645. * @param parser Defines the parser to add
  33646. */
  33647. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33648. /**
  33649. * Gets an individual parser from the list of avaialble ones
  33650. * @param name Defines the name of the parser
  33651. * @returns the requested parser or null
  33652. */
  33653. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33654. /**
  33655. * Parser json data and populate both a scene and its associated container object
  33656. * @param jsonData Defines the data to parse
  33657. * @param scene Defines the scene to parse the data for
  33658. * @param container Defines the container attached to the parsing sequence
  33659. * @param rootUrl Defines the root url of the data
  33660. */
  33661. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33662. /**
  33663. * Gets the list of root nodes (ie. nodes with no parent)
  33664. */
  33665. rootNodes: Node[];
  33666. /** All of the cameras added to this scene
  33667. * @see http://doc.babylonjs.com/babylon101/cameras
  33668. */
  33669. cameras: Camera[];
  33670. /**
  33671. * All of the lights added to this scene
  33672. * @see http://doc.babylonjs.com/babylon101/lights
  33673. */
  33674. lights: Light[];
  33675. /**
  33676. * All of the (abstract) meshes added to this scene
  33677. */
  33678. meshes: AbstractMesh[];
  33679. /**
  33680. * The list of skeletons added to the scene
  33681. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33682. */
  33683. skeletons: Skeleton[];
  33684. /**
  33685. * All of the particle systems added to this scene
  33686. * @see http://doc.babylonjs.com/babylon101/particles
  33687. */
  33688. particleSystems: IParticleSystem[];
  33689. /**
  33690. * Gets a list of Animations associated with the scene
  33691. */
  33692. animations: Animation[];
  33693. /**
  33694. * All of the animation groups added to this scene
  33695. * @see http://doc.babylonjs.com/how_to/group
  33696. */
  33697. animationGroups: AnimationGroup[];
  33698. /**
  33699. * All of the multi-materials added to this scene
  33700. * @see http://doc.babylonjs.com/how_to/multi_materials
  33701. */
  33702. multiMaterials: MultiMaterial[];
  33703. /**
  33704. * All of the materials added to this scene
  33705. * In the context of a Scene, it is not supposed to be modified manually.
  33706. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33707. * Note also that the order of the Material wihin the array is not significant and might change.
  33708. * @see http://doc.babylonjs.com/babylon101/materials
  33709. */
  33710. materials: Material[];
  33711. /**
  33712. * The list of morph target managers added to the scene
  33713. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33714. */
  33715. morphTargetManagers: MorphTargetManager[];
  33716. /**
  33717. * The list of geometries used in the scene.
  33718. */
  33719. geometries: Geometry[];
  33720. /**
  33721. * All of the tranform nodes added to this scene
  33722. * In the context of a Scene, it is not supposed to be modified manually.
  33723. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33724. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33725. * @see http://doc.babylonjs.com/how_to/transformnode
  33726. */
  33727. transformNodes: TransformNode[];
  33728. /**
  33729. * ActionManagers available on the scene.
  33730. */
  33731. actionManagers: AbstractActionManager[];
  33732. /**
  33733. * Textures to keep.
  33734. */
  33735. textures: BaseTexture[];
  33736. }
  33737. }
  33738. declare module "babylonjs/Audio/sound" {
  33739. import { Observable } from "babylonjs/Misc/observable";
  33740. import { Vector3 } from "babylonjs/Maths/math";
  33741. import { Nullable } from "babylonjs/types";
  33742. import { Scene } from "babylonjs/scene";
  33743. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33744. /**
  33745. * Defines a sound that can be played in the application.
  33746. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33748. */
  33749. export class Sound {
  33750. /**
  33751. * The name of the sound in the scene.
  33752. */
  33753. name: string;
  33754. /**
  33755. * Does the sound autoplay once loaded.
  33756. */
  33757. autoplay: boolean;
  33758. /**
  33759. * Does the sound loop after it finishes playing once.
  33760. */
  33761. loop: boolean;
  33762. /**
  33763. * Does the sound use a custom attenuation curve to simulate the falloff
  33764. * happening when the source gets further away from the camera.
  33765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33766. */
  33767. useCustomAttenuation: boolean;
  33768. /**
  33769. * The sound track id this sound belongs to.
  33770. */
  33771. soundTrackId: number;
  33772. /**
  33773. * Is this sound currently played.
  33774. */
  33775. isPlaying: boolean;
  33776. /**
  33777. * Is this sound currently paused.
  33778. */
  33779. isPaused: boolean;
  33780. /**
  33781. * Does this sound enables spatial sound.
  33782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33783. */
  33784. spatialSound: boolean;
  33785. /**
  33786. * Define the reference distance the sound should be heard perfectly.
  33787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33788. */
  33789. refDistance: number;
  33790. /**
  33791. * Define the roll off factor of spatial sounds.
  33792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33793. */
  33794. rolloffFactor: number;
  33795. /**
  33796. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33798. */
  33799. maxDistance: number;
  33800. /**
  33801. * Define the distance attenuation model the sound will follow.
  33802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33803. */
  33804. distanceModel: string;
  33805. /**
  33806. * @hidden
  33807. * Back Compat
  33808. **/
  33809. onended: () => any;
  33810. /**
  33811. * Observable event when the current playing sound finishes.
  33812. */
  33813. onEndedObservable: Observable<Sound>;
  33814. private _panningModel;
  33815. private _playbackRate;
  33816. private _streaming;
  33817. private _startTime;
  33818. private _startOffset;
  33819. private _position;
  33820. /** @hidden */
  33821. _positionInEmitterSpace: boolean;
  33822. private _localDirection;
  33823. private _volume;
  33824. private _isReadyToPlay;
  33825. private _isDirectional;
  33826. private _readyToPlayCallback;
  33827. private _audioBuffer;
  33828. private _soundSource;
  33829. private _streamingSource;
  33830. private _soundPanner;
  33831. private _soundGain;
  33832. private _inputAudioNode;
  33833. private _outputAudioNode;
  33834. private _coneInnerAngle;
  33835. private _coneOuterAngle;
  33836. private _coneOuterGain;
  33837. private _scene;
  33838. private _connectedTransformNode;
  33839. private _customAttenuationFunction;
  33840. private _registerFunc;
  33841. private _isOutputConnected;
  33842. private _htmlAudioElement;
  33843. private _urlType;
  33844. /** @hidden */
  33845. static _SceneComponentInitialization: (scene: Scene) => void;
  33846. /**
  33847. * Create a sound and attach it to a scene
  33848. * @param name Name of your sound
  33849. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33850. * @param scene defines the scene the sound belongs to
  33851. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33852. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33853. */
  33854. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33855. /**
  33856. * Release the sound and its associated resources
  33857. */
  33858. dispose(): void;
  33859. /**
  33860. * Gets if the sounds is ready to be played or not.
  33861. * @returns true if ready, otherwise false
  33862. */
  33863. isReady(): boolean;
  33864. private _soundLoaded;
  33865. /**
  33866. * Sets the data of the sound from an audiobuffer
  33867. * @param audioBuffer The audioBuffer containing the data
  33868. */
  33869. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33870. /**
  33871. * Updates the current sounds options such as maxdistance, loop...
  33872. * @param options A JSON object containing values named as the object properties
  33873. */
  33874. updateOptions(options: any): void;
  33875. private _createSpatialParameters;
  33876. private _updateSpatialParameters;
  33877. /**
  33878. * Switch the panning model to HRTF:
  33879. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33881. */
  33882. switchPanningModelToHRTF(): void;
  33883. /**
  33884. * Switch the panning model to Equal Power:
  33885. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33887. */
  33888. switchPanningModelToEqualPower(): void;
  33889. private _switchPanningModel;
  33890. /**
  33891. * Connect this sound to a sound track audio node like gain...
  33892. * @param soundTrackAudioNode the sound track audio node to connect to
  33893. */
  33894. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33895. /**
  33896. * Transform this sound into a directional source
  33897. * @param coneInnerAngle Size of the inner cone in degree
  33898. * @param coneOuterAngle Size of the outer cone in degree
  33899. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33900. */
  33901. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33902. /**
  33903. * Gets or sets the inner angle for the directional cone.
  33904. */
  33905. /**
  33906. * Gets or sets the inner angle for the directional cone.
  33907. */
  33908. directionalConeInnerAngle: number;
  33909. /**
  33910. * Gets or sets the outer angle for the directional cone.
  33911. */
  33912. /**
  33913. * Gets or sets the outer angle for the directional cone.
  33914. */
  33915. directionalConeOuterAngle: number;
  33916. /**
  33917. * Sets the position of the emitter if spatial sound is enabled
  33918. * @param newPosition Defines the new posisiton
  33919. */
  33920. setPosition(newPosition: Vector3): void;
  33921. /**
  33922. * Sets the local direction of the emitter if spatial sound is enabled
  33923. * @param newLocalDirection Defines the new local direction
  33924. */
  33925. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33926. private _updateDirection;
  33927. /** @hidden */
  33928. updateDistanceFromListener(): void;
  33929. /**
  33930. * Sets a new custom attenuation function for the sound.
  33931. * @param callback Defines the function used for the attenuation
  33932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33933. */
  33934. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33935. /**
  33936. * Play the sound
  33937. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33938. * @param offset (optional) Start the sound setting it at a specific time
  33939. */
  33940. play(time?: number, offset?: number): void;
  33941. private _onended;
  33942. /**
  33943. * Stop the sound
  33944. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33945. */
  33946. stop(time?: number): void;
  33947. /**
  33948. * Put the sound in pause
  33949. */
  33950. pause(): void;
  33951. /**
  33952. * Sets a dedicated volume for this sounds
  33953. * @param newVolume Define the new volume of the sound
  33954. * @param time Define in how long the sound should be at this value
  33955. */
  33956. setVolume(newVolume: number, time?: number): void;
  33957. /**
  33958. * Set the sound play back rate
  33959. * @param newPlaybackRate Define the playback rate the sound should be played at
  33960. */
  33961. setPlaybackRate(newPlaybackRate: number): void;
  33962. /**
  33963. * Gets the volume of the sound.
  33964. * @returns the volume of the sound
  33965. */
  33966. getVolume(): number;
  33967. /**
  33968. * Attach the sound to a dedicated mesh
  33969. * @param transformNode The transform node to connect the sound with
  33970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33971. */
  33972. attachToMesh(transformNode: TransformNode): void;
  33973. /**
  33974. * Detach the sound from the previously attached mesh
  33975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33976. */
  33977. detachFromMesh(): void;
  33978. private _onRegisterAfterWorldMatrixUpdate;
  33979. /**
  33980. * Clone the current sound in the scene.
  33981. * @returns the new sound clone
  33982. */
  33983. clone(): Nullable<Sound>;
  33984. /**
  33985. * Gets the current underlying audio buffer containing the data
  33986. * @returns the audio buffer
  33987. */
  33988. getAudioBuffer(): Nullable<AudioBuffer>;
  33989. /**
  33990. * Serializes the Sound in a JSON representation
  33991. * @returns the JSON representation of the sound
  33992. */
  33993. serialize(): any;
  33994. /**
  33995. * Parse a JSON representation of a sound to innstantiate in a given scene
  33996. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33997. * @param scene Define the scene the new parsed sound should be created in
  33998. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33999. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34000. * @returns the newly parsed sound
  34001. */
  34002. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34003. }
  34004. }
  34005. declare module "babylonjs/Actions/directAudioActions" {
  34006. import { Action } from "babylonjs/Actions/action";
  34007. import { Condition } from "babylonjs/Actions/condition";
  34008. import { Sound } from "babylonjs/Audio/sound";
  34009. /**
  34010. * This defines an action helpful to play a defined sound on a triggered action.
  34011. */
  34012. export class PlaySoundAction extends Action {
  34013. private _sound;
  34014. /**
  34015. * Instantiate the action
  34016. * @param triggerOptions defines the trigger options
  34017. * @param sound defines the sound to play
  34018. * @param condition defines the trigger related conditions
  34019. */
  34020. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34021. /** @hidden */
  34022. _prepare(): void;
  34023. /**
  34024. * Execute the action and play the sound.
  34025. */
  34026. execute(): void;
  34027. /**
  34028. * Serializes the actions and its related information.
  34029. * @param parent defines the object to serialize in
  34030. * @returns the serialized object
  34031. */
  34032. serialize(parent: any): any;
  34033. }
  34034. /**
  34035. * This defines an action helpful to stop a defined sound on a triggered action.
  34036. */
  34037. export class StopSoundAction extends Action {
  34038. private _sound;
  34039. /**
  34040. * Instantiate the action
  34041. * @param triggerOptions defines the trigger options
  34042. * @param sound defines the sound to stop
  34043. * @param condition defines the trigger related conditions
  34044. */
  34045. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34046. /** @hidden */
  34047. _prepare(): void;
  34048. /**
  34049. * Execute the action and stop the sound.
  34050. */
  34051. execute(): void;
  34052. /**
  34053. * Serializes the actions and its related information.
  34054. * @param parent defines the object to serialize in
  34055. * @returns the serialized object
  34056. */
  34057. serialize(parent: any): any;
  34058. }
  34059. }
  34060. declare module "babylonjs/Actions/interpolateValueAction" {
  34061. import { Action } from "babylonjs/Actions/action";
  34062. import { Condition } from "babylonjs/Actions/condition";
  34063. import { Observable } from "babylonjs/Misc/observable";
  34064. /**
  34065. * This defines an action responsible to change the value of a property
  34066. * by interpolating between its current value and the newly set one once triggered.
  34067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34068. */
  34069. export class InterpolateValueAction extends Action {
  34070. /**
  34071. * Defines the path of the property where the value should be interpolated
  34072. */
  34073. propertyPath: string;
  34074. /**
  34075. * Defines the target value at the end of the interpolation.
  34076. */
  34077. value: any;
  34078. /**
  34079. * Defines the time it will take for the property to interpolate to the value.
  34080. */
  34081. duration: number;
  34082. /**
  34083. * Defines if the other scene animations should be stopped when the action has been triggered
  34084. */
  34085. stopOtherAnimations?: boolean;
  34086. /**
  34087. * Defines a callback raised once the interpolation animation has been done.
  34088. */
  34089. onInterpolationDone?: () => void;
  34090. /**
  34091. * Observable triggered once the interpolation animation has been done.
  34092. */
  34093. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34094. private _target;
  34095. private _effectiveTarget;
  34096. private _property;
  34097. /**
  34098. * Instantiate the action
  34099. * @param triggerOptions defines the trigger options
  34100. * @param target defines the object containing the value to interpolate
  34101. * @param propertyPath defines the path to the property in the target object
  34102. * @param value defines the target value at the end of the interpolation
  34103. * @param duration deines the time it will take for the property to interpolate to the value.
  34104. * @param condition defines the trigger related conditions
  34105. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34106. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34107. */
  34108. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34109. /** @hidden */
  34110. _prepare(): void;
  34111. /**
  34112. * Execute the action starts the value interpolation.
  34113. */
  34114. execute(): void;
  34115. /**
  34116. * Serializes the actions and its related information.
  34117. * @param parent defines the object to serialize in
  34118. * @returns the serialized object
  34119. */
  34120. serialize(parent: any): any;
  34121. }
  34122. }
  34123. declare module "babylonjs/Actions/index" {
  34124. export * from "babylonjs/Actions/action";
  34125. export * from "babylonjs/Actions/actionEvent";
  34126. export * from "babylonjs/Actions/actionManager";
  34127. export * from "babylonjs/Actions/condition";
  34128. export * from "babylonjs/Actions/directActions";
  34129. export * from "babylonjs/Actions/directAudioActions";
  34130. export * from "babylonjs/Actions/interpolateValueAction";
  34131. }
  34132. declare module "babylonjs/Animations/index" {
  34133. export * from "babylonjs/Animations/animatable";
  34134. export * from "babylonjs/Animations/animation";
  34135. export * from "babylonjs/Animations/animationGroup";
  34136. export * from "babylonjs/Animations/animationPropertiesOverride";
  34137. export * from "babylonjs/Animations/easing";
  34138. export * from "babylonjs/Animations/runtimeAnimation";
  34139. export * from "babylonjs/Animations/animationEvent";
  34140. export * from "babylonjs/Animations/animationGroup";
  34141. export * from "babylonjs/Animations/animationKey";
  34142. export * from "babylonjs/Animations/animationRange";
  34143. }
  34144. declare module "babylonjs/Audio/soundTrack" {
  34145. import { Sound } from "babylonjs/Audio/sound";
  34146. import { Analyser } from "babylonjs/Audio/analyser";
  34147. import { Scene } from "babylonjs/scene";
  34148. /**
  34149. * Options allowed during the creation of a sound track.
  34150. */
  34151. export interface ISoundTrackOptions {
  34152. /**
  34153. * The volume the sound track should take during creation
  34154. */
  34155. volume?: number;
  34156. /**
  34157. * Define if the sound track is the main sound track of the scene
  34158. */
  34159. mainTrack?: boolean;
  34160. }
  34161. /**
  34162. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34163. * It will be also used in a future release to apply effects on a specific track.
  34164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34165. */
  34166. export class SoundTrack {
  34167. /**
  34168. * The unique identifier of the sound track in the scene.
  34169. */
  34170. id: number;
  34171. /**
  34172. * The list of sounds included in the sound track.
  34173. */
  34174. soundCollection: Array<Sound>;
  34175. private _outputAudioNode;
  34176. private _scene;
  34177. private _isMainTrack;
  34178. private _connectedAnalyser;
  34179. private _options;
  34180. private _isInitialized;
  34181. /**
  34182. * Creates a new sound track.
  34183. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34184. * @param scene Define the scene the sound track belongs to
  34185. * @param options
  34186. */
  34187. constructor(scene: Scene, options?: ISoundTrackOptions);
  34188. private _initializeSoundTrackAudioGraph;
  34189. /**
  34190. * Release the sound track and its associated resources
  34191. */
  34192. dispose(): void;
  34193. /**
  34194. * Adds a sound to this sound track
  34195. * @param sound define the cound to add
  34196. * @ignoreNaming
  34197. */
  34198. AddSound(sound: Sound): void;
  34199. /**
  34200. * Removes a sound to this sound track
  34201. * @param sound define the cound to remove
  34202. * @ignoreNaming
  34203. */
  34204. RemoveSound(sound: Sound): void;
  34205. /**
  34206. * Set a global volume for the full sound track.
  34207. * @param newVolume Define the new volume of the sound track
  34208. */
  34209. setVolume(newVolume: number): void;
  34210. /**
  34211. * Switch the panning model to HRTF:
  34212. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34214. */
  34215. switchPanningModelToHRTF(): void;
  34216. /**
  34217. * Switch the panning model to Equal Power:
  34218. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34219. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34220. */
  34221. switchPanningModelToEqualPower(): void;
  34222. /**
  34223. * Connect the sound track to an audio analyser allowing some amazing
  34224. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34226. * @param analyser The analyser to connect to the engine
  34227. */
  34228. connectToAnalyser(analyser: Analyser): void;
  34229. }
  34230. }
  34231. declare module "babylonjs/Audio/audioSceneComponent" {
  34232. import { Sound } from "babylonjs/Audio/sound";
  34233. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34234. import { Nullable } from "babylonjs/types";
  34235. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34236. import { Scene } from "babylonjs/scene";
  34237. import { AbstractScene } from "babylonjs/abstractScene";
  34238. module "babylonjs/abstractScene" {
  34239. interface AbstractScene {
  34240. /**
  34241. * The list of sounds used in the scene.
  34242. */
  34243. sounds: Nullable<Array<Sound>>;
  34244. }
  34245. }
  34246. module "babylonjs/scene" {
  34247. interface Scene {
  34248. /**
  34249. * @hidden
  34250. * Backing field
  34251. */
  34252. _mainSoundTrack: SoundTrack;
  34253. /**
  34254. * The main sound track played by the scene.
  34255. * It cotains your primary collection of sounds.
  34256. */
  34257. mainSoundTrack: SoundTrack;
  34258. /**
  34259. * The list of sound tracks added to the scene
  34260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34261. */
  34262. soundTracks: Nullable<Array<SoundTrack>>;
  34263. /**
  34264. * Gets a sound using a given name
  34265. * @param name defines the name to search for
  34266. * @return the found sound or null if not found at all.
  34267. */
  34268. getSoundByName(name: string): Nullable<Sound>;
  34269. /**
  34270. * Gets or sets if audio support is enabled
  34271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34272. */
  34273. audioEnabled: boolean;
  34274. /**
  34275. * Gets or sets if audio will be output to headphones
  34276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34277. */
  34278. headphone: boolean;
  34279. }
  34280. }
  34281. /**
  34282. * Defines the sound scene component responsible to manage any sounds
  34283. * in a given scene.
  34284. */
  34285. export class AudioSceneComponent implements ISceneSerializableComponent {
  34286. /**
  34287. * The component name helpfull to identify the component in the list of scene components.
  34288. */
  34289. readonly name: string;
  34290. /**
  34291. * The scene the component belongs to.
  34292. */
  34293. scene: Scene;
  34294. private _audioEnabled;
  34295. /**
  34296. * Gets whether audio is enabled or not.
  34297. * Please use related enable/disable method to switch state.
  34298. */
  34299. readonly audioEnabled: boolean;
  34300. private _headphone;
  34301. /**
  34302. * Gets whether audio is outputing to headphone or not.
  34303. * Please use the according Switch methods to change output.
  34304. */
  34305. readonly headphone: boolean;
  34306. /**
  34307. * Creates a new instance of the component for the given scene
  34308. * @param scene Defines the scene to register the component in
  34309. */
  34310. constructor(scene: Scene);
  34311. /**
  34312. * Registers the component in a given scene
  34313. */
  34314. register(): void;
  34315. /**
  34316. * Rebuilds the elements related to this component in case of
  34317. * context lost for instance.
  34318. */
  34319. rebuild(): void;
  34320. /**
  34321. * Serializes the component data to the specified json object
  34322. * @param serializationObject The object to serialize to
  34323. */
  34324. serialize(serializationObject: any): void;
  34325. /**
  34326. * Adds all the element from the container to the scene
  34327. * @param container the container holding the elements
  34328. */
  34329. addFromContainer(container: AbstractScene): void;
  34330. /**
  34331. * Removes all the elements in the container from the scene
  34332. * @param container contains the elements to remove
  34333. */
  34334. removeFromContainer(container: AbstractScene): void;
  34335. /**
  34336. * Disposes the component and the associated ressources.
  34337. */
  34338. dispose(): void;
  34339. /**
  34340. * Disables audio in the associated scene.
  34341. */
  34342. disableAudio(): void;
  34343. /**
  34344. * Enables audio in the associated scene.
  34345. */
  34346. enableAudio(): void;
  34347. /**
  34348. * Switch audio to headphone output.
  34349. */
  34350. switchAudioModeForHeadphones(): void;
  34351. /**
  34352. * Switch audio to normal speakers.
  34353. */
  34354. switchAudioModeForNormalSpeakers(): void;
  34355. private _afterRender;
  34356. }
  34357. }
  34358. declare module "babylonjs/Audio/weightedsound" {
  34359. import { Sound } from "babylonjs/Audio/sound";
  34360. /**
  34361. * Wraps one or more Sound objects and selects one with random weight for playback.
  34362. */
  34363. export class WeightedSound {
  34364. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34365. loop: boolean;
  34366. private _coneInnerAngle;
  34367. private _coneOuterAngle;
  34368. private _volume;
  34369. /** A Sound is currently playing. */
  34370. isPlaying: boolean;
  34371. /** A Sound is currently paused. */
  34372. isPaused: boolean;
  34373. private _sounds;
  34374. private _weights;
  34375. private _currentIndex?;
  34376. /**
  34377. * Creates a new WeightedSound from the list of sounds given.
  34378. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34379. * @param sounds Array of Sounds that will be selected from.
  34380. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34381. */
  34382. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34383. /**
  34384. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34385. */
  34386. /**
  34387. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34388. */
  34389. directionalConeInnerAngle: number;
  34390. /**
  34391. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34392. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34393. */
  34394. /**
  34395. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34396. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34397. */
  34398. directionalConeOuterAngle: number;
  34399. /**
  34400. * Playback volume.
  34401. */
  34402. /**
  34403. * Playback volume.
  34404. */
  34405. volume: number;
  34406. private _onended;
  34407. /**
  34408. * Suspend playback
  34409. */
  34410. pause(): void;
  34411. /**
  34412. * Stop playback
  34413. */
  34414. stop(): void;
  34415. /**
  34416. * Start playback.
  34417. * @param startOffset Position the clip head at a specific time in seconds.
  34418. */
  34419. play(startOffset?: number): void;
  34420. }
  34421. }
  34422. declare module "babylonjs/Audio/index" {
  34423. export * from "babylonjs/Audio/analyser";
  34424. export * from "babylonjs/Audio/audioEngine";
  34425. export * from "babylonjs/Audio/audioSceneComponent";
  34426. export * from "babylonjs/Audio/sound";
  34427. export * from "babylonjs/Audio/soundTrack";
  34428. export * from "babylonjs/Audio/weightedsound";
  34429. }
  34430. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34431. import { Behavior } from "babylonjs/Behaviors/behavior";
  34432. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34433. import { BackEase } from "babylonjs/Animations/easing";
  34434. /**
  34435. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34436. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34437. */
  34438. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34439. /**
  34440. * Gets the name of the behavior.
  34441. */
  34442. readonly name: string;
  34443. /**
  34444. * The easing function used by animations
  34445. */
  34446. static EasingFunction: BackEase;
  34447. /**
  34448. * The easing mode used by animations
  34449. */
  34450. static EasingMode: number;
  34451. /**
  34452. * The duration of the animation, in milliseconds
  34453. */
  34454. transitionDuration: number;
  34455. /**
  34456. * Length of the distance animated by the transition when lower radius is reached
  34457. */
  34458. lowerRadiusTransitionRange: number;
  34459. /**
  34460. * Length of the distance animated by the transition when upper radius is reached
  34461. */
  34462. upperRadiusTransitionRange: number;
  34463. private _autoTransitionRange;
  34464. /**
  34465. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34466. */
  34467. /**
  34468. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34469. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34470. */
  34471. autoTransitionRange: boolean;
  34472. private _attachedCamera;
  34473. private _onAfterCheckInputsObserver;
  34474. private _onMeshTargetChangedObserver;
  34475. /**
  34476. * Initializes the behavior.
  34477. */
  34478. init(): void;
  34479. /**
  34480. * Attaches the behavior to its arc rotate camera.
  34481. * @param camera Defines the camera to attach the behavior to
  34482. */
  34483. attach(camera: ArcRotateCamera): void;
  34484. /**
  34485. * Detaches the behavior from its current arc rotate camera.
  34486. */
  34487. detach(): void;
  34488. private _radiusIsAnimating;
  34489. private _radiusBounceTransition;
  34490. private _animatables;
  34491. private _cachedWheelPrecision;
  34492. /**
  34493. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34494. * @param radiusLimit The limit to check against.
  34495. * @return Bool to indicate if at limit.
  34496. */
  34497. private _isRadiusAtLimit;
  34498. /**
  34499. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34500. * @param radiusDelta The delta by which to animate to. Can be negative.
  34501. */
  34502. private _applyBoundRadiusAnimation;
  34503. /**
  34504. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34505. */
  34506. protected _clearAnimationLocks(): void;
  34507. /**
  34508. * Stops and removes all animations that have been applied to the camera
  34509. */
  34510. stopAllAnimations(): void;
  34511. }
  34512. }
  34513. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34514. import { Behavior } from "babylonjs/Behaviors/behavior";
  34515. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34516. import { ExponentialEase } from "babylonjs/Animations/easing";
  34517. import { Nullable } from "babylonjs/types";
  34518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34519. import { Vector3 } from "babylonjs/Maths/math";
  34520. /**
  34521. * 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.
  34522. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34523. */
  34524. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34525. /**
  34526. * Gets the name of the behavior.
  34527. */
  34528. readonly name: string;
  34529. private _mode;
  34530. private _radiusScale;
  34531. private _positionScale;
  34532. private _defaultElevation;
  34533. private _elevationReturnTime;
  34534. private _elevationReturnWaitTime;
  34535. private _zoomStopsAnimation;
  34536. private _framingTime;
  34537. /**
  34538. * The easing function used by animations
  34539. */
  34540. static EasingFunction: ExponentialEase;
  34541. /**
  34542. * The easing mode used by animations
  34543. */
  34544. static EasingMode: number;
  34545. /**
  34546. * Sets the current mode used by the behavior
  34547. */
  34548. /**
  34549. * Gets current mode used by the behavior.
  34550. */
  34551. mode: number;
  34552. /**
  34553. * Sets the scale applied to the radius (1 by default)
  34554. */
  34555. /**
  34556. * Gets the scale applied to the radius
  34557. */
  34558. radiusScale: number;
  34559. /**
  34560. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34561. */
  34562. /**
  34563. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34564. */
  34565. positionScale: number;
  34566. /**
  34567. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34568. * behaviour is triggered, in radians.
  34569. */
  34570. /**
  34571. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34572. * behaviour is triggered, in radians.
  34573. */
  34574. defaultElevation: number;
  34575. /**
  34576. * Sets the time (in milliseconds) taken to return to the default beta position.
  34577. * Negative value indicates camera should not return to default.
  34578. */
  34579. /**
  34580. * Gets the time (in milliseconds) taken to return to the default beta position.
  34581. * Negative value indicates camera should not return to default.
  34582. */
  34583. elevationReturnTime: number;
  34584. /**
  34585. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34586. */
  34587. /**
  34588. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34589. */
  34590. elevationReturnWaitTime: number;
  34591. /**
  34592. * Sets the flag that indicates if user zooming should stop animation.
  34593. */
  34594. /**
  34595. * Gets the flag that indicates if user zooming should stop animation.
  34596. */
  34597. zoomStopsAnimation: boolean;
  34598. /**
  34599. * Sets the transition time when framing the mesh, in milliseconds
  34600. */
  34601. /**
  34602. * Gets the transition time when framing the mesh, in milliseconds
  34603. */
  34604. framingTime: number;
  34605. /**
  34606. * Define if the behavior should automatically change the configured
  34607. * camera limits and sensibilities.
  34608. */
  34609. autoCorrectCameraLimitsAndSensibility: boolean;
  34610. private _onPrePointerObservableObserver;
  34611. private _onAfterCheckInputsObserver;
  34612. private _onMeshTargetChangedObserver;
  34613. private _attachedCamera;
  34614. private _isPointerDown;
  34615. private _lastInteractionTime;
  34616. /**
  34617. * Initializes the behavior.
  34618. */
  34619. init(): void;
  34620. /**
  34621. * Attaches the behavior to its arc rotate camera.
  34622. * @param camera Defines the camera to attach the behavior to
  34623. */
  34624. attach(camera: ArcRotateCamera): void;
  34625. /**
  34626. * Detaches the behavior from its current arc rotate camera.
  34627. */
  34628. detach(): void;
  34629. private _animatables;
  34630. private _betaIsAnimating;
  34631. private _betaTransition;
  34632. private _radiusTransition;
  34633. private _vectorTransition;
  34634. /**
  34635. * Targets the given mesh and updates zoom level accordingly.
  34636. * @param mesh The mesh to target.
  34637. * @param radius Optional. If a cached radius position already exists, overrides default.
  34638. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34639. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34640. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34641. */
  34642. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34643. /**
  34644. * Targets the given mesh with its children and updates zoom level accordingly.
  34645. * @param mesh The mesh to target.
  34646. * @param radius Optional. If a cached radius position already exists, overrides default.
  34647. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34648. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34649. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34650. */
  34651. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34652. /**
  34653. * Targets the given meshes with their children and updates zoom level accordingly.
  34654. * @param meshes The mesh to target.
  34655. * @param radius Optional. If a cached radius position already exists, overrides default.
  34656. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34657. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34658. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34659. */
  34660. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34661. /**
  34662. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34663. * @param minimumWorld Determines the smaller position of the bounding box extend
  34664. * @param maximumWorld Determines the bigger position of the bounding box extend
  34665. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34666. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34667. */
  34668. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34669. /**
  34670. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34671. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34672. * frustum width.
  34673. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34674. * to fully enclose the mesh in the viewing frustum.
  34675. */
  34676. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34677. /**
  34678. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34679. * is automatically returned to its default position (expected to be above ground plane).
  34680. */
  34681. private _maintainCameraAboveGround;
  34682. /**
  34683. * Returns the frustum slope based on the canvas ratio and camera FOV
  34684. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34685. */
  34686. private _getFrustumSlope;
  34687. /**
  34688. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34689. */
  34690. private _clearAnimationLocks;
  34691. /**
  34692. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34693. */
  34694. private _applyUserInteraction;
  34695. /**
  34696. * Stops and removes all animations that have been applied to the camera
  34697. */
  34698. stopAllAnimations(): void;
  34699. /**
  34700. * Gets a value indicating if the user is moving the camera
  34701. */
  34702. readonly isUserIsMoving: boolean;
  34703. /**
  34704. * The camera can move all the way towards the mesh.
  34705. */
  34706. static IgnoreBoundsSizeMode: number;
  34707. /**
  34708. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34709. */
  34710. static FitFrustumSidesMode: number;
  34711. }
  34712. }
  34713. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34714. import { Nullable } from "babylonjs/types";
  34715. import { Camera } from "babylonjs/Cameras/camera";
  34716. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34717. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34718. /**
  34719. * Base class for Camera Pointer Inputs.
  34720. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34721. * for example usage.
  34722. */
  34723. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34724. /**
  34725. * Defines the camera the input is attached to.
  34726. */
  34727. abstract camera: Camera;
  34728. /**
  34729. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34730. */
  34731. protected _altKey: boolean;
  34732. protected _ctrlKey: boolean;
  34733. protected _metaKey: boolean;
  34734. protected _shiftKey: boolean;
  34735. /**
  34736. * Which mouse buttons were pressed at time of last mouse event.
  34737. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34738. */
  34739. protected _buttonsPressed: number;
  34740. /**
  34741. * Defines the buttons associated with the input to handle camera move.
  34742. */
  34743. buttons: number[];
  34744. /**
  34745. * Attach the input controls to a specific dom element to get the input from.
  34746. * @param element Defines the element the controls should be listened from
  34747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34748. */
  34749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34750. /**
  34751. * Detach the current controls from the specified dom element.
  34752. * @param element Defines the element to stop listening the inputs from
  34753. */
  34754. detachControl(element: Nullable<HTMLElement>): void;
  34755. /**
  34756. * Gets the class name of the current input.
  34757. * @returns the class name
  34758. */
  34759. getClassName(): string;
  34760. /**
  34761. * Get the friendly name associated with the input class.
  34762. * @returns the input friendly name
  34763. */
  34764. getSimpleName(): string;
  34765. /**
  34766. * Called on pointer POINTERDOUBLETAP event.
  34767. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34768. */
  34769. protected onDoubleTap(type: string): void;
  34770. /**
  34771. * Called on pointer POINTERMOVE event if only a single touch is active.
  34772. * Override this method to provide functionality.
  34773. */
  34774. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34775. /**
  34776. * Called on pointer POINTERMOVE event if multiple touches are active.
  34777. * Override this method to provide functionality.
  34778. */
  34779. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34780. /**
  34781. * Called on JS contextmenu event.
  34782. * Override this method to provide functionality.
  34783. */
  34784. protected onContextMenu(evt: PointerEvent): void;
  34785. /**
  34786. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34787. * press.
  34788. * Override this method to provide functionality.
  34789. */
  34790. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34791. /**
  34792. * Called each time a new POINTERUP event occurs. Ie, for each button
  34793. * release.
  34794. * Override this method to provide functionality.
  34795. */
  34796. protected onButtonUp(evt: PointerEvent): void;
  34797. /**
  34798. * Called when window becomes inactive.
  34799. * Override this method to provide functionality.
  34800. */
  34801. protected onLostFocus(): void;
  34802. private _pointerInput;
  34803. private _observer;
  34804. private _onLostFocus;
  34805. }
  34806. }
  34807. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34808. import { Nullable } from "babylonjs/types";
  34809. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34810. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34811. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34812. /**
  34813. * Manage the pointers inputs to control an arc rotate camera.
  34814. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34815. */
  34816. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34817. /**
  34818. * Defines the camera the input is attached to.
  34819. */
  34820. camera: ArcRotateCamera;
  34821. /**
  34822. * Gets the class name of the current input.
  34823. * @returns the class name
  34824. */
  34825. getClassName(): string;
  34826. /**
  34827. * Defines the buttons associated with the input to handle camera move.
  34828. */
  34829. buttons: number[];
  34830. /**
  34831. * Defines the pointer angular sensibility along the X axis or how fast is
  34832. * the camera rotating.
  34833. */
  34834. angularSensibilityX: number;
  34835. /**
  34836. * Defines the pointer angular sensibility along the Y axis or how fast is
  34837. * the camera rotating.
  34838. */
  34839. angularSensibilityY: number;
  34840. /**
  34841. * Defines the pointer pinch precision or how fast is the camera zooming.
  34842. */
  34843. pinchPrecision: number;
  34844. /**
  34845. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34846. * from 0.
  34847. * It defines the percentage of current camera.radius to use as delta when
  34848. * pinch zoom is used.
  34849. */
  34850. pinchDeltaPercentage: number;
  34851. /**
  34852. * Defines the pointer panning sensibility or how fast is the camera moving.
  34853. */
  34854. panningSensibility: number;
  34855. /**
  34856. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34857. */
  34858. multiTouchPanning: boolean;
  34859. /**
  34860. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34861. * zoom (pinch) through multitouch.
  34862. */
  34863. multiTouchPanAndZoom: boolean;
  34864. /**
  34865. * Revers pinch action direction.
  34866. */
  34867. pinchInwards: boolean;
  34868. private _isPanClick;
  34869. private _twoFingerActivityCount;
  34870. private _isPinching;
  34871. /**
  34872. * Called on pointer POINTERMOVE event if only a single touch is active.
  34873. */
  34874. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34875. /**
  34876. * Called on pointer POINTERDOUBLETAP event.
  34877. */
  34878. protected onDoubleTap(type: string): void;
  34879. /**
  34880. * Called on pointer POINTERMOVE event if multiple touches are active.
  34881. */
  34882. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34883. /**
  34884. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34885. * press.
  34886. */
  34887. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34888. /**
  34889. * Called each time a new POINTERUP event occurs. Ie, for each button
  34890. * release.
  34891. */
  34892. protected onButtonUp(evt: PointerEvent): void;
  34893. /**
  34894. * Called when window becomes inactive.
  34895. */
  34896. protected onLostFocus(): void;
  34897. }
  34898. }
  34899. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34900. import { Nullable } from "babylonjs/types";
  34901. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34902. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34903. /**
  34904. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34906. */
  34907. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34908. /**
  34909. * Defines the camera the input is attached to.
  34910. */
  34911. camera: ArcRotateCamera;
  34912. /**
  34913. * Defines the list of key codes associated with the up action (increase alpha)
  34914. */
  34915. keysUp: number[];
  34916. /**
  34917. * Defines the list of key codes associated with the down action (decrease alpha)
  34918. */
  34919. keysDown: number[];
  34920. /**
  34921. * Defines the list of key codes associated with the left action (increase beta)
  34922. */
  34923. keysLeft: number[];
  34924. /**
  34925. * Defines the list of key codes associated with the right action (decrease beta)
  34926. */
  34927. keysRight: number[];
  34928. /**
  34929. * Defines the list of key codes associated with the reset action.
  34930. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34931. */
  34932. keysReset: number[];
  34933. /**
  34934. * Defines the panning sensibility of the inputs.
  34935. * (How fast is the camera paning)
  34936. */
  34937. panningSensibility: number;
  34938. /**
  34939. * Defines the zooming sensibility of the inputs.
  34940. * (How fast is the camera zooming)
  34941. */
  34942. zoomingSensibility: number;
  34943. /**
  34944. * Defines wether maintaining the alt key down switch the movement mode from
  34945. * orientation to zoom.
  34946. */
  34947. useAltToZoom: boolean;
  34948. /**
  34949. * Rotation speed of the camera
  34950. */
  34951. angularSpeed: number;
  34952. private _keys;
  34953. private _ctrlPressed;
  34954. private _altPressed;
  34955. private _onCanvasBlurObserver;
  34956. private _onKeyboardObserver;
  34957. private _engine;
  34958. private _scene;
  34959. /**
  34960. * Attach the input controls to a specific dom element to get the input from.
  34961. * @param element Defines the element the controls should be listened from
  34962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34963. */
  34964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34965. /**
  34966. * Detach the current controls from the specified dom element.
  34967. * @param element Defines the element to stop listening the inputs from
  34968. */
  34969. detachControl(element: Nullable<HTMLElement>): void;
  34970. /**
  34971. * Update the current camera state depending on the inputs that have been used this frame.
  34972. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34973. */
  34974. checkInputs(): void;
  34975. /**
  34976. * Gets the class name of the current intput.
  34977. * @returns the class name
  34978. */
  34979. getClassName(): string;
  34980. /**
  34981. * Get the friendly name associated with the input class.
  34982. * @returns the input friendly name
  34983. */
  34984. getSimpleName(): string;
  34985. }
  34986. }
  34987. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  34988. import { Nullable } from "babylonjs/types";
  34989. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34990. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34991. /**
  34992. * Manage the mouse wheel inputs to control an arc rotate camera.
  34993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34994. */
  34995. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34996. /**
  34997. * Defines the camera the input is attached to.
  34998. */
  34999. camera: ArcRotateCamera;
  35000. /**
  35001. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35002. */
  35003. wheelPrecision: number;
  35004. /**
  35005. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35006. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35007. */
  35008. wheelDeltaPercentage: number;
  35009. private _wheel;
  35010. private _observer;
  35011. /**
  35012. * Attach the input controls to a specific dom element to get the input from.
  35013. * @param element Defines the element the controls should be listened from
  35014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35015. */
  35016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35017. /**
  35018. * Detach the current controls from the specified dom element.
  35019. * @param element Defines the element to stop listening the inputs from
  35020. */
  35021. detachControl(element: Nullable<HTMLElement>): void;
  35022. /**
  35023. * Gets the class name of the current intput.
  35024. * @returns the class name
  35025. */
  35026. getClassName(): string;
  35027. /**
  35028. * Get the friendly name associated with the input class.
  35029. * @returns the input friendly name
  35030. */
  35031. getSimpleName(): string;
  35032. }
  35033. }
  35034. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35035. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35036. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35037. /**
  35038. * Default Inputs manager for the ArcRotateCamera.
  35039. * It groups all the default supported inputs for ease of use.
  35040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35041. */
  35042. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35043. /**
  35044. * Instantiates a new ArcRotateCameraInputsManager.
  35045. * @param camera Defines the camera the inputs belong to
  35046. */
  35047. constructor(camera: ArcRotateCamera);
  35048. /**
  35049. * Add mouse wheel input support to the input manager.
  35050. * @returns the current input manager
  35051. */
  35052. addMouseWheel(): ArcRotateCameraInputsManager;
  35053. /**
  35054. * Add pointers input support to the input manager.
  35055. * @returns the current input manager
  35056. */
  35057. addPointers(): ArcRotateCameraInputsManager;
  35058. /**
  35059. * Add keyboard input support to the input manager.
  35060. * @returns the current input manager
  35061. */
  35062. addKeyboard(): ArcRotateCameraInputsManager;
  35063. }
  35064. }
  35065. declare module "babylonjs/Cameras/arcRotateCamera" {
  35066. import { Observable } from "babylonjs/Misc/observable";
  35067. import { Nullable } from "babylonjs/types";
  35068. import { Scene } from "babylonjs/scene";
  35069. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35071. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35072. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35073. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35074. import { Camera } from "babylonjs/Cameras/camera";
  35075. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35076. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35077. import { Collider } from "babylonjs/Collisions/collider";
  35078. /**
  35079. * This represents an orbital type of camera.
  35080. *
  35081. * 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.
  35082. * 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.
  35083. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35084. */
  35085. export class ArcRotateCamera extends TargetCamera {
  35086. /**
  35087. * Defines the rotation angle of the camera along the longitudinal axis.
  35088. */
  35089. alpha: number;
  35090. /**
  35091. * Defines the rotation angle of the camera along the latitudinal axis.
  35092. */
  35093. beta: number;
  35094. /**
  35095. * Defines the radius of the camera from it s target point.
  35096. */
  35097. radius: number;
  35098. protected _target: Vector3;
  35099. protected _targetHost: Nullable<AbstractMesh>;
  35100. /**
  35101. * Defines the target point of the camera.
  35102. * The camera looks towards it form the radius distance.
  35103. */
  35104. target: Vector3;
  35105. /**
  35106. * Define the current local position of the camera in the scene
  35107. */
  35108. position: Vector3;
  35109. /**
  35110. * Current inertia value on the longitudinal axis.
  35111. * The bigger this number the longer it will take for the camera to stop.
  35112. */
  35113. inertialAlphaOffset: number;
  35114. /**
  35115. * Current inertia value on the latitudinal axis.
  35116. * The bigger this number the longer it will take for the camera to stop.
  35117. */
  35118. inertialBetaOffset: number;
  35119. /**
  35120. * Current inertia value on the radius axis.
  35121. * The bigger this number the longer it will take for the camera to stop.
  35122. */
  35123. inertialRadiusOffset: number;
  35124. /**
  35125. * Minimum allowed angle on the longitudinal axis.
  35126. * This can help limiting how the Camera is able to move in the scene.
  35127. */
  35128. lowerAlphaLimit: Nullable<number>;
  35129. /**
  35130. * Maximum allowed angle on the longitudinal axis.
  35131. * This can help limiting how the Camera is able to move in the scene.
  35132. */
  35133. upperAlphaLimit: Nullable<number>;
  35134. /**
  35135. * Minimum allowed angle on the latitudinal axis.
  35136. * This can help limiting how the Camera is able to move in the scene.
  35137. */
  35138. lowerBetaLimit: number;
  35139. /**
  35140. * Maximum allowed angle on the latitudinal axis.
  35141. * This can help limiting how the Camera is able to move in the scene.
  35142. */
  35143. upperBetaLimit: number;
  35144. /**
  35145. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35146. * This can help limiting how the Camera is able to move in the scene.
  35147. */
  35148. lowerRadiusLimit: Nullable<number>;
  35149. /**
  35150. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35151. * This can help limiting how the Camera is able to move in the scene.
  35152. */
  35153. upperRadiusLimit: Nullable<number>;
  35154. /**
  35155. * Defines the current inertia value used during panning of the camera along the X axis.
  35156. */
  35157. inertialPanningX: number;
  35158. /**
  35159. * Defines the current inertia value used during panning of the camera along the Y axis.
  35160. */
  35161. inertialPanningY: number;
  35162. /**
  35163. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35164. * Basically if your fingers moves away from more than this distance you will be considered
  35165. * in pinch mode.
  35166. */
  35167. pinchToPanMaxDistance: number;
  35168. /**
  35169. * Defines the maximum distance the camera can pan.
  35170. * This could help keeping the cammera always in your scene.
  35171. */
  35172. panningDistanceLimit: Nullable<number>;
  35173. /**
  35174. * Defines the target of the camera before paning.
  35175. */
  35176. panningOriginTarget: Vector3;
  35177. /**
  35178. * Defines the value of the inertia used during panning.
  35179. * 0 would mean stop inertia and one would mean no decelleration at all.
  35180. */
  35181. panningInertia: number;
  35182. /**
  35183. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35184. */
  35185. angularSensibilityX: number;
  35186. /**
  35187. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35188. */
  35189. angularSensibilityY: number;
  35190. /**
  35191. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35192. */
  35193. pinchPrecision: number;
  35194. /**
  35195. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35196. * It will be used instead of pinchDeltaPrecision if different from 0.
  35197. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35198. */
  35199. pinchDeltaPercentage: number;
  35200. /**
  35201. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35202. */
  35203. panningSensibility: number;
  35204. /**
  35205. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35206. */
  35207. keysUp: number[];
  35208. /**
  35209. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35210. */
  35211. keysDown: number[];
  35212. /**
  35213. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35214. */
  35215. keysLeft: number[];
  35216. /**
  35217. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35218. */
  35219. keysRight: number[];
  35220. /**
  35221. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35222. */
  35223. wheelPrecision: number;
  35224. /**
  35225. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35226. * It will be used instead of pinchDeltaPrecision if different from 0.
  35227. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35228. */
  35229. wheelDeltaPercentage: number;
  35230. /**
  35231. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35232. */
  35233. zoomOnFactor: number;
  35234. /**
  35235. * Defines a screen offset for the camera position.
  35236. */
  35237. targetScreenOffset: Vector2;
  35238. /**
  35239. * Allows the camera to be completely reversed.
  35240. * If false the camera can not arrive upside down.
  35241. */
  35242. allowUpsideDown: boolean;
  35243. /**
  35244. * Define if double tap/click is used to restore the previously saved state of the camera.
  35245. */
  35246. useInputToRestoreState: boolean;
  35247. /** @hidden */
  35248. _viewMatrix: Matrix;
  35249. /** @hidden */
  35250. _useCtrlForPanning: boolean;
  35251. /** @hidden */
  35252. _panningMouseButton: number;
  35253. /**
  35254. * Defines the input associated to the camera.
  35255. */
  35256. inputs: ArcRotateCameraInputsManager;
  35257. /** @hidden */
  35258. _reset: () => void;
  35259. /**
  35260. * Defines the allowed panning axis.
  35261. */
  35262. panningAxis: Vector3;
  35263. protected _localDirection: Vector3;
  35264. protected _transformedDirection: Vector3;
  35265. private _bouncingBehavior;
  35266. /**
  35267. * Gets the bouncing behavior of the camera if it has been enabled.
  35268. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35269. */
  35270. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35271. /**
  35272. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35273. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35274. */
  35275. useBouncingBehavior: boolean;
  35276. private _framingBehavior;
  35277. /**
  35278. * Gets the framing behavior of the camera if it has been enabled.
  35279. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35280. */
  35281. readonly framingBehavior: Nullable<FramingBehavior>;
  35282. /**
  35283. * Defines if the framing behavior of the camera is enabled on the camera.
  35284. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35285. */
  35286. useFramingBehavior: boolean;
  35287. private _autoRotationBehavior;
  35288. /**
  35289. * Gets the auto rotation behavior of the camera if it has been enabled.
  35290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35291. */
  35292. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35293. /**
  35294. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35295. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35296. */
  35297. useAutoRotationBehavior: boolean;
  35298. /**
  35299. * Observable triggered when the mesh target has been changed on the camera.
  35300. */
  35301. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35302. /**
  35303. * Event raised when the camera is colliding with a mesh.
  35304. */
  35305. onCollide: (collidedMesh: AbstractMesh) => void;
  35306. /**
  35307. * Defines whether the camera should check collision with the objects oh the scene.
  35308. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35309. */
  35310. checkCollisions: boolean;
  35311. /**
  35312. * Defines the collision radius of the camera.
  35313. * This simulates a sphere around the camera.
  35314. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35315. */
  35316. collisionRadius: Vector3;
  35317. protected _collider: Collider;
  35318. protected _previousPosition: Vector3;
  35319. protected _collisionVelocity: Vector3;
  35320. protected _newPosition: Vector3;
  35321. protected _previousAlpha: number;
  35322. protected _previousBeta: number;
  35323. protected _previousRadius: number;
  35324. protected _collisionTriggered: boolean;
  35325. protected _targetBoundingCenter: Nullable<Vector3>;
  35326. private _computationVector;
  35327. private _tempAxisVector;
  35328. private _tempAxisRotationMatrix;
  35329. /**
  35330. * Instantiates a new ArcRotateCamera in a given scene
  35331. * @param name Defines the name of the camera
  35332. * @param alpha Defines the camera rotation along the logitudinal axis
  35333. * @param beta Defines the camera rotation along the latitudinal axis
  35334. * @param radius Defines the camera distance from its target
  35335. * @param target Defines the camera target
  35336. * @param scene Defines the scene the camera belongs to
  35337. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35338. */
  35339. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35340. /** @hidden */
  35341. _initCache(): void;
  35342. /** @hidden */
  35343. _updateCache(ignoreParentClass?: boolean): void;
  35344. protected _getTargetPosition(): Vector3;
  35345. private _storedAlpha;
  35346. private _storedBeta;
  35347. private _storedRadius;
  35348. private _storedTarget;
  35349. /**
  35350. * Stores the current state of the camera (alpha, beta, radius and target)
  35351. * @returns the camera itself
  35352. */
  35353. storeState(): Camera;
  35354. /**
  35355. * @hidden
  35356. * Restored camera state. You must call storeState() first
  35357. */
  35358. _restoreStateValues(): boolean;
  35359. /** @hidden */
  35360. _isSynchronizedViewMatrix(): boolean;
  35361. /**
  35362. * Attached controls to the current camera.
  35363. * @param element Defines the element the controls should be listened from
  35364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35365. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35366. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35367. */
  35368. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35369. /**
  35370. * Detach the current controls from the camera.
  35371. * The camera will stop reacting to inputs.
  35372. * @param element Defines the element to stop listening the inputs from
  35373. */
  35374. detachControl(element: HTMLElement): void;
  35375. /** @hidden */
  35376. _checkInputs(): void;
  35377. protected _checkLimits(): void;
  35378. /**
  35379. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35380. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35381. */
  35382. rebuildAnglesAndRadius(updateView?: boolean): void;
  35383. /**
  35384. * Use a position to define the current camera related information like aplha, beta and radius
  35385. * @param position Defines the position to set the camera at
  35386. */
  35387. setPosition(position: Vector3): void;
  35388. /**
  35389. * Defines the target the camera should look at.
  35390. * This will automatically adapt alpha beta and radius to fit within the new target.
  35391. * @param target Defines the new target as a Vector or a mesh
  35392. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35393. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35394. */
  35395. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35396. /** @hidden */
  35397. _getViewMatrix(): Matrix;
  35398. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35399. /**
  35400. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35401. * @param meshes Defines the mesh to zoom on
  35402. * @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)
  35403. */
  35404. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35405. /**
  35406. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35407. * The target will be changed but the radius
  35408. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35409. * @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)
  35410. */
  35411. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35412. min: Vector3;
  35413. max: Vector3;
  35414. distance: number;
  35415. }, doNotUpdateMaxZ?: boolean): void;
  35416. /**
  35417. * @override
  35418. * Override Camera.createRigCamera
  35419. */
  35420. createRigCamera(name: string, cameraIndex: number): Camera;
  35421. /**
  35422. * @hidden
  35423. * @override
  35424. * Override Camera._updateRigCameras
  35425. */
  35426. _updateRigCameras(): void;
  35427. /**
  35428. * Destroy the camera and release the current resources hold by it.
  35429. */
  35430. dispose(): void;
  35431. /**
  35432. * Gets the current object class name.
  35433. * @return the class name
  35434. */
  35435. getClassName(): string;
  35436. }
  35437. }
  35438. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35439. import { Behavior } from "babylonjs/Behaviors/behavior";
  35440. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35441. /**
  35442. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35443. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35444. */
  35445. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35446. /**
  35447. * Gets the name of the behavior.
  35448. */
  35449. readonly name: string;
  35450. private _zoomStopsAnimation;
  35451. private _idleRotationSpeed;
  35452. private _idleRotationWaitTime;
  35453. private _idleRotationSpinupTime;
  35454. /**
  35455. * Sets the flag that indicates if user zooming should stop animation.
  35456. */
  35457. /**
  35458. * Gets the flag that indicates if user zooming should stop animation.
  35459. */
  35460. zoomStopsAnimation: boolean;
  35461. /**
  35462. * Sets the default speed at which the camera rotates around the model.
  35463. */
  35464. /**
  35465. * Gets the default speed at which the camera rotates around the model.
  35466. */
  35467. idleRotationSpeed: number;
  35468. /**
  35469. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35470. */
  35471. /**
  35472. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35473. */
  35474. idleRotationWaitTime: number;
  35475. /**
  35476. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35477. */
  35478. /**
  35479. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35480. */
  35481. idleRotationSpinupTime: number;
  35482. /**
  35483. * Gets a value indicating if the camera is currently rotating because of this behavior
  35484. */
  35485. readonly rotationInProgress: boolean;
  35486. private _onPrePointerObservableObserver;
  35487. private _onAfterCheckInputsObserver;
  35488. private _attachedCamera;
  35489. private _isPointerDown;
  35490. private _lastFrameTime;
  35491. private _lastInteractionTime;
  35492. private _cameraRotationSpeed;
  35493. /**
  35494. * Initializes the behavior.
  35495. */
  35496. init(): void;
  35497. /**
  35498. * Attaches the behavior to its arc rotate camera.
  35499. * @param camera Defines the camera to attach the behavior to
  35500. */
  35501. attach(camera: ArcRotateCamera): void;
  35502. /**
  35503. * Detaches the behavior from its current arc rotate camera.
  35504. */
  35505. detach(): void;
  35506. /**
  35507. * Returns true if user is scrolling.
  35508. * @return true if user is scrolling.
  35509. */
  35510. private _userIsZooming;
  35511. private _lastFrameRadius;
  35512. private _shouldAnimationStopForInteraction;
  35513. /**
  35514. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35515. */
  35516. private _applyUserInteraction;
  35517. private _userIsMoving;
  35518. }
  35519. }
  35520. declare module "babylonjs/Behaviors/Cameras/index" {
  35521. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35522. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35523. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35524. }
  35525. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35526. import { Mesh } from "babylonjs/Meshes/mesh";
  35527. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35528. import { Behavior } from "babylonjs/Behaviors/behavior";
  35529. /**
  35530. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35531. */
  35532. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35533. private ui;
  35534. /**
  35535. * The name of the behavior
  35536. */
  35537. name: string;
  35538. /**
  35539. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35540. */
  35541. distanceAwayFromFace: number;
  35542. /**
  35543. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35544. */
  35545. distanceAwayFromBottomOfFace: number;
  35546. private _faceVectors;
  35547. private _target;
  35548. private _scene;
  35549. private _onRenderObserver;
  35550. private _tmpMatrix;
  35551. private _tmpVector;
  35552. /**
  35553. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35554. * @param ui The transform node that should be attched to the mesh
  35555. */
  35556. constructor(ui: TransformNode);
  35557. /**
  35558. * Initializes the behavior
  35559. */
  35560. init(): void;
  35561. private _closestFace;
  35562. private _zeroVector;
  35563. private _lookAtTmpMatrix;
  35564. private _lookAtToRef;
  35565. /**
  35566. * Attaches the AttachToBoxBehavior to the passed in mesh
  35567. * @param target The mesh that the specified node will be attached to
  35568. */
  35569. attach(target: Mesh): void;
  35570. /**
  35571. * Detaches the behavior from the mesh
  35572. */
  35573. detach(): void;
  35574. }
  35575. }
  35576. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35577. import { Behavior } from "babylonjs/Behaviors/behavior";
  35578. import { Mesh } from "babylonjs/Meshes/mesh";
  35579. /**
  35580. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35581. */
  35582. export class FadeInOutBehavior implements Behavior<Mesh> {
  35583. /**
  35584. * Time in milliseconds to delay before fading in (Default: 0)
  35585. */
  35586. delay: number;
  35587. /**
  35588. * Time in milliseconds for the mesh to fade in (Default: 300)
  35589. */
  35590. fadeInTime: number;
  35591. private _millisecondsPerFrame;
  35592. private _hovered;
  35593. private _hoverValue;
  35594. private _ownerNode;
  35595. /**
  35596. * Instatiates the FadeInOutBehavior
  35597. */
  35598. constructor();
  35599. /**
  35600. * The name of the behavior
  35601. */
  35602. readonly name: string;
  35603. /**
  35604. * Initializes the behavior
  35605. */
  35606. init(): void;
  35607. /**
  35608. * Attaches the fade behavior on the passed in mesh
  35609. * @param ownerNode The mesh that will be faded in/out once attached
  35610. */
  35611. attach(ownerNode: Mesh): void;
  35612. /**
  35613. * Detaches the behavior from the mesh
  35614. */
  35615. detach(): void;
  35616. /**
  35617. * Triggers the mesh to begin fading in or out
  35618. * @param value if the object should fade in or out (true to fade in)
  35619. */
  35620. fadeIn(value: boolean): void;
  35621. private _update;
  35622. private _setAllVisibility;
  35623. }
  35624. }
  35625. declare module "babylonjs/Misc/pivotTools" {
  35626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35627. /**
  35628. * Class containing a set of static utilities functions for managing Pivots
  35629. * @hidden
  35630. */
  35631. export class PivotTools {
  35632. private static _PivotCached;
  35633. private static _OldPivotPoint;
  35634. private static _PivotTranslation;
  35635. private static _PivotTmpVector;
  35636. /** @hidden */
  35637. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35638. /** @hidden */
  35639. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35640. }
  35641. }
  35642. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35643. import { Scene } from "babylonjs/scene";
  35644. import { Vector4, Plane } from "babylonjs/Maths/math";
  35645. import { Mesh } from "babylonjs/Meshes/mesh";
  35646. /**
  35647. * Class containing static functions to help procedurally build meshes
  35648. */
  35649. export class PlaneBuilder {
  35650. /**
  35651. * Creates a plane mesh
  35652. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35653. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35654. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35658. * @param name defines the name of the mesh
  35659. * @param options defines the options used to create the mesh
  35660. * @param scene defines the hosting scene
  35661. * @returns the plane mesh
  35662. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35663. */
  35664. static CreatePlane(name: string, options: {
  35665. size?: number;
  35666. width?: number;
  35667. height?: number;
  35668. sideOrientation?: number;
  35669. frontUVs?: Vector4;
  35670. backUVs?: Vector4;
  35671. updatable?: boolean;
  35672. sourcePlane?: Plane;
  35673. }, scene: Scene): Mesh;
  35674. }
  35675. }
  35676. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35677. import { Behavior } from "babylonjs/Behaviors/behavior";
  35678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35679. import { Observable } from "babylonjs/Misc/observable";
  35680. import { Vector3 } from "babylonjs/Maths/math";
  35681. import { Ray } from "babylonjs/Culling/ray";
  35682. import "babylonjs/Meshes/Builders/planeBuilder";
  35683. /**
  35684. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35685. */
  35686. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35687. private static _AnyMouseID;
  35688. private _attachedNode;
  35689. private _dragPlane;
  35690. private _scene;
  35691. private _pointerObserver;
  35692. private _beforeRenderObserver;
  35693. private static _planeScene;
  35694. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35695. /**
  35696. * 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)
  35697. */
  35698. maxDragAngle: number;
  35699. /**
  35700. * @hidden
  35701. */
  35702. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35703. /**
  35704. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35705. */
  35706. currentDraggingPointerID: number;
  35707. /**
  35708. * The last position where the pointer hit the drag plane in world space
  35709. */
  35710. lastDragPosition: Vector3;
  35711. /**
  35712. * If the behavior is currently in a dragging state
  35713. */
  35714. dragging: boolean;
  35715. /**
  35716. * 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)
  35717. */
  35718. dragDeltaRatio: number;
  35719. /**
  35720. * If the drag plane orientation should be updated during the dragging (Default: true)
  35721. */
  35722. updateDragPlane: boolean;
  35723. private _debugMode;
  35724. private _moving;
  35725. /**
  35726. * Fires each time the attached mesh is dragged with the pointer
  35727. * * delta between last drag position and current drag position in world space
  35728. * * dragDistance along the drag axis
  35729. * * dragPlaneNormal normal of the current drag plane used during the drag
  35730. * * dragPlanePoint in world space where the drag intersects the drag plane
  35731. */
  35732. onDragObservable: Observable<{
  35733. delta: Vector3;
  35734. dragPlanePoint: Vector3;
  35735. dragPlaneNormal: Vector3;
  35736. dragDistance: number;
  35737. pointerId: number;
  35738. }>;
  35739. /**
  35740. * Fires each time a drag begins (eg. mouse down on mesh)
  35741. */
  35742. onDragStartObservable: Observable<{
  35743. dragPlanePoint: Vector3;
  35744. pointerId: number;
  35745. }>;
  35746. /**
  35747. * Fires each time a drag ends (eg. mouse release after drag)
  35748. */
  35749. onDragEndObservable: Observable<{
  35750. dragPlanePoint: Vector3;
  35751. pointerId: number;
  35752. }>;
  35753. /**
  35754. * If the attached mesh should be moved when dragged
  35755. */
  35756. moveAttached: boolean;
  35757. /**
  35758. * If the drag behavior will react to drag events (Default: true)
  35759. */
  35760. enabled: boolean;
  35761. /**
  35762. * If camera controls should be detached during the drag
  35763. */
  35764. detachCameraControls: boolean;
  35765. /**
  35766. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35767. */
  35768. useObjectOrienationForDragging: boolean;
  35769. private _options;
  35770. /**
  35771. * Creates a pointer drag behavior that can be attached to a mesh
  35772. * @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)
  35773. */
  35774. constructor(options?: {
  35775. dragAxis?: Vector3;
  35776. dragPlaneNormal?: Vector3;
  35777. });
  35778. /**
  35779. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35780. */
  35781. validateDrag: (targetPosition: Vector3) => boolean;
  35782. /**
  35783. * The name of the behavior
  35784. */
  35785. readonly name: string;
  35786. /**
  35787. * Initializes the behavior
  35788. */
  35789. init(): void;
  35790. private _tmpVector;
  35791. private _alternatePickedPoint;
  35792. private _worldDragAxis;
  35793. private _targetPosition;
  35794. private _attachedElement;
  35795. /**
  35796. * Attaches the drag behavior the passed in mesh
  35797. * @param ownerNode The mesh that will be dragged around once attached
  35798. */
  35799. attach(ownerNode: AbstractMesh): void;
  35800. /**
  35801. * Force relase the drag action by code.
  35802. */
  35803. releaseDrag(): void;
  35804. private _startDragRay;
  35805. private _lastPointerRay;
  35806. /**
  35807. * Simulates the start of a pointer drag event on the behavior
  35808. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35809. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35810. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35811. */
  35812. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35813. private _startDrag;
  35814. private _dragDelta;
  35815. private _moveDrag;
  35816. private _pickWithRayOnDragPlane;
  35817. private _pointA;
  35818. private _pointB;
  35819. private _pointC;
  35820. private _lineA;
  35821. private _lineB;
  35822. private _localAxis;
  35823. private _lookAt;
  35824. private _updateDragPlanePosition;
  35825. /**
  35826. * Detaches the behavior from the mesh
  35827. */
  35828. detach(): void;
  35829. }
  35830. }
  35831. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35832. import { Mesh } from "babylonjs/Meshes/mesh";
  35833. import { Behavior } from "babylonjs/Behaviors/behavior";
  35834. /**
  35835. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35836. */
  35837. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35838. private _dragBehaviorA;
  35839. private _dragBehaviorB;
  35840. private _startDistance;
  35841. private _initialScale;
  35842. private _targetScale;
  35843. private _ownerNode;
  35844. private _sceneRenderObserver;
  35845. /**
  35846. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35847. */
  35848. constructor();
  35849. /**
  35850. * The name of the behavior
  35851. */
  35852. readonly name: string;
  35853. /**
  35854. * Initializes the behavior
  35855. */
  35856. init(): void;
  35857. private _getCurrentDistance;
  35858. /**
  35859. * Attaches the scale behavior the passed in mesh
  35860. * @param ownerNode The mesh that will be scaled around once attached
  35861. */
  35862. attach(ownerNode: Mesh): void;
  35863. /**
  35864. * Detaches the behavior from the mesh
  35865. */
  35866. detach(): void;
  35867. }
  35868. }
  35869. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35870. import { Behavior } from "babylonjs/Behaviors/behavior";
  35871. import { Mesh } from "babylonjs/Meshes/mesh";
  35872. import { Observable } from "babylonjs/Misc/observable";
  35873. /**
  35874. * 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
  35875. */
  35876. export class SixDofDragBehavior implements Behavior<Mesh> {
  35877. private static _virtualScene;
  35878. private _ownerNode;
  35879. private _sceneRenderObserver;
  35880. private _scene;
  35881. private _targetPosition;
  35882. private _virtualOriginMesh;
  35883. private _virtualDragMesh;
  35884. private _pointerObserver;
  35885. private _moving;
  35886. private _startingOrientation;
  35887. /**
  35888. * 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)
  35889. */
  35890. private zDragFactor;
  35891. /**
  35892. * If the object should rotate to face the drag origin
  35893. */
  35894. rotateDraggedObject: boolean;
  35895. /**
  35896. * If the behavior is currently in a dragging state
  35897. */
  35898. dragging: boolean;
  35899. /**
  35900. * 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)
  35901. */
  35902. dragDeltaRatio: number;
  35903. /**
  35904. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35905. */
  35906. currentDraggingPointerID: number;
  35907. /**
  35908. * If camera controls should be detached during the drag
  35909. */
  35910. detachCameraControls: boolean;
  35911. /**
  35912. * Fires each time a drag starts
  35913. */
  35914. onDragStartObservable: Observable<{}>;
  35915. /**
  35916. * Fires each time a drag ends (eg. mouse release after drag)
  35917. */
  35918. onDragEndObservable: Observable<{}>;
  35919. /**
  35920. * 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
  35921. */
  35922. constructor();
  35923. /**
  35924. * The name of the behavior
  35925. */
  35926. readonly name: string;
  35927. /**
  35928. * Initializes the behavior
  35929. */
  35930. init(): void;
  35931. /**
  35932. * Attaches the scale behavior the passed in mesh
  35933. * @param ownerNode The mesh that will be scaled around once attached
  35934. */
  35935. attach(ownerNode: Mesh): void;
  35936. /**
  35937. * Detaches the behavior from the mesh
  35938. */
  35939. detach(): void;
  35940. }
  35941. }
  35942. declare module "babylonjs/Behaviors/Meshes/index" {
  35943. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35944. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35945. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35946. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35947. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35948. }
  35949. declare module "babylonjs/Behaviors/index" {
  35950. export * from "babylonjs/Behaviors/behavior";
  35951. export * from "babylonjs/Behaviors/Cameras/index";
  35952. export * from "babylonjs/Behaviors/Meshes/index";
  35953. }
  35954. declare module "babylonjs/Bones/boneIKController" {
  35955. import { Bone } from "babylonjs/Bones/bone";
  35956. import { Vector3 } from "babylonjs/Maths/math";
  35957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35958. import { Nullable } from "babylonjs/types";
  35959. /**
  35960. * Class used to apply inverse kinematics to bones
  35961. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35962. */
  35963. export class BoneIKController {
  35964. private static _tmpVecs;
  35965. private static _tmpQuat;
  35966. private static _tmpMats;
  35967. /**
  35968. * Gets or sets the target mesh
  35969. */
  35970. targetMesh: AbstractMesh;
  35971. /** Gets or sets the mesh used as pole */
  35972. poleTargetMesh: AbstractMesh;
  35973. /**
  35974. * Gets or sets the bone used as pole
  35975. */
  35976. poleTargetBone: Nullable<Bone>;
  35977. /**
  35978. * Gets or sets the target position
  35979. */
  35980. targetPosition: Vector3;
  35981. /**
  35982. * Gets or sets the pole target position
  35983. */
  35984. poleTargetPosition: Vector3;
  35985. /**
  35986. * Gets or sets the pole target local offset
  35987. */
  35988. poleTargetLocalOffset: Vector3;
  35989. /**
  35990. * Gets or sets the pole angle
  35991. */
  35992. poleAngle: number;
  35993. /**
  35994. * Gets or sets the mesh associated with the controller
  35995. */
  35996. mesh: AbstractMesh;
  35997. /**
  35998. * 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)
  35999. */
  36000. slerpAmount: number;
  36001. private _bone1Quat;
  36002. private _bone1Mat;
  36003. private _bone2Ang;
  36004. private _bone1;
  36005. private _bone2;
  36006. private _bone1Length;
  36007. private _bone2Length;
  36008. private _maxAngle;
  36009. private _maxReach;
  36010. private _rightHandedSystem;
  36011. private _bendAxis;
  36012. private _slerping;
  36013. private _adjustRoll;
  36014. /**
  36015. * Gets or sets maximum allowed angle
  36016. */
  36017. maxAngle: number;
  36018. /**
  36019. * Creates a new BoneIKController
  36020. * @param mesh defines the mesh to control
  36021. * @param bone defines the bone to control
  36022. * @param options defines options to set up the controller
  36023. */
  36024. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36025. targetMesh?: AbstractMesh;
  36026. poleTargetMesh?: AbstractMesh;
  36027. poleTargetBone?: Bone;
  36028. poleTargetLocalOffset?: Vector3;
  36029. poleAngle?: number;
  36030. bendAxis?: Vector3;
  36031. maxAngle?: number;
  36032. slerpAmount?: number;
  36033. });
  36034. private _setMaxAngle;
  36035. /**
  36036. * Force the controller to update the bones
  36037. */
  36038. update(): void;
  36039. }
  36040. }
  36041. declare module "babylonjs/Bones/boneLookController" {
  36042. import { Vector3, Space } from "babylonjs/Maths/math";
  36043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36044. import { Bone } from "babylonjs/Bones/bone";
  36045. /**
  36046. * Class used to make a bone look toward a point in space
  36047. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36048. */
  36049. export class BoneLookController {
  36050. private static _tmpVecs;
  36051. private static _tmpQuat;
  36052. private static _tmpMats;
  36053. /**
  36054. * The target Vector3 that the bone will look at
  36055. */
  36056. target: Vector3;
  36057. /**
  36058. * The mesh that the bone is attached to
  36059. */
  36060. mesh: AbstractMesh;
  36061. /**
  36062. * The bone that will be looking to the target
  36063. */
  36064. bone: Bone;
  36065. /**
  36066. * The up axis of the coordinate system that is used when the bone is rotated
  36067. */
  36068. upAxis: Vector3;
  36069. /**
  36070. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36071. */
  36072. upAxisSpace: Space;
  36073. /**
  36074. * Used to make an adjustment to the yaw of the bone
  36075. */
  36076. adjustYaw: number;
  36077. /**
  36078. * Used to make an adjustment to the pitch of the bone
  36079. */
  36080. adjustPitch: number;
  36081. /**
  36082. * Used to make an adjustment to the roll of the bone
  36083. */
  36084. adjustRoll: number;
  36085. /**
  36086. * 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)
  36087. */
  36088. slerpAmount: number;
  36089. private _minYaw;
  36090. private _maxYaw;
  36091. private _minPitch;
  36092. private _maxPitch;
  36093. private _minYawSin;
  36094. private _minYawCos;
  36095. private _maxYawSin;
  36096. private _maxYawCos;
  36097. private _midYawConstraint;
  36098. private _minPitchTan;
  36099. private _maxPitchTan;
  36100. private _boneQuat;
  36101. private _slerping;
  36102. private _transformYawPitch;
  36103. private _transformYawPitchInv;
  36104. private _firstFrameSkipped;
  36105. private _yawRange;
  36106. private _fowardAxis;
  36107. /**
  36108. * Gets or sets the minimum yaw angle that the bone can look to
  36109. */
  36110. minYaw: number;
  36111. /**
  36112. * Gets or sets the maximum yaw angle that the bone can look to
  36113. */
  36114. maxYaw: number;
  36115. /**
  36116. * Gets or sets the minimum pitch angle that the bone can look to
  36117. */
  36118. minPitch: number;
  36119. /**
  36120. * Gets or sets the maximum pitch angle that the bone can look to
  36121. */
  36122. maxPitch: number;
  36123. /**
  36124. * Create a BoneLookController
  36125. * @param mesh the mesh that the bone belongs to
  36126. * @param bone the bone that will be looking to the target
  36127. * @param target the target Vector3 to look at
  36128. * @param options optional settings:
  36129. * * maxYaw: the maximum angle the bone will yaw to
  36130. * * minYaw: the minimum angle the bone will yaw to
  36131. * * maxPitch: the maximum angle the bone will pitch to
  36132. * * minPitch: the minimum angle the bone will yaw to
  36133. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36134. * * upAxis: the up axis of the coordinate system
  36135. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36136. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36137. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36138. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36139. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36140. * * adjustRoll: used to make an adjustment to the roll of the bone
  36141. **/
  36142. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36143. maxYaw?: number;
  36144. minYaw?: number;
  36145. maxPitch?: number;
  36146. minPitch?: number;
  36147. slerpAmount?: number;
  36148. upAxis?: Vector3;
  36149. upAxisSpace?: Space;
  36150. yawAxis?: Vector3;
  36151. pitchAxis?: Vector3;
  36152. adjustYaw?: number;
  36153. adjustPitch?: number;
  36154. adjustRoll?: number;
  36155. });
  36156. /**
  36157. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36158. */
  36159. update(): void;
  36160. private _getAngleDiff;
  36161. private _getAngleBetween;
  36162. private _isAngleBetween;
  36163. }
  36164. }
  36165. declare module "babylonjs/Bones/index" {
  36166. export * from "babylonjs/Bones/bone";
  36167. export * from "babylonjs/Bones/boneIKController";
  36168. export * from "babylonjs/Bones/boneLookController";
  36169. export * from "babylonjs/Bones/skeleton";
  36170. }
  36171. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36172. import { Nullable } from "babylonjs/types";
  36173. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36174. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36175. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36176. /**
  36177. * Manage the gamepad inputs to control an arc rotate camera.
  36178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36179. */
  36180. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36181. /**
  36182. * Defines the camera the input is attached to.
  36183. */
  36184. camera: ArcRotateCamera;
  36185. /**
  36186. * Defines the gamepad the input is gathering event from.
  36187. */
  36188. gamepad: Nullable<Gamepad>;
  36189. /**
  36190. * Defines the gamepad rotation sensiblity.
  36191. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36192. */
  36193. gamepadRotationSensibility: number;
  36194. /**
  36195. * Defines the gamepad move sensiblity.
  36196. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36197. */
  36198. gamepadMoveSensibility: number;
  36199. private _onGamepadConnectedObserver;
  36200. private _onGamepadDisconnectedObserver;
  36201. /**
  36202. * Attach the input controls to a specific dom element to get the input from.
  36203. * @param element Defines the element the controls should be listened from
  36204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36205. */
  36206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36207. /**
  36208. * Detach the current controls from the specified dom element.
  36209. * @param element Defines the element to stop listening the inputs from
  36210. */
  36211. detachControl(element: Nullable<HTMLElement>): void;
  36212. /**
  36213. * Update the current camera state depending on the inputs that have been used this frame.
  36214. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36215. */
  36216. checkInputs(): void;
  36217. /**
  36218. * Gets the class name of the current intput.
  36219. * @returns the class name
  36220. */
  36221. getClassName(): string;
  36222. /**
  36223. * Get the friendly name associated with the input class.
  36224. * @returns the input friendly name
  36225. */
  36226. getSimpleName(): string;
  36227. }
  36228. }
  36229. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36230. import { Nullable } from "babylonjs/types";
  36231. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36232. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36233. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36234. interface ArcRotateCameraInputsManager {
  36235. /**
  36236. * Add orientation input support to the input manager.
  36237. * @returns the current input manager
  36238. */
  36239. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36240. }
  36241. }
  36242. /**
  36243. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36245. */
  36246. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36247. /**
  36248. * Defines the camera the input is attached to.
  36249. */
  36250. camera: ArcRotateCamera;
  36251. /**
  36252. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36253. */
  36254. alphaCorrection: number;
  36255. /**
  36256. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36257. */
  36258. gammaCorrection: number;
  36259. private _alpha;
  36260. private _gamma;
  36261. private _dirty;
  36262. private _deviceOrientationHandler;
  36263. /**
  36264. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36265. */
  36266. constructor();
  36267. /**
  36268. * Attach the input controls to a specific dom element to get the input from.
  36269. * @param element Defines the element the controls should be listened from
  36270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36271. */
  36272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36273. /** @hidden */
  36274. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36275. /**
  36276. * Update the current camera state depending on the inputs that have been used this frame.
  36277. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36278. */
  36279. checkInputs(): void;
  36280. /**
  36281. * Detach the current controls from the specified dom element.
  36282. * @param element Defines the element to stop listening the inputs from
  36283. */
  36284. detachControl(element: Nullable<HTMLElement>): void;
  36285. /**
  36286. * Gets the class name of the current intput.
  36287. * @returns the class name
  36288. */
  36289. getClassName(): string;
  36290. /**
  36291. * Get the friendly name associated with the input class.
  36292. * @returns the input friendly name
  36293. */
  36294. getSimpleName(): string;
  36295. }
  36296. }
  36297. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36298. import { Nullable } from "babylonjs/types";
  36299. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36300. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36301. /**
  36302. * Listen to mouse events to control the camera.
  36303. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36304. */
  36305. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36306. /**
  36307. * Defines the camera the input is attached to.
  36308. */
  36309. camera: FlyCamera;
  36310. /**
  36311. * Defines if touch is enabled. (Default is true.)
  36312. */
  36313. touchEnabled: boolean;
  36314. /**
  36315. * Defines the buttons associated with the input to handle camera rotation.
  36316. */
  36317. buttons: number[];
  36318. /**
  36319. * Assign buttons for Yaw control.
  36320. */
  36321. buttonsYaw: number[];
  36322. /**
  36323. * Assign buttons for Pitch control.
  36324. */
  36325. buttonsPitch: number[];
  36326. /**
  36327. * Assign buttons for Roll control.
  36328. */
  36329. buttonsRoll: number[];
  36330. /**
  36331. * Detect if any button is being pressed while mouse is moved.
  36332. * -1 = Mouse locked.
  36333. * 0 = Left button.
  36334. * 1 = Middle Button.
  36335. * 2 = Right Button.
  36336. */
  36337. activeButton: number;
  36338. /**
  36339. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36340. * Higher values reduce its sensitivity.
  36341. */
  36342. angularSensibility: number;
  36343. private _mousemoveCallback;
  36344. private _observer;
  36345. private _rollObserver;
  36346. private previousPosition;
  36347. private noPreventDefault;
  36348. private element;
  36349. /**
  36350. * Listen to mouse events to control the camera.
  36351. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36352. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36353. */
  36354. constructor(touchEnabled?: boolean);
  36355. /**
  36356. * Attach the mouse control to the HTML DOM element.
  36357. * @param element Defines the element that listens to the input events.
  36358. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36359. */
  36360. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36361. /**
  36362. * Detach the current controls from the specified dom element.
  36363. * @param element Defines the element to stop listening the inputs from
  36364. */
  36365. detachControl(element: Nullable<HTMLElement>): void;
  36366. /**
  36367. * Gets the class name of the current input.
  36368. * @returns the class name.
  36369. */
  36370. getClassName(): string;
  36371. /**
  36372. * Get the friendly name associated with the input class.
  36373. * @returns the input's friendly name.
  36374. */
  36375. getSimpleName(): string;
  36376. private _pointerInput;
  36377. private _onMouseMove;
  36378. /**
  36379. * Rotate camera by mouse offset.
  36380. */
  36381. private rotateCamera;
  36382. }
  36383. }
  36384. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36385. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36386. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36387. /**
  36388. * Default Inputs manager for the FlyCamera.
  36389. * It groups all the default supported inputs for ease of use.
  36390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36391. */
  36392. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36393. /**
  36394. * Instantiates a new FlyCameraInputsManager.
  36395. * @param camera Defines the camera the inputs belong to.
  36396. */
  36397. constructor(camera: FlyCamera);
  36398. /**
  36399. * Add keyboard input support to the input manager.
  36400. * @returns the new FlyCameraKeyboardMoveInput().
  36401. */
  36402. addKeyboard(): FlyCameraInputsManager;
  36403. /**
  36404. * Add mouse input support to the input manager.
  36405. * @param touchEnabled Enable touch screen support.
  36406. * @returns the new FlyCameraMouseInput().
  36407. */
  36408. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36409. }
  36410. }
  36411. declare module "babylonjs/Cameras/flyCamera" {
  36412. import { Scene } from "babylonjs/scene";
  36413. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36415. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36416. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36417. /**
  36418. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36419. * such as in a 3D Space Shooter or a Flight Simulator.
  36420. */
  36421. export class FlyCamera extends TargetCamera {
  36422. /**
  36423. * Define the collision ellipsoid of the camera.
  36424. * This is helpful for simulating a camera body, like a player's body.
  36425. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36426. */
  36427. ellipsoid: Vector3;
  36428. /**
  36429. * Define an offset for the position of the ellipsoid around the camera.
  36430. * This can be helpful if the camera is attached away from the player's body center,
  36431. * such as at its head.
  36432. */
  36433. ellipsoidOffset: Vector3;
  36434. /**
  36435. * Enable or disable collisions of the camera with the rest of the scene objects.
  36436. */
  36437. checkCollisions: boolean;
  36438. /**
  36439. * Enable or disable gravity on the camera.
  36440. */
  36441. applyGravity: boolean;
  36442. /**
  36443. * Define the current direction the camera is moving to.
  36444. */
  36445. cameraDirection: Vector3;
  36446. /**
  36447. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36448. * This overrides and empties cameraRotation.
  36449. */
  36450. rotationQuaternion: Quaternion;
  36451. /**
  36452. * Track Roll to maintain the wanted Rolling when looking around.
  36453. */
  36454. _trackRoll: number;
  36455. /**
  36456. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36457. */
  36458. rollCorrect: number;
  36459. /**
  36460. * Mimic a banked turn, Rolling the camera when Yawing.
  36461. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36462. */
  36463. bankedTurn: boolean;
  36464. /**
  36465. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36466. */
  36467. bankedTurnLimit: number;
  36468. /**
  36469. * Value of 0 disables the banked Roll.
  36470. * Value of 1 is equal to the Yaw angle in radians.
  36471. */
  36472. bankedTurnMultiplier: number;
  36473. /**
  36474. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36475. */
  36476. inputs: FlyCameraInputsManager;
  36477. /**
  36478. * Gets the input sensibility for mouse input.
  36479. * Higher values reduce sensitivity.
  36480. */
  36481. /**
  36482. * Sets the input sensibility for a mouse input.
  36483. * Higher values reduce sensitivity.
  36484. */
  36485. angularSensibility: number;
  36486. /**
  36487. * Get the keys for camera movement forward.
  36488. */
  36489. /**
  36490. * Set the keys for camera movement forward.
  36491. */
  36492. keysForward: number[];
  36493. /**
  36494. * Get the keys for camera movement backward.
  36495. */
  36496. keysBackward: number[];
  36497. /**
  36498. * Get the keys for camera movement up.
  36499. */
  36500. /**
  36501. * Set the keys for camera movement up.
  36502. */
  36503. keysUp: number[];
  36504. /**
  36505. * Get the keys for camera movement down.
  36506. */
  36507. /**
  36508. * Set the keys for camera movement down.
  36509. */
  36510. keysDown: number[];
  36511. /**
  36512. * Get the keys for camera movement left.
  36513. */
  36514. /**
  36515. * Set the keys for camera movement left.
  36516. */
  36517. keysLeft: number[];
  36518. /**
  36519. * Set the keys for camera movement right.
  36520. */
  36521. /**
  36522. * Set the keys for camera movement right.
  36523. */
  36524. keysRight: number[];
  36525. /**
  36526. * Event raised when the camera collides with a mesh in the scene.
  36527. */
  36528. onCollide: (collidedMesh: AbstractMesh) => void;
  36529. private _collider;
  36530. private _needMoveForGravity;
  36531. private _oldPosition;
  36532. private _diffPosition;
  36533. private _newPosition;
  36534. /** @hidden */
  36535. _localDirection: Vector3;
  36536. /** @hidden */
  36537. _transformedDirection: Vector3;
  36538. /**
  36539. * Instantiates a FlyCamera.
  36540. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36541. * such as in a 3D Space Shooter or a Flight Simulator.
  36542. * @param name Define the name of the camera in the scene.
  36543. * @param position Define the starting position of the camera in the scene.
  36544. * @param scene Define the scene the camera belongs to.
  36545. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36546. */
  36547. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36548. /**
  36549. * Attach a control to the HTML DOM element.
  36550. * @param element Defines the element that listens to the input events.
  36551. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36552. */
  36553. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36554. /**
  36555. * Detach a control from the HTML DOM element.
  36556. * The camera will stop reacting to that input.
  36557. * @param element Defines the element that listens to the input events.
  36558. */
  36559. detachControl(element: HTMLElement): void;
  36560. private _collisionMask;
  36561. /**
  36562. * Get the mask that the camera ignores in collision events.
  36563. */
  36564. /**
  36565. * Set the mask that the camera ignores in collision events.
  36566. */
  36567. collisionMask: number;
  36568. /** @hidden */
  36569. _collideWithWorld(displacement: Vector3): void;
  36570. /** @hidden */
  36571. private _onCollisionPositionChange;
  36572. /** @hidden */
  36573. _checkInputs(): void;
  36574. /** @hidden */
  36575. _decideIfNeedsToMove(): boolean;
  36576. /** @hidden */
  36577. _updatePosition(): void;
  36578. /**
  36579. * Restore the Roll to its target value at the rate specified.
  36580. * @param rate - Higher means slower restoring.
  36581. * @hidden
  36582. */
  36583. restoreRoll(rate: number): void;
  36584. /**
  36585. * Destroy the camera and release the current resources held by it.
  36586. */
  36587. dispose(): void;
  36588. /**
  36589. * Get the current object class name.
  36590. * @returns the class name.
  36591. */
  36592. getClassName(): string;
  36593. }
  36594. }
  36595. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36596. import { Nullable } from "babylonjs/types";
  36597. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36598. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36599. /**
  36600. * Listen to keyboard events to control the camera.
  36601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36602. */
  36603. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36604. /**
  36605. * Defines the camera the input is attached to.
  36606. */
  36607. camera: FlyCamera;
  36608. /**
  36609. * The list of keyboard keys used to control the forward move of the camera.
  36610. */
  36611. keysForward: number[];
  36612. /**
  36613. * The list of keyboard keys used to control the backward move of the camera.
  36614. */
  36615. keysBackward: number[];
  36616. /**
  36617. * The list of keyboard keys used to control the forward move of the camera.
  36618. */
  36619. keysUp: number[];
  36620. /**
  36621. * The list of keyboard keys used to control the backward move of the camera.
  36622. */
  36623. keysDown: number[];
  36624. /**
  36625. * The list of keyboard keys used to control the right strafe move of the camera.
  36626. */
  36627. keysRight: number[];
  36628. /**
  36629. * The list of keyboard keys used to control the left strafe move of the camera.
  36630. */
  36631. keysLeft: number[];
  36632. private _keys;
  36633. private _onCanvasBlurObserver;
  36634. private _onKeyboardObserver;
  36635. private _engine;
  36636. private _scene;
  36637. /**
  36638. * Attach the input controls to a specific dom element to get the input from.
  36639. * @param element Defines the element the controls should be listened from
  36640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36641. */
  36642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36643. /**
  36644. * Detach the current controls from the specified dom element.
  36645. * @param element Defines the element to stop listening the inputs from
  36646. */
  36647. detachControl(element: Nullable<HTMLElement>): void;
  36648. /**
  36649. * Gets the class name of the current intput.
  36650. * @returns the class name
  36651. */
  36652. getClassName(): string;
  36653. /** @hidden */
  36654. _onLostFocus(e: FocusEvent): void;
  36655. /**
  36656. * Get the friendly name associated with the input class.
  36657. * @returns the input friendly name
  36658. */
  36659. getSimpleName(): string;
  36660. /**
  36661. * Update the current camera state depending on the inputs that have been used this frame.
  36662. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36663. */
  36664. checkInputs(): void;
  36665. }
  36666. }
  36667. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36668. import { Nullable } from "babylonjs/types";
  36669. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36670. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36671. /**
  36672. * Manage the mouse wheel inputs to control a follow camera.
  36673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36674. */
  36675. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36676. /**
  36677. * Defines the camera the input is attached to.
  36678. */
  36679. camera: FollowCamera;
  36680. /**
  36681. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36682. */
  36683. axisControlRadius: boolean;
  36684. /**
  36685. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36686. */
  36687. axisControlHeight: boolean;
  36688. /**
  36689. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36690. */
  36691. axisControlRotation: boolean;
  36692. /**
  36693. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36694. * relation to mouseWheel events.
  36695. */
  36696. wheelPrecision: number;
  36697. /**
  36698. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36699. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36700. */
  36701. wheelDeltaPercentage: number;
  36702. private _wheel;
  36703. private _observer;
  36704. /**
  36705. * Attach the input controls to a specific dom element to get the input from.
  36706. * @param element Defines the element the controls should be listened from
  36707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36708. */
  36709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36710. /**
  36711. * Detach the current controls from the specified dom element.
  36712. * @param element Defines the element to stop listening the inputs from
  36713. */
  36714. detachControl(element: Nullable<HTMLElement>): void;
  36715. /**
  36716. * Gets the class name of the current intput.
  36717. * @returns the class name
  36718. */
  36719. getClassName(): string;
  36720. /**
  36721. * Get the friendly name associated with the input class.
  36722. * @returns the input friendly name
  36723. */
  36724. getSimpleName(): string;
  36725. }
  36726. }
  36727. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36728. import { Nullable } from "babylonjs/types";
  36729. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36730. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36731. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36732. /**
  36733. * Manage the pointers inputs to control an follow camera.
  36734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36735. */
  36736. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36737. /**
  36738. * Defines the camera the input is attached to.
  36739. */
  36740. camera: FollowCamera;
  36741. /**
  36742. * Gets the class name of the current input.
  36743. * @returns the class name
  36744. */
  36745. getClassName(): string;
  36746. /**
  36747. * Defines the pointer angular sensibility along the X axis or how fast is
  36748. * the camera rotating.
  36749. * A negative number will reverse the axis direction.
  36750. */
  36751. angularSensibilityX: number;
  36752. /**
  36753. * Defines the pointer angular sensibility along the Y axis or how fast is
  36754. * the camera rotating.
  36755. * A negative number will reverse the axis direction.
  36756. */
  36757. angularSensibilityY: number;
  36758. /**
  36759. * Defines the pointer pinch precision or how fast is the camera zooming.
  36760. * A negative number will reverse the axis direction.
  36761. */
  36762. pinchPrecision: number;
  36763. /**
  36764. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36765. * from 0.
  36766. * It defines the percentage of current camera.radius to use as delta when
  36767. * pinch zoom is used.
  36768. */
  36769. pinchDeltaPercentage: number;
  36770. /**
  36771. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36772. */
  36773. axisXControlRadius: boolean;
  36774. /**
  36775. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36776. */
  36777. axisXControlHeight: boolean;
  36778. /**
  36779. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36780. */
  36781. axisXControlRotation: boolean;
  36782. /**
  36783. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36784. */
  36785. axisYControlRadius: boolean;
  36786. /**
  36787. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36788. */
  36789. axisYControlHeight: boolean;
  36790. /**
  36791. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36792. */
  36793. axisYControlRotation: boolean;
  36794. /**
  36795. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36796. */
  36797. axisPinchControlRadius: boolean;
  36798. /**
  36799. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36800. */
  36801. axisPinchControlHeight: boolean;
  36802. /**
  36803. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36804. */
  36805. axisPinchControlRotation: boolean;
  36806. /**
  36807. * Log error messages if basic misconfiguration has occurred.
  36808. */
  36809. warningEnable: boolean;
  36810. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36811. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36812. private _warningCounter;
  36813. private _warning;
  36814. }
  36815. }
  36816. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36817. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36818. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36819. /**
  36820. * Default Inputs manager for the FollowCamera.
  36821. * It groups all the default supported inputs for ease of use.
  36822. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36823. */
  36824. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36825. /**
  36826. * Instantiates a new FollowCameraInputsManager.
  36827. * @param camera Defines the camera the inputs belong to
  36828. */
  36829. constructor(camera: FollowCamera);
  36830. /**
  36831. * Add keyboard input support to the input manager.
  36832. * @returns the current input manager
  36833. */
  36834. addKeyboard(): FollowCameraInputsManager;
  36835. /**
  36836. * Add mouse wheel input support to the input manager.
  36837. * @returns the current input manager
  36838. */
  36839. addMouseWheel(): FollowCameraInputsManager;
  36840. /**
  36841. * Add pointers input support to the input manager.
  36842. * @returns the current input manager
  36843. */
  36844. addPointers(): FollowCameraInputsManager;
  36845. /**
  36846. * Add orientation input support to the input manager.
  36847. * @returns the current input manager
  36848. */
  36849. addVRDeviceOrientation(): FollowCameraInputsManager;
  36850. }
  36851. }
  36852. declare module "babylonjs/Cameras/followCamera" {
  36853. import { Nullable } from "babylonjs/types";
  36854. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36855. import { Scene } from "babylonjs/scene";
  36856. import { Vector3 } from "babylonjs/Maths/math";
  36857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36858. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  36859. /**
  36860. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36861. * an arc rotate version arcFollowCamera are available.
  36862. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36863. */
  36864. export class FollowCamera extends TargetCamera {
  36865. /**
  36866. * Distance the follow camera should follow an object at
  36867. */
  36868. radius: number;
  36869. /**
  36870. * Minimum allowed distance of the camera to the axis of rotation
  36871. * (The camera can not get closer).
  36872. * This can help limiting how the Camera is able to move in the scene.
  36873. */
  36874. lowerRadiusLimit: Nullable<number>;
  36875. /**
  36876. * Maximum allowed distance of the camera to the axis of rotation
  36877. * (The camera can not get further).
  36878. * This can help limiting how the Camera is able to move in the scene.
  36879. */
  36880. upperRadiusLimit: Nullable<number>;
  36881. /**
  36882. * Define a rotation offset between the camera and the object it follows
  36883. */
  36884. rotationOffset: number;
  36885. /**
  36886. * Minimum allowed angle to camera position relative to target object.
  36887. * This can help limiting how the Camera is able to move in the scene.
  36888. */
  36889. lowerRotationOffsetLimit: Nullable<number>;
  36890. /**
  36891. * Maximum allowed angle to camera position relative to target object.
  36892. * This can help limiting how the Camera is able to move in the scene.
  36893. */
  36894. upperRotationOffsetLimit: Nullable<number>;
  36895. /**
  36896. * Define a height offset between the camera and the object it follows.
  36897. * It can help following an object from the top (like a car chaing a plane)
  36898. */
  36899. heightOffset: number;
  36900. /**
  36901. * Minimum allowed height of camera position relative to target object.
  36902. * This can help limiting how the Camera is able to move in the scene.
  36903. */
  36904. lowerHeightOffsetLimit: Nullable<number>;
  36905. /**
  36906. * Maximum allowed height of camera position relative to target object.
  36907. * This can help limiting how the Camera is able to move in the scene.
  36908. */
  36909. upperHeightOffsetLimit: Nullable<number>;
  36910. /**
  36911. * Define how fast the camera can accelerate to follow it s target.
  36912. */
  36913. cameraAcceleration: number;
  36914. /**
  36915. * Define the speed limit of the camera following an object.
  36916. */
  36917. maxCameraSpeed: number;
  36918. /**
  36919. * Define the target of the camera.
  36920. */
  36921. lockedTarget: Nullable<AbstractMesh>;
  36922. /**
  36923. * Defines the input associated with the camera.
  36924. */
  36925. inputs: FollowCameraInputsManager;
  36926. /**
  36927. * Instantiates the follow camera.
  36928. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36929. * @param name Define the name of the camera in the scene
  36930. * @param position Define the position of the camera
  36931. * @param scene Define the scene the camera belong to
  36932. * @param lockedTarget Define the target of the camera
  36933. */
  36934. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36935. private _follow;
  36936. /**
  36937. * Attached controls to the current camera.
  36938. * @param element Defines the element the controls should be listened from
  36939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36940. */
  36941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36942. /**
  36943. * Detach the current controls from the camera.
  36944. * The camera will stop reacting to inputs.
  36945. * @param element Defines the element to stop listening the inputs from
  36946. */
  36947. detachControl(element: HTMLElement): void;
  36948. /** @hidden */
  36949. _checkInputs(): void;
  36950. private _checkLimits;
  36951. /**
  36952. * Gets the camera class name.
  36953. * @returns the class name
  36954. */
  36955. getClassName(): string;
  36956. }
  36957. /**
  36958. * Arc Rotate version of the follow camera.
  36959. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36960. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36961. */
  36962. export class ArcFollowCamera extends TargetCamera {
  36963. /** The longitudinal angle of the camera */
  36964. alpha: number;
  36965. /** The latitudinal angle of the camera */
  36966. beta: number;
  36967. /** The radius of the camera from its target */
  36968. radius: number;
  36969. /** Define the camera target (the messh it should follow) */
  36970. target: Nullable<AbstractMesh>;
  36971. private _cartesianCoordinates;
  36972. /**
  36973. * Instantiates a new ArcFollowCamera
  36974. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36975. * @param name Define the name of the camera
  36976. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36977. * @param beta Define the rotation angle of the camera around the elevation axis
  36978. * @param radius Define the radius of the camera from its target point
  36979. * @param target Define the target of the camera
  36980. * @param scene Define the scene the camera belongs to
  36981. */
  36982. constructor(name: string,
  36983. /** The longitudinal angle of the camera */
  36984. alpha: number,
  36985. /** The latitudinal angle of the camera */
  36986. beta: number,
  36987. /** The radius of the camera from its target */
  36988. radius: number,
  36989. /** Define the camera target (the messh it should follow) */
  36990. target: Nullable<AbstractMesh>, scene: Scene);
  36991. private _follow;
  36992. /** @hidden */
  36993. _checkInputs(): void;
  36994. /**
  36995. * Returns the class name of the object.
  36996. * It is mostly used internally for serialization purposes.
  36997. */
  36998. getClassName(): string;
  36999. }
  37000. }
  37001. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37002. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37003. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37004. import { Nullable } from "babylonjs/types";
  37005. /**
  37006. * Manage the keyboard inputs to control the movement of a follow camera.
  37007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37008. */
  37009. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37010. /**
  37011. * Defines the camera the input is attached to.
  37012. */
  37013. camera: FollowCamera;
  37014. /**
  37015. * Defines the list of key codes associated with the up action (increase heightOffset)
  37016. */
  37017. keysHeightOffsetIncr: number[];
  37018. /**
  37019. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37020. */
  37021. keysHeightOffsetDecr: number[];
  37022. /**
  37023. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37024. */
  37025. keysHeightOffsetModifierAlt: boolean;
  37026. /**
  37027. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37028. */
  37029. keysHeightOffsetModifierCtrl: boolean;
  37030. /**
  37031. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37032. */
  37033. keysHeightOffsetModifierShift: boolean;
  37034. /**
  37035. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37036. */
  37037. keysRotationOffsetIncr: number[];
  37038. /**
  37039. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37040. */
  37041. keysRotationOffsetDecr: number[];
  37042. /**
  37043. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37044. */
  37045. keysRotationOffsetModifierAlt: boolean;
  37046. /**
  37047. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37048. */
  37049. keysRotationOffsetModifierCtrl: boolean;
  37050. /**
  37051. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37052. */
  37053. keysRotationOffsetModifierShift: boolean;
  37054. /**
  37055. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37056. */
  37057. keysRadiusIncr: number[];
  37058. /**
  37059. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37060. */
  37061. keysRadiusDecr: number[];
  37062. /**
  37063. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37064. */
  37065. keysRadiusModifierAlt: boolean;
  37066. /**
  37067. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37068. */
  37069. keysRadiusModifierCtrl: boolean;
  37070. /**
  37071. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37072. */
  37073. keysRadiusModifierShift: boolean;
  37074. /**
  37075. * Defines the rate of change of heightOffset.
  37076. */
  37077. heightSensibility: number;
  37078. /**
  37079. * Defines the rate of change of rotationOffset.
  37080. */
  37081. rotationSensibility: number;
  37082. /**
  37083. * Defines the rate of change of radius.
  37084. */
  37085. radiusSensibility: number;
  37086. private _keys;
  37087. private _ctrlPressed;
  37088. private _altPressed;
  37089. private _shiftPressed;
  37090. private _onCanvasBlurObserver;
  37091. private _onKeyboardObserver;
  37092. private _engine;
  37093. private _scene;
  37094. /**
  37095. * Attach the input controls to a specific dom element to get the input from.
  37096. * @param element Defines the element the controls should be listened from
  37097. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37098. */
  37099. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37100. /**
  37101. * Detach the current controls from the specified dom element.
  37102. * @param element Defines the element to stop listening the inputs from
  37103. */
  37104. detachControl(element: Nullable<HTMLElement>): void;
  37105. /**
  37106. * Update the current camera state depending on the inputs that have been used this frame.
  37107. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37108. */
  37109. checkInputs(): void;
  37110. /**
  37111. * Gets the class name of the current input.
  37112. * @returns the class name
  37113. */
  37114. getClassName(): string;
  37115. /**
  37116. * Get the friendly name associated with the input class.
  37117. * @returns the input friendly name
  37118. */
  37119. getSimpleName(): string;
  37120. /**
  37121. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37122. * allow modification of the heightOffset value.
  37123. */
  37124. private _modifierHeightOffset;
  37125. /**
  37126. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37127. * allow modification of the rotationOffset value.
  37128. */
  37129. private _modifierRotationOffset;
  37130. /**
  37131. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37132. * allow modification of the radius value.
  37133. */
  37134. private _modifierRadius;
  37135. }
  37136. }
  37137. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37138. import { Nullable } from "babylonjs/types";
  37139. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37140. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37141. module "babylonjs/Cameras/freeCameraInputsManager" {
  37142. interface FreeCameraInputsManager {
  37143. /**
  37144. * Add orientation input support to the input manager.
  37145. * @returns the current input manager
  37146. */
  37147. addDeviceOrientation(): FreeCameraInputsManager;
  37148. }
  37149. }
  37150. /**
  37151. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37152. * Screen rotation is taken into account.
  37153. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37154. */
  37155. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37156. private _camera;
  37157. private _screenOrientationAngle;
  37158. private _constantTranform;
  37159. private _screenQuaternion;
  37160. private _alpha;
  37161. private _beta;
  37162. private _gamma;
  37163. /**
  37164. * Instantiates a new input
  37165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37166. */
  37167. constructor();
  37168. /**
  37169. * Define the camera controlled by the input.
  37170. */
  37171. camera: FreeCamera;
  37172. /**
  37173. * Attach the input controls to a specific dom element to get the input from.
  37174. * @param element Defines the element the controls should be listened from
  37175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37176. */
  37177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37178. private _orientationChanged;
  37179. private _deviceOrientation;
  37180. /**
  37181. * Detach the current controls from the specified dom element.
  37182. * @param element Defines the element to stop listening the inputs from
  37183. */
  37184. detachControl(element: Nullable<HTMLElement>): void;
  37185. /**
  37186. * Update the current camera state depending on the inputs that have been used this frame.
  37187. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37188. */
  37189. checkInputs(): void;
  37190. /**
  37191. * Gets the class name of the current intput.
  37192. * @returns the class name
  37193. */
  37194. getClassName(): string;
  37195. /**
  37196. * Get the friendly name associated with the input class.
  37197. * @returns the input friendly name
  37198. */
  37199. getSimpleName(): string;
  37200. }
  37201. }
  37202. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37203. import { Nullable } from "babylonjs/types";
  37204. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37205. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37206. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37207. /**
  37208. * Manage the gamepad inputs to control a free camera.
  37209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37210. */
  37211. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37212. /**
  37213. * Define the camera the input is attached to.
  37214. */
  37215. camera: FreeCamera;
  37216. /**
  37217. * Define the Gamepad controlling the input
  37218. */
  37219. gamepad: Nullable<Gamepad>;
  37220. /**
  37221. * Defines the gamepad rotation sensiblity.
  37222. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37223. */
  37224. gamepadAngularSensibility: number;
  37225. /**
  37226. * Defines the gamepad move sensiblity.
  37227. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37228. */
  37229. gamepadMoveSensibility: number;
  37230. private _onGamepadConnectedObserver;
  37231. private _onGamepadDisconnectedObserver;
  37232. private _cameraTransform;
  37233. private _deltaTransform;
  37234. private _vector3;
  37235. private _vector2;
  37236. /**
  37237. * Attach the input controls to a specific dom element to get the input from.
  37238. * @param element Defines the element the controls should be listened from
  37239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37240. */
  37241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37242. /**
  37243. * Detach the current controls from the specified dom element.
  37244. * @param element Defines the element to stop listening the inputs from
  37245. */
  37246. detachControl(element: Nullable<HTMLElement>): void;
  37247. /**
  37248. * Update the current camera state depending on the inputs that have been used this frame.
  37249. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37250. */
  37251. checkInputs(): void;
  37252. /**
  37253. * Gets the class name of the current intput.
  37254. * @returns the class name
  37255. */
  37256. getClassName(): string;
  37257. /**
  37258. * Get the friendly name associated with the input class.
  37259. * @returns the input friendly name
  37260. */
  37261. getSimpleName(): string;
  37262. }
  37263. }
  37264. declare module "babylonjs/Misc/virtualJoystick" {
  37265. import { Nullable } from "babylonjs/types";
  37266. import { Vector3 } from "babylonjs/Maths/math";
  37267. /**
  37268. * Defines the potential axis of a Joystick
  37269. */
  37270. export enum JoystickAxis {
  37271. /** X axis */
  37272. X = 0,
  37273. /** Y axis */
  37274. Y = 1,
  37275. /** Z axis */
  37276. Z = 2
  37277. }
  37278. /**
  37279. * Class used to define virtual joystick (used in touch mode)
  37280. */
  37281. export class VirtualJoystick {
  37282. /**
  37283. * Gets or sets a boolean indicating that left and right values must be inverted
  37284. */
  37285. reverseLeftRight: boolean;
  37286. /**
  37287. * Gets or sets a boolean indicating that up and down values must be inverted
  37288. */
  37289. reverseUpDown: boolean;
  37290. /**
  37291. * Gets the offset value for the position (ie. the change of the position value)
  37292. */
  37293. deltaPosition: Vector3;
  37294. /**
  37295. * Gets a boolean indicating if the virtual joystick was pressed
  37296. */
  37297. pressed: boolean;
  37298. /**
  37299. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37300. */
  37301. static Canvas: Nullable<HTMLCanvasElement>;
  37302. private static _globalJoystickIndex;
  37303. private static vjCanvasContext;
  37304. private static vjCanvasWidth;
  37305. private static vjCanvasHeight;
  37306. private static halfWidth;
  37307. private _action;
  37308. private _axisTargetedByLeftAndRight;
  37309. private _axisTargetedByUpAndDown;
  37310. private _joystickSensibility;
  37311. private _inversedSensibility;
  37312. private _joystickPointerID;
  37313. private _joystickColor;
  37314. private _joystickPointerPos;
  37315. private _joystickPreviousPointerPos;
  37316. private _joystickPointerStartPos;
  37317. private _deltaJoystickVector;
  37318. private _leftJoystick;
  37319. private _touches;
  37320. private _onPointerDownHandlerRef;
  37321. private _onPointerMoveHandlerRef;
  37322. private _onPointerUpHandlerRef;
  37323. private _onResize;
  37324. /**
  37325. * Creates a new virtual joystick
  37326. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37327. */
  37328. constructor(leftJoystick?: boolean);
  37329. /**
  37330. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37331. * @param newJoystickSensibility defines the new sensibility
  37332. */
  37333. setJoystickSensibility(newJoystickSensibility: number): void;
  37334. private _onPointerDown;
  37335. private _onPointerMove;
  37336. private _onPointerUp;
  37337. /**
  37338. * Change the color of the virtual joystick
  37339. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37340. */
  37341. setJoystickColor(newColor: string): void;
  37342. /**
  37343. * Defines a callback to call when the joystick is touched
  37344. * @param action defines the callback
  37345. */
  37346. setActionOnTouch(action: () => any): void;
  37347. /**
  37348. * Defines which axis you'd like to control for left & right
  37349. * @param axis defines the axis to use
  37350. */
  37351. setAxisForLeftRight(axis: JoystickAxis): void;
  37352. /**
  37353. * Defines which axis you'd like to control for up & down
  37354. * @param axis defines the axis to use
  37355. */
  37356. setAxisForUpDown(axis: JoystickAxis): void;
  37357. private _drawVirtualJoystick;
  37358. /**
  37359. * Release internal HTML canvas
  37360. */
  37361. releaseCanvas(): void;
  37362. }
  37363. }
  37364. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37365. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37366. import { Nullable } from "babylonjs/types";
  37367. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37368. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37369. module "babylonjs/Cameras/freeCameraInputsManager" {
  37370. interface FreeCameraInputsManager {
  37371. /**
  37372. * Add virtual joystick input support to the input manager.
  37373. * @returns the current input manager
  37374. */
  37375. addVirtualJoystick(): FreeCameraInputsManager;
  37376. }
  37377. }
  37378. /**
  37379. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37380. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37381. */
  37382. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37383. /**
  37384. * Defines the camera the input is attached to.
  37385. */
  37386. camera: FreeCamera;
  37387. private _leftjoystick;
  37388. private _rightjoystick;
  37389. /**
  37390. * Gets the left stick of the virtual joystick.
  37391. * @returns The virtual Joystick
  37392. */
  37393. getLeftJoystick(): VirtualJoystick;
  37394. /**
  37395. * Gets the right stick of the virtual joystick.
  37396. * @returns The virtual Joystick
  37397. */
  37398. getRightJoystick(): VirtualJoystick;
  37399. /**
  37400. * Update the current camera state depending on the inputs that have been used this frame.
  37401. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37402. */
  37403. checkInputs(): void;
  37404. /**
  37405. * Attach the input controls to a specific dom element to get the input from.
  37406. * @param element Defines the element the controls should be listened from
  37407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37408. */
  37409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37410. /**
  37411. * Detach the current controls from the specified dom element.
  37412. * @param element Defines the element to stop listening the inputs from
  37413. */
  37414. detachControl(element: Nullable<HTMLElement>): void;
  37415. /**
  37416. * Gets the class name of the current intput.
  37417. * @returns the class name
  37418. */
  37419. getClassName(): string;
  37420. /**
  37421. * Get the friendly name associated with the input class.
  37422. * @returns the input friendly name
  37423. */
  37424. getSimpleName(): string;
  37425. }
  37426. }
  37427. declare module "babylonjs/Cameras/Inputs/index" {
  37428. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37429. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37430. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37431. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37432. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37433. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37434. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37435. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37436. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37437. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37438. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37439. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37440. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37441. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37442. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37443. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37444. }
  37445. declare module "babylonjs/Cameras/touchCamera" {
  37446. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37447. import { Scene } from "babylonjs/scene";
  37448. import { Vector3 } from "babylonjs/Maths/math";
  37449. /**
  37450. * This represents a FPS type of camera controlled by touch.
  37451. * This is like a universal camera minus the Gamepad controls.
  37452. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37453. */
  37454. export class TouchCamera extends FreeCamera {
  37455. /**
  37456. * Defines the touch sensibility for rotation.
  37457. * The higher the faster.
  37458. */
  37459. touchAngularSensibility: number;
  37460. /**
  37461. * Defines the touch sensibility for move.
  37462. * The higher the faster.
  37463. */
  37464. touchMoveSensibility: number;
  37465. /**
  37466. * Instantiates a new touch camera.
  37467. * This represents a FPS type of camera controlled by touch.
  37468. * This is like a universal camera minus the Gamepad controls.
  37469. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37470. * @param name Define the name of the camera in the scene
  37471. * @param position Define the start position of the camera in the scene
  37472. * @param scene Define the scene the camera belongs to
  37473. */
  37474. constructor(name: string, position: Vector3, scene: Scene);
  37475. /**
  37476. * Gets the current object class name.
  37477. * @return the class name
  37478. */
  37479. getClassName(): string;
  37480. /** @hidden */
  37481. _setupInputs(): void;
  37482. }
  37483. }
  37484. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37485. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37486. import { Scene } from "babylonjs/scene";
  37487. import { Vector3, Axis } from "babylonjs/Maths/math";
  37488. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37489. /**
  37490. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37491. * being tilted forward or back and left or right.
  37492. */
  37493. export class DeviceOrientationCamera extends FreeCamera {
  37494. private _initialQuaternion;
  37495. private _quaternionCache;
  37496. /**
  37497. * Creates a new device orientation camera
  37498. * @param name The name of the camera
  37499. * @param position The start position camera
  37500. * @param scene The scene the camera belongs to
  37501. */
  37502. constructor(name: string, position: Vector3, scene: Scene);
  37503. /**
  37504. * Gets the current instance class name ("DeviceOrientationCamera").
  37505. * This helps avoiding instanceof at run time.
  37506. * @returns the class name
  37507. */
  37508. getClassName(): string;
  37509. /**
  37510. * @hidden
  37511. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37512. */
  37513. _checkInputs(): void;
  37514. /**
  37515. * Reset the camera to its default orientation on the specified axis only.
  37516. * @param axis The axis to reset
  37517. */
  37518. resetToCurrentRotation(axis?: Axis): void;
  37519. }
  37520. }
  37521. declare module "babylonjs/Cameras/universalCamera" {
  37522. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37523. import { Scene } from "babylonjs/scene";
  37524. import { Vector3 } from "babylonjs/Maths/math";
  37525. /**
  37526. * 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,
  37527. * which still works and will still be found in many Playgrounds.
  37528. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37529. */
  37530. export class UniversalCamera extends TouchCamera {
  37531. /**
  37532. * Defines the gamepad rotation sensiblity.
  37533. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37534. */
  37535. gamepadAngularSensibility: number;
  37536. /**
  37537. * Defines the gamepad move sensiblity.
  37538. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37539. */
  37540. gamepadMoveSensibility: number;
  37541. /**
  37542. * 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,
  37543. * which still works and will still be found in many Playgrounds.
  37544. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37545. * @param name Define the name of the camera in the scene
  37546. * @param position Define the start position of the camera in the scene
  37547. * @param scene Define the scene the camera belongs to
  37548. */
  37549. constructor(name: string, position: Vector3, scene: Scene);
  37550. /**
  37551. * Gets the current object class name.
  37552. * @return the class name
  37553. */
  37554. getClassName(): string;
  37555. }
  37556. }
  37557. declare module "babylonjs/Cameras/gamepadCamera" {
  37558. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37559. import { Scene } from "babylonjs/scene";
  37560. import { Vector3 } from "babylonjs/Maths/math";
  37561. /**
  37562. * This represents a FPS type of camera. This is only here for back compat purpose.
  37563. * Please use the UniversalCamera instead as both are identical.
  37564. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37565. */
  37566. export class GamepadCamera extends UniversalCamera {
  37567. /**
  37568. * Instantiates a new Gamepad Camera
  37569. * This represents a FPS type of camera. This is only here for back compat purpose.
  37570. * Please use the UniversalCamera instead as both are identical.
  37571. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37572. * @param name Define the name of the camera in the scene
  37573. * @param position Define the start position of the camera in the scene
  37574. * @param scene Define the scene the camera belongs to
  37575. */
  37576. constructor(name: string, position: Vector3, scene: Scene);
  37577. /**
  37578. * Gets the current object class name.
  37579. * @return the class name
  37580. */
  37581. getClassName(): string;
  37582. }
  37583. }
  37584. declare module "babylonjs/Shaders/pass.fragment" {
  37585. /** @hidden */
  37586. export var passPixelShader: {
  37587. name: string;
  37588. shader: string;
  37589. };
  37590. }
  37591. declare module "babylonjs/Shaders/passCube.fragment" {
  37592. /** @hidden */
  37593. export var passCubePixelShader: {
  37594. name: string;
  37595. shader: string;
  37596. };
  37597. }
  37598. declare module "babylonjs/PostProcesses/passPostProcess" {
  37599. import { Nullable } from "babylonjs/types";
  37600. import { Camera } from "babylonjs/Cameras/camera";
  37601. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37602. import { Engine } from "babylonjs/Engines/engine";
  37603. import "babylonjs/Shaders/pass.fragment";
  37604. import "babylonjs/Shaders/passCube.fragment";
  37605. /**
  37606. * PassPostProcess which produces an output the same as it's input
  37607. */
  37608. export class PassPostProcess extends PostProcess {
  37609. /**
  37610. * Creates the PassPostProcess
  37611. * @param name The name of the effect.
  37612. * @param options The required width/height ratio to downsize to before computing the render pass.
  37613. * @param camera The camera to apply the render pass to.
  37614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37615. * @param engine The engine which the post process will be applied. (default: current engine)
  37616. * @param reusable If the post process can be reused on the same frame. (default: false)
  37617. * @param textureType The type of texture to be used when performing the post processing.
  37618. * @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)
  37619. */
  37620. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37621. }
  37622. /**
  37623. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37624. */
  37625. export class PassCubePostProcess extends PostProcess {
  37626. private _face;
  37627. /**
  37628. * Gets or sets the cube face to display.
  37629. * * 0 is +X
  37630. * * 1 is -X
  37631. * * 2 is +Y
  37632. * * 3 is -Y
  37633. * * 4 is +Z
  37634. * * 5 is -Z
  37635. */
  37636. face: number;
  37637. /**
  37638. * Creates the PassCubePostProcess
  37639. * @param name The name of the effect.
  37640. * @param options The required width/height ratio to downsize to before computing the render pass.
  37641. * @param camera The camera to apply the render pass to.
  37642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37643. * @param engine The engine which the post process will be applied. (default: current engine)
  37644. * @param reusable If the post process can be reused on the same frame. (default: false)
  37645. * @param textureType The type of texture to be used when performing the post processing.
  37646. * @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)
  37647. */
  37648. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37649. }
  37650. }
  37651. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37652. /** @hidden */
  37653. export var anaglyphPixelShader: {
  37654. name: string;
  37655. shader: string;
  37656. };
  37657. }
  37658. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37659. import { Engine } from "babylonjs/Engines/engine";
  37660. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37661. import { Camera } from "babylonjs/Cameras/camera";
  37662. import "babylonjs/Shaders/anaglyph.fragment";
  37663. /**
  37664. * Postprocess used to generate anaglyphic rendering
  37665. */
  37666. export class AnaglyphPostProcess extends PostProcess {
  37667. private _passedProcess;
  37668. /**
  37669. * Creates a new AnaglyphPostProcess
  37670. * @param name defines postprocess name
  37671. * @param options defines creation options or target ratio scale
  37672. * @param rigCameras defines cameras using this postprocess
  37673. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37674. * @param engine defines hosting engine
  37675. * @param reusable defines if the postprocess will be reused multiple times per frame
  37676. */
  37677. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37678. }
  37679. }
  37680. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37681. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37682. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37683. import { Scene } from "babylonjs/scene";
  37684. import { Vector3 } from "babylonjs/Maths/math";
  37685. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37686. /**
  37687. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37688. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37689. */
  37690. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37691. /**
  37692. * Creates a new AnaglyphArcRotateCamera
  37693. * @param name defines camera name
  37694. * @param alpha defines alpha angle (in radians)
  37695. * @param beta defines beta angle (in radians)
  37696. * @param radius defines radius
  37697. * @param target defines camera target
  37698. * @param interaxialDistance defines distance between each color axis
  37699. * @param scene defines the hosting scene
  37700. */
  37701. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37702. /**
  37703. * Gets camera class name
  37704. * @returns AnaglyphArcRotateCamera
  37705. */
  37706. getClassName(): string;
  37707. }
  37708. }
  37709. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37710. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37711. import { Scene } from "babylonjs/scene";
  37712. import { Vector3 } from "babylonjs/Maths/math";
  37713. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37714. /**
  37715. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37716. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37717. */
  37718. export class AnaglyphFreeCamera extends FreeCamera {
  37719. /**
  37720. * Creates a new AnaglyphFreeCamera
  37721. * @param name defines camera name
  37722. * @param position defines initial position
  37723. * @param interaxialDistance defines distance between each color axis
  37724. * @param scene defines the hosting scene
  37725. */
  37726. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37727. /**
  37728. * Gets camera class name
  37729. * @returns AnaglyphFreeCamera
  37730. */
  37731. getClassName(): string;
  37732. }
  37733. }
  37734. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37735. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37736. import { Scene } from "babylonjs/scene";
  37737. import { Vector3 } from "babylonjs/Maths/math";
  37738. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37739. /**
  37740. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37741. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37742. */
  37743. export class AnaglyphGamepadCamera extends GamepadCamera {
  37744. /**
  37745. * Creates a new AnaglyphGamepadCamera
  37746. * @param name defines camera name
  37747. * @param position defines initial position
  37748. * @param interaxialDistance defines distance between each color axis
  37749. * @param scene defines the hosting scene
  37750. */
  37751. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37752. /**
  37753. * Gets camera class name
  37754. * @returns AnaglyphGamepadCamera
  37755. */
  37756. getClassName(): string;
  37757. }
  37758. }
  37759. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37760. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37761. import { Scene } from "babylonjs/scene";
  37762. import { Vector3 } from "babylonjs/Maths/math";
  37763. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37764. /**
  37765. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37766. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37767. */
  37768. export class AnaglyphUniversalCamera extends UniversalCamera {
  37769. /**
  37770. * Creates a new AnaglyphUniversalCamera
  37771. * @param name defines camera name
  37772. * @param position defines initial position
  37773. * @param interaxialDistance defines distance between each color axis
  37774. * @param scene defines the hosting scene
  37775. */
  37776. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37777. /**
  37778. * Gets camera class name
  37779. * @returns AnaglyphUniversalCamera
  37780. */
  37781. getClassName(): string;
  37782. }
  37783. }
  37784. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37785. /** @hidden */
  37786. export var stereoscopicInterlacePixelShader: {
  37787. name: string;
  37788. shader: string;
  37789. };
  37790. }
  37791. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37792. import { Camera } from "babylonjs/Cameras/camera";
  37793. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37794. import { Engine } from "babylonjs/Engines/engine";
  37795. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37796. /**
  37797. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37798. */
  37799. export class StereoscopicInterlacePostProcess extends PostProcess {
  37800. private _stepSize;
  37801. private _passedProcess;
  37802. /**
  37803. * Initializes a StereoscopicInterlacePostProcess
  37804. * @param name The name of the effect.
  37805. * @param rigCameras The rig cameras to be appled to the post process
  37806. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37807. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37808. * @param engine The engine which the post process will be applied. (default: current engine)
  37809. * @param reusable If the post process can be reused on the same frame. (default: false)
  37810. */
  37811. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37812. }
  37813. }
  37814. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37815. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37816. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37817. import { Scene } from "babylonjs/scene";
  37818. import { Vector3 } from "babylonjs/Maths/math";
  37819. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37820. /**
  37821. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37822. * @see http://doc.babylonjs.com/features/cameras
  37823. */
  37824. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37825. /**
  37826. * Creates a new StereoscopicArcRotateCamera
  37827. * @param name defines camera name
  37828. * @param alpha defines alpha angle (in radians)
  37829. * @param beta defines beta angle (in radians)
  37830. * @param radius defines radius
  37831. * @param target defines camera target
  37832. * @param interaxialDistance defines distance between each color axis
  37833. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37834. * @param scene defines the hosting scene
  37835. */
  37836. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37837. /**
  37838. * Gets camera class name
  37839. * @returns StereoscopicArcRotateCamera
  37840. */
  37841. getClassName(): string;
  37842. }
  37843. }
  37844. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37845. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37846. import { Scene } from "babylonjs/scene";
  37847. import { Vector3 } from "babylonjs/Maths/math";
  37848. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37849. /**
  37850. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37851. * @see http://doc.babylonjs.com/features/cameras
  37852. */
  37853. export class StereoscopicFreeCamera extends FreeCamera {
  37854. /**
  37855. * Creates a new StereoscopicFreeCamera
  37856. * @param name defines camera name
  37857. * @param position defines initial position
  37858. * @param interaxialDistance defines distance between each color axis
  37859. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37860. * @param scene defines the hosting scene
  37861. */
  37862. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37863. /**
  37864. * Gets camera class name
  37865. * @returns StereoscopicFreeCamera
  37866. */
  37867. getClassName(): string;
  37868. }
  37869. }
  37870. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37871. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37872. import { Scene } from "babylonjs/scene";
  37873. import { Vector3 } from "babylonjs/Maths/math";
  37874. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37875. /**
  37876. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37877. * @see http://doc.babylonjs.com/features/cameras
  37878. */
  37879. export class StereoscopicGamepadCamera extends GamepadCamera {
  37880. /**
  37881. * Creates a new StereoscopicGamepadCamera
  37882. * @param name defines camera name
  37883. * @param position defines initial position
  37884. * @param interaxialDistance defines distance between each color axis
  37885. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37886. * @param scene defines the hosting scene
  37887. */
  37888. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37889. /**
  37890. * Gets camera class name
  37891. * @returns StereoscopicGamepadCamera
  37892. */
  37893. getClassName(): string;
  37894. }
  37895. }
  37896. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37897. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37898. import { Scene } from "babylonjs/scene";
  37899. import { Vector3 } from "babylonjs/Maths/math";
  37900. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37901. /**
  37902. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37903. * @see http://doc.babylonjs.com/features/cameras
  37904. */
  37905. export class StereoscopicUniversalCamera extends UniversalCamera {
  37906. /**
  37907. * Creates a new StereoscopicUniversalCamera
  37908. * @param name defines camera name
  37909. * @param position defines initial position
  37910. * @param interaxialDistance defines distance between each color axis
  37911. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37912. * @param scene defines the hosting scene
  37913. */
  37914. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37915. /**
  37916. * Gets camera class name
  37917. * @returns StereoscopicUniversalCamera
  37918. */
  37919. getClassName(): string;
  37920. }
  37921. }
  37922. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37923. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37924. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37925. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37926. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37927. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37928. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37929. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37930. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37931. }
  37932. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37933. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37934. import { Scene } from "babylonjs/scene";
  37935. import { Vector3 } from "babylonjs/Maths/math";
  37936. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37937. /**
  37938. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37939. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37940. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37941. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37942. */
  37943. export class VirtualJoysticksCamera extends FreeCamera {
  37944. /**
  37945. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37946. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37947. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37948. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37949. * @param name Define the name of the camera in the scene
  37950. * @param position Define the start position of the camera in the scene
  37951. * @param scene Define the scene the camera belongs to
  37952. */
  37953. constructor(name: string, position: Vector3, scene: Scene);
  37954. /**
  37955. * Gets the current object class name.
  37956. * @return the class name
  37957. */
  37958. getClassName(): string;
  37959. }
  37960. }
  37961. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  37962. import { Matrix } from "babylonjs/Maths/math";
  37963. /**
  37964. * This represents all the required metrics to create a VR camera.
  37965. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37966. */
  37967. export class VRCameraMetrics {
  37968. /**
  37969. * Define the horizontal resolution off the screen.
  37970. */
  37971. hResolution: number;
  37972. /**
  37973. * Define the vertical resolution off the screen.
  37974. */
  37975. vResolution: number;
  37976. /**
  37977. * Define the horizontal screen size.
  37978. */
  37979. hScreenSize: number;
  37980. /**
  37981. * Define the vertical screen size.
  37982. */
  37983. vScreenSize: number;
  37984. /**
  37985. * Define the vertical screen center position.
  37986. */
  37987. vScreenCenter: number;
  37988. /**
  37989. * Define the distance of the eyes to the screen.
  37990. */
  37991. eyeToScreenDistance: number;
  37992. /**
  37993. * Define the distance between both lenses
  37994. */
  37995. lensSeparationDistance: number;
  37996. /**
  37997. * Define the distance between both viewer's eyes.
  37998. */
  37999. interpupillaryDistance: number;
  38000. /**
  38001. * Define the distortion factor of the VR postprocess.
  38002. * Please, touch with care.
  38003. */
  38004. distortionK: number[];
  38005. /**
  38006. * Define the chromatic aberration correction factors for the VR post process.
  38007. */
  38008. chromaAbCorrection: number[];
  38009. /**
  38010. * Define the scale factor of the post process.
  38011. * The smaller the better but the slower.
  38012. */
  38013. postProcessScaleFactor: number;
  38014. /**
  38015. * Define an offset for the lens center.
  38016. */
  38017. lensCenterOffset: number;
  38018. /**
  38019. * Define if the current vr camera should compensate the distortion of the lense or not.
  38020. */
  38021. compensateDistortion: boolean;
  38022. /**
  38023. * Gets the rendering aspect ratio based on the provided resolutions.
  38024. */
  38025. readonly aspectRatio: number;
  38026. /**
  38027. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38028. */
  38029. readonly aspectRatioFov: number;
  38030. /**
  38031. * @hidden
  38032. */
  38033. readonly leftHMatrix: Matrix;
  38034. /**
  38035. * @hidden
  38036. */
  38037. readonly rightHMatrix: Matrix;
  38038. /**
  38039. * @hidden
  38040. */
  38041. readonly leftPreViewMatrix: Matrix;
  38042. /**
  38043. * @hidden
  38044. */
  38045. readonly rightPreViewMatrix: Matrix;
  38046. /**
  38047. * Get the default VRMetrics based on the most generic setup.
  38048. * @returns the default vr metrics
  38049. */
  38050. static GetDefault(): VRCameraMetrics;
  38051. }
  38052. }
  38053. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38054. /** @hidden */
  38055. export var vrDistortionCorrectionPixelShader: {
  38056. name: string;
  38057. shader: string;
  38058. };
  38059. }
  38060. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38061. import { Camera } from "babylonjs/Cameras/camera";
  38062. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38063. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38064. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38065. /**
  38066. * VRDistortionCorrectionPostProcess used for mobile VR
  38067. */
  38068. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38069. private _isRightEye;
  38070. private _distortionFactors;
  38071. private _postProcessScaleFactor;
  38072. private _lensCenterOffset;
  38073. private _scaleIn;
  38074. private _scaleFactor;
  38075. private _lensCenter;
  38076. /**
  38077. * Initializes the VRDistortionCorrectionPostProcess
  38078. * @param name The name of the effect.
  38079. * @param camera The camera to apply the render pass to.
  38080. * @param isRightEye If this is for the right eye distortion
  38081. * @param vrMetrics All the required metrics for the VR camera
  38082. */
  38083. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38084. }
  38085. }
  38086. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38087. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38088. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38089. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38090. import { Scene } from "babylonjs/scene";
  38091. import { Vector3 } from "babylonjs/Maths/math";
  38092. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38093. import "babylonjs/Cameras/RigModes/vrRigMode";
  38094. /**
  38095. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38096. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38097. */
  38098. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38099. /**
  38100. * Creates a new VRDeviceOrientationArcRotateCamera
  38101. * @param name defines camera name
  38102. * @param alpha defines the camera rotation along the logitudinal axis
  38103. * @param beta defines the camera rotation along the latitudinal axis
  38104. * @param radius defines the camera distance from its target
  38105. * @param target defines the camera target
  38106. * @param scene defines the scene the camera belongs to
  38107. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38108. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38109. */
  38110. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38111. /**
  38112. * Gets camera class name
  38113. * @returns VRDeviceOrientationArcRotateCamera
  38114. */
  38115. getClassName(): string;
  38116. }
  38117. }
  38118. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38119. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38120. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38121. import { Scene } from "babylonjs/scene";
  38122. import { Vector3 } from "babylonjs/Maths/math";
  38123. import "babylonjs/Cameras/RigModes/vrRigMode";
  38124. /**
  38125. * Camera used to simulate VR rendering (based on FreeCamera)
  38126. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38127. */
  38128. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38129. /**
  38130. * Creates a new VRDeviceOrientationFreeCamera
  38131. * @param name defines camera name
  38132. * @param position defines the start position of the camera
  38133. * @param scene defines the scene the camera belongs to
  38134. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38135. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38136. */
  38137. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38138. /**
  38139. * Gets camera class name
  38140. * @returns VRDeviceOrientationFreeCamera
  38141. */
  38142. getClassName(): string;
  38143. }
  38144. }
  38145. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38146. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38147. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38148. import { Scene } from "babylonjs/scene";
  38149. import { Vector3 } from "babylonjs/Maths/math";
  38150. /**
  38151. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38152. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38153. */
  38154. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38155. /**
  38156. * Creates a new VRDeviceOrientationGamepadCamera
  38157. * @param name defines camera name
  38158. * @param position defines the start position of the camera
  38159. * @param scene defines the scene the camera belongs to
  38160. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38161. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38162. */
  38163. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38164. /**
  38165. * Gets camera class name
  38166. * @returns VRDeviceOrientationGamepadCamera
  38167. */
  38168. getClassName(): string;
  38169. }
  38170. }
  38171. declare module "babylonjs/Gamepads/xboxGamepad" {
  38172. import { Observable } from "babylonjs/Misc/observable";
  38173. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38174. /**
  38175. * Defines supported buttons for XBox360 compatible gamepads
  38176. */
  38177. export enum Xbox360Button {
  38178. /** A */
  38179. A = 0,
  38180. /** B */
  38181. B = 1,
  38182. /** X */
  38183. X = 2,
  38184. /** Y */
  38185. Y = 3,
  38186. /** Start */
  38187. Start = 4,
  38188. /** Back */
  38189. Back = 5,
  38190. /** Left button */
  38191. LB = 6,
  38192. /** Right button */
  38193. RB = 7,
  38194. /** Left stick */
  38195. LeftStick = 8,
  38196. /** Right stick */
  38197. RightStick = 9
  38198. }
  38199. /** Defines values for XBox360 DPad */
  38200. export enum Xbox360Dpad {
  38201. /** Up */
  38202. Up = 0,
  38203. /** Down */
  38204. Down = 1,
  38205. /** Left */
  38206. Left = 2,
  38207. /** Right */
  38208. Right = 3
  38209. }
  38210. /**
  38211. * Defines a XBox360 gamepad
  38212. */
  38213. export class Xbox360Pad extends Gamepad {
  38214. private _leftTrigger;
  38215. private _rightTrigger;
  38216. private _onlefttriggerchanged;
  38217. private _onrighttriggerchanged;
  38218. private _onbuttondown;
  38219. private _onbuttonup;
  38220. private _ondpaddown;
  38221. private _ondpadup;
  38222. /** Observable raised when a button is pressed */
  38223. onButtonDownObservable: Observable<Xbox360Button>;
  38224. /** Observable raised when a button is released */
  38225. onButtonUpObservable: Observable<Xbox360Button>;
  38226. /** Observable raised when a pad is pressed */
  38227. onPadDownObservable: Observable<Xbox360Dpad>;
  38228. /** Observable raised when a pad is released */
  38229. onPadUpObservable: Observable<Xbox360Dpad>;
  38230. private _buttonA;
  38231. private _buttonB;
  38232. private _buttonX;
  38233. private _buttonY;
  38234. private _buttonBack;
  38235. private _buttonStart;
  38236. private _buttonLB;
  38237. private _buttonRB;
  38238. private _buttonLeftStick;
  38239. private _buttonRightStick;
  38240. private _dPadUp;
  38241. private _dPadDown;
  38242. private _dPadLeft;
  38243. private _dPadRight;
  38244. private _isXboxOnePad;
  38245. /**
  38246. * Creates a new XBox360 gamepad object
  38247. * @param id defines the id of this gamepad
  38248. * @param index defines its index
  38249. * @param gamepad defines the internal HTML gamepad object
  38250. * @param xboxOne defines if it is a XBox One gamepad
  38251. */
  38252. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38253. /**
  38254. * Defines the callback to call when left trigger is pressed
  38255. * @param callback defines the callback to use
  38256. */
  38257. onlefttriggerchanged(callback: (value: number) => void): void;
  38258. /**
  38259. * Defines the callback to call when right trigger is pressed
  38260. * @param callback defines the callback to use
  38261. */
  38262. onrighttriggerchanged(callback: (value: number) => void): void;
  38263. /**
  38264. * Gets the left trigger value
  38265. */
  38266. /**
  38267. * Sets the left trigger value
  38268. */
  38269. leftTrigger: number;
  38270. /**
  38271. * Gets the right trigger value
  38272. */
  38273. /**
  38274. * Sets the right trigger value
  38275. */
  38276. rightTrigger: number;
  38277. /**
  38278. * Defines the callback to call when a button is pressed
  38279. * @param callback defines the callback to use
  38280. */
  38281. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38282. /**
  38283. * Defines the callback to call when a button is released
  38284. * @param callback defines the callback to use
  38285. */
  38286. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38287. /**
  38288. * Defines the callback to call when a pad is pressed
  38289. * @param callback defines the callback to use
  38290. */
  38291. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38292. /**
  38293. * Defines the callback to call when a pad is released
  38294. * @param callback defines the callback to use
  38295. */
  38296. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38297. private _setButtonValue;
  38298. private _setDPadValue;
  38299. /**
  38300. * Gets the value of the `A` button
  38301. */
  38302. /**
  38303. * Sets the value of the `A` button
  38304. */
  38305. buttonA: number;
  38306. /**
  38307. * Gets the value of the `B` button
  38308. */
  38309. /**
  38310. * Sets the value of the `B` button
  38311. */
  38312. buttonB: number;
  38313. /**
  38314. * Gets the value of the `X` button
  38315. */
  38316. /**
  38317. * Sets the value of the `X` button
  38318. */
  38319. buttonX: number;
  38320. /**
  38321. * Gets the value of the `Y` button
  38322. */
  38323. /**
  38324. * Sets the value of the `Y` button
  38325. */
  38326. buttonY: number;
  38327. /**
  38328. * Gets the value of the `Start` button
  38329. */
  38330. /**
  38331. * Sets the value of the `Start` button
  38332. */
  38333. buttonStart: number;
  38334. /**
  38335. * Gets the value of the `Back` button
  38336. */
  38337. /**
  38338. * Sets the value of the `Back` button
  38339. */
  38340. buttonBack: number;
  38341. /**
  38342. * Gets the value of the `Left` button
  38343. */
  38344. /**
  38345. * Sets the value of the `Left` button
  38346. */
  38347. buttonLB: number;
  38348. /**
  38349. * Gets the value of the `Right` button
  38350. */
  38351. /**
  38352. * Sets the value of the `Right` button
  38353. */
  38354. buttonRB: number;
  38355. /**
  38356. * Gets the value of the Left joystick
  38357. */
  38358. /**
  38359. * Sets the value of the Left joystick
  38360. */
  38361. buttonLeftStick: number;
  38362. /**
  38363. * Gets the value of the Right joystick
  38364. */
  38365. /**
  38366. * Sets the value of the Right joystick
  38367. */
  38368. buttonRightStick: number;
  38369. /**
  38370. * Gets the value of D-pad up
  38371. */
  38372. /**
  38373. * Sets the value of D-pad up
  38374. */
  38375. dPadUp: number;
  38376. /**
  38377. * Gets the value of D-pad down
  38378. */
  38379. /**
  38380. * Sets the value of D-pad down
  38381. */
  38382. dPadDown: number;
  38383. /**
  38384. * Gets the value of D-pad left
  38385. */
  38386. /**
  38387. * Sets the value of D-pad left
  38388. */
  38389. dPadLeft: number;
  38390. /**
  38391. * Gets the value of D-pad right
  38392. */
  38393. /**
  38394. * Sets the value of D-pad right
  38395. */
  38396. dPadRight: number;
  38397. /**
  38398. * Force the gamepad to synchronize with device values
  38399. */
  38400. update(): void;
  38401. /**
  38402. * Disposes the gamepad
  38403. */
  38404. dispose(): void;
  38405. }
  38406. }
  38407. declare module "babylonjs/Materials/pushMaterial" {
  38408. import { Nullable } from "babylonjs/types";
  38409. import { Scene } from "babylonjs/scene";
  38410. import { Matrix } from "babylonjs/Maths/math";
  38411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38412. import { Mesh } from "babylonjs/Meshes/mesh";
  38413. import { Material } from "babylonjs/Materials/material";
  38414. import { Effect } from "babylonjs/Materials/effect";
  38415. /**
  38416. * Base class of materials working in push mode in babylon JS
  38417. * @hidden
  38418. */
  38419. export class PushMaterial extends Material {
  38420. protected _activeEffect: Effect;
  38421. protected _normalMatrix: Matrix;
  38422. /**
  38423. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38424. * This means that the material can keep using a previous shader while a new one is being compiled.
  38425. * This is mostly used when shader parallel compilation is supported (true by default)
  38426. */
  38427. allowShaderHotSwapping: boolean;
  38428. constructor(name: string, scene: Scene);
  38429. getEffect(): Effect;
  38430. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38431. /**
  38432. * Binds the given world matrix to the active effect
  38433. *
  38434. * @param world the matrix to bind
  38435. */
  38436. bindOnlyWorldMatrix(world: Matrix): void;
  38437. /**
  38438. * Binds the given normal matrix to the active effect
  38439. *
  38440. * @param normalMatrix the matrix to bind
  38441. */
  38442. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38443. bind(world: Matrix, mesh?: Mesh): void;
  38444. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38445. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38446. }
  38447. }
  38448. declare module "babylonjs/Materials/materialFlags" {
  38449. /**
  38450. * This groups all the flags used to control the materials channel.
  38451. */
  38452. export class MaterialFlags {
  38453. private static _DiffuseTextureEnabled;
  38454. /**
  38455. * Are diffuse textures enabled in the application.
  38456. */
  38457. static DiffuseTextureEnabled: boolean;
  38458. private static _AmbientTextureEnabled;
  38459. /**
  38460. * Are ambient textures enabled in the application.
  38461. */
  38462. static AmbientTextureEnabled: boolean;
  38463. private static _OpacityTextureEnabled;
  38464. /**
  38465. * Are opacity textures enabled in the application.
  38466. */
  38467. static OpacityTextureEnabled: boolean;
  38468. private static _ReflectionTextureEnabled;
  38469. /**
  38470. * Are reflection textures enabled in the application.
  38471. */
  38472. static ReflectionTextureEnabled: boolean;
  38473. private static _EmissiveTextureEnabled;
  38474. /**
  38475. * Are emissive textures enabled in the application.
  38476. */
  38477. static EmissiveTextureEnabled: boolean;
  38478. private static _SpecularTextureEnabled;
  38479. /**
  38480. * Are specular textures enabled in the application.
  38481. */
  38482. static SpecularTextureEnabled: boolean;
  38483. private static _BumpTextureEnabled;
  38484. /**
  38485. * Are bump textures enabled in the application.
  38486. */
  38487. static BumpTextureEnabled: boolean;
  38488. private static _LightmapTextureEnabled;
  38489. /**
  38490. * Are lightmap textures enabled in the application.
  38491. */
  38492. static LightmapTextureEnabled: boolean;
  38493. private static _RefractionTextureEnabled;
  38494. /**
  38495. * Are refraction textures enabled in the application.
  38496. */
  38497. static RefractionTextureEnabled: boolean;
  38498. private static _ColorGradingTextureEnabled;
  38499. /**
  38500. * Are color grading textures enabled in the application.
  38501. */
  38502. static ColorGradingTextureEnabled: boolean;
  38503. private static _FresnelEnabled;
  38504. /**
  38505. * Are fresnels enabled in the application.
  38506. */
  38507. static FresnelEnabled: boolean;
  38508. private static _ClearCoatTextureEnabled;
  38509. /**
  38510. * Are clear coat textures enabled in the application.
  38511. */
  38512. static ClearCoatTextureEnabled: boolean;
  38513. private static _ClearCoatBumpTextureEnabled;
  38514. /**
  38515. * Are clear coat bump textures enabled in the application.
  38516. */
  38517. static ClearCoatBumpTextureEnabled: boolean;
  38518. private static _ClearCoatTintTextureEnabled;
  38519. /**
  38520. * Are clear coat tint textures enabled in the application.
  38521. */
  38522. static ClearCoatTintTextureEnabled: boolean;
  38523. }
  38524. }
  38525. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38526. /** @hidden */
  38527. export var defaultFragmentDeclaration: {
  38528. name: string;
  38529. shader: string;
  38530. };
  38531. }
  38532. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38533. /** @hidden */
  38534. export var defaultUboDeclaration: {
  38535. name: string;
  38536. shader: string;
  38537. };
  38538. }
  38539. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38540. /** @hidden */
  38541. export var lightFragmentDeclaration: {
  38542. name: string;
  38543. shader: string;
  38544. };
  38545. }
  38546. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38547. /** @hidden */
  38548. export var lightUboDeclaration: {
  38549. name: string;
  38550. shader: string;
  38551. };
  38552. }
  38553. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38554. /** @hidden */
  38555. export var lightsFragmentFunctions: {
  38556. name: string;
  38557. shader: string;
  38558. };
  38559. }
  38560. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38561. /** @hidden */
  38562. export var shadowsFragmentFunctions: {
  38563. name: string;
  38564. shader: string;
  38565. };
  38566. }
  38567. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38568. /** @hidden */
  38569. export var fresnelFunction: {
  38570. name: string;
  38571. shader: string;
  38572. };
  38573. }
  38574. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38575. /** @hidden */
  38576. export var reflectionFunction: {
  38577. name: string;
  38578. shader: string;
  38579. };
  38580. }
  38581. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38582. /** @hidden */
  38583. export var bumpFragmentFunctions: {
  38584. name: string;
  38585. shader: string;
  38586. };
  38587. }
  38588. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38589. /** @hidden */
  38590. export var logDepthDeclaration: {
  38591. name: string;
  38592. shader: string;
  38593. };
  38594. }
  38595. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38596. /** @hidden */
  38597. export var bumpFragment: {
  38598. name: string;
  38599. shader: string;
  38600. };
  38601. }
  38602. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38603. /** @hidden */
  38604. export var depthPrePass: {
  38605. name: string;
  38606. shader: string;
  38607. };
  38608. }
  38609. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38610. /** @hidden */
  38611. export var lightFragment: {
  38612. name: string;
  38613. shader: string;
  38614. };
  38615. }
  38616. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38617. /** @hidden */
  38618. export var logDepthFragment: {
  38619. name: string;
  38620. shader: string;
  38621. };
  38622. }
  38623. declare module "babylonjs/Shaders/default.fragment" {
  38624. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38625. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38626. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38627. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38628. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38629. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38630. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38631. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38632. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38633. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38634. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38635. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38636. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38637. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38638. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38639. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38640. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38641. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38642. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38643. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38644. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38645. /** @hidden */
  38646. export var defaultPixelShader: {
  38647. name: string;
  38648. shader: string;
  38649. };
  38650. }
  38651. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38652. /** @hidden */
  38653. export var defaultVertexDeclaration: {
  38654. name: string;
  38655. shader: string;
  38656. };
  38657. }
  38658. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38659. /** @hidden */
  38660. export var bumpVertexDeclaration: {
  38661. name: string;
  38662. shader: string;
  38663. };
  38664. }
  38665. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38666. /** @hidden */
  38667. export var bumpVertex: {
  38668. name: string;
  38669. shader: string;
  38670. };
  38671. }
  38672. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38673. /** @hidden */
  38674. export var fogVertex: {
  38675. name: string;
  38676. shader: string;
  38677. };
  38678. }
  38679. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38680. /** @hidden */
  38681. export var shadowsVertex: {
  38682. name: string;
  38683. shader: string;
  38684. };
  38685. }
  38686. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38687. /** @hidden */
  38688. export var pointCloudVertex: {
  38689. name: string;
  38690. shader: string;
  38691. };
  38692. }
  38693. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38694. /** @hidden */
  38695. export var logDepthVertex: {
  38696. name: string;
  38697. shader: string;
  38698. };
  38699. }
  38700. declare module "babylonjs/Shaders/default.vertex" {
  38701. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38702. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38703. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38704. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38705. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38706. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38707. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38708. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38709. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38710. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38711. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38712. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38713. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38714. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38715. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38716. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38717. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38718. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38719. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38720. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38721. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38722. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38723. /** @hidden */
  38724. export var defaultVertexShader: {
  38725. name: string;
  38726. shader: string;
  38727. };
  38728. }
  38729. declare module "babylonjs/Materials/standardMaterial" {
  38730. import { SmartArray } from "babylonjs/Misc/smartArray";
  38731. import { IAnimatable } from "babylonjs/Misc/tools";
  38732. import { Nullable } from "babylonjs/types";
  38733. import { Scene } from "babylonjs/scene";
  38734. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38735. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38737. import { Mesh } from "babylonjs/Meshes/mesh";
  38738. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38739. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38740. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38741. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38742. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38743. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38744. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38745. import "babylonjs/Shaders/default.fragment";
  38746. import "babylonjs/Shaders/default.vertex";
  38747. /** @hidden */
  38748. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38749. MAINUV1: boolean;
  38750. MAINUV2: boolean;
  38751. DIFFUSE: boolean;
  38752. DIFFUSEDIRECTUV: number;
  38753. AMBIENT: boolean;
  38754. AMBIENTDIRECTUV: number;
  38755. OPACITY: boolean;
  38756. OPACITYDIRECTUV: number;
  38757. OPACITYRGB: boolean;
  38758. REFLECTION: boolean;
  38759. EMISSIVE: boolean;
  38760. EMISSIVEDIRECTUV: number;
  38761. SPECULAR: boolean;
  38762. SPECULARDIRECTUV: number;
  38763. BUMP: boolean;
  38764. BUMPDIRECTUV: number;
  38765. PARALLAX: boolean;
  38766. PARALLAXOCCLUSION: boolean;
  38767. SPECULAROVERALPHA: boolean;
  38768. CLIPPLANE: boolean;
  38769. CLIPPLANE2: boolean;
  38770. CLIPPLANE3: boolean;
  38771. CLIPPLANE4: boolean;
  38772. ALPHATEST: boolean;
  38773. DEPTHPREPASS: boolean;
  38774. ALPHAFROMDIFFUSE: boolean;
  38775. POINTSIZE: boolean;
  38776. FOG: boolean;
  38777. SPECULARTERM: boolean;
  38778. DIFFUSEFRESNEL: boolean;
  38779. OPACITYFRESNEL: boolean;
  38780. REFLECTIONFRESNEL: boolean;
  38781. REFRACTIONFRESNEL: boolean;
  38782. EMISSIVEFRESNEL: boolean;
  38783. FRESNEL: boolean;
  38784. NORMAL: boolean;
  38785. UV1: boolean;
  38786. UV2: boolean;
  38787. VERTEXCOLOR: boolean;
  38788. VERTEXALPHA: boolean;
  38789. NUM_BONE_INFLUENCERS: number;
  38790. BonesPerMesh: number;
  38791. BONETEXTURE: boolean;
  38792. INSTANCES: boolean;
  38793. GLOSSINESS: boolean;
  38794. ROUGHNESS: boolean;
  38795. EMISSIVEASILLUMINATION: boolean;
  38796. LINKEMISSIVEWITHDIFFUSE: boolean;
  38797. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38798. LIGHTMAP: boolean;
  38799. LIGHTMAPDIRECTUV: number;
  38800. OBJECTSPACE_NORMALMAP: boolean;
  38801. USELIGHTMAPASSHADOWMAP: boolean;
  38802. REFLECTIONMAP_3D: boolean;
  38803. REFLECTIONMAP_SPHERICAL: boolean;
  38804. REFLECTIONMAP_PLANAR: boolean;
  38805. REFLECTIONMAP_CUBIC: boolean;
  38806. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38807. REFLECTIONMAP_PROJECTION: boolean;
  38808. REFLECTIONMAP_SKYBOX: boolean;
  38809. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38810. REFLECTIONMAP_EXPLICIT: boolean;
  38811. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38812. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38813. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38814. INVERTCUBICMAP: boolean;
  38815. LOGARITHMICDEPTH: boolean;
  38816. REFRACTION: boolean;
  38817. REFRACTIONMAP_3D: boolean;
  38818. REFLECTIONOVERALPHA: boolean;
  38819. TWOSIDEDLIGHTING: boolean;
  38820. SHADOWFLOAT: boolean;
  38821. MORPHTARGETS: boolean;
  38822. MORPHTARGETS_NORMAL: boolean;
  38823. MORPHTARGETS_TANGENT: boolean;
  38824. NUM_MORPH_INFLUENCERS: number;
  38825. NONUNIFORMSCALING: boolean;
  38826. PREMULTIPLYALPHA: boolean;
  38827. IMAGEPROCESSING: boolean;
  38828. VIGNETTE: boolean;
  38829. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38830. VIGNETTEBLENDMODEOPAQUE: boolean;
  38831. TONEMAPPING: boolean;
  38832. TONEMAPPING_ACES: boolean;
  38833. CONTRAST: boolean;
  38834. COLORCURVES: boolean;
  38835. COLORGRADING: boolean;
  38836. COLORGRADING3D: boolean;
  38837. SAMPLER3DGREENDEPTH: boolean;
  38838. SAMPLER3DBGRMAP: boolean;
  38839. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38840. /**
  38841. * If the reflection texture on this material is in linear color space
  38842. * @hidden
  38843. */
  38844. IS_REFLECTION_LINEAR: boolean;
  38845. /**
  38846. * If the refraction texture on this material is in linear color space
  38847. * @hidden
  38848. */
  38849. IS_REFRACTION_LINEAR: boolean;
  38850. EXPOSURE: boolean;
  38851. constructor();
  38852. setReflectionMode(modeToEnable: string): void;
  38853. }
  38854. /**
  38855. * This is the default material used in Babylon. It is the best trade off between quality
  38856. * and performances.
  38857. * @see http://doc.babylonjs.com/babylon101/materials
  38858. */
  38859. export class StandardMaterial extends PushMaterial {
  38860. private _diffuseTexture;
  38861. /**
  38862. * The basic texture of the material as viewed under a light.
  38863. */
  38864. diffuseTexture: Nullable<BaseTexture>;
  38865. private _ambientTexture;
  38866. /**
  38867. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38868. */
  38869. ambientTexture: Nullable<BaseTexture>;
  38870. private _opacityTexture;
  38871. /**
  38872. * Define the transparency of the material from a texture.
  38873. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38874. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38875. */
  38876. opacityTexture: Nullable<BaseTexture>;
  38877. private _reflectionTexture;
  38878. /**
  38879. * Define the texture used to display the reflection.
  38880. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38881. */
  38882. reflectionTexture: Nullable<BaseTexture>;
  38883. private _emissiveTexture;
  38884. /**
  38885. * Define texture of the material as if self lit.
  38886. * This will be mixed in the final result even in the absence of light.
  38887. */
  38888. emissiveTexture: Nullable<BaseTexture>;
  38889. private _specularTexture;
  38890. /**
  38891. * Define how the color and intensity of the highlight given by the light in the material.
  38892. */
  38893. specularTexture: Nullable<BaseTexture>;
  38894. private _bumpTexture;
  38895. /**
  38896. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38897. * 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.
  38898. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38899. */
  38900. bumpTexture: Nullable<BaseTexture>;
  38901. private _lightmapTexture;
  38902. /**
  38903. * Complex lighting can be computationally expensive to compute at runtime.
  38904. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38905. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38906. */
  38907. lightmapTexture: Nullable<BaseTexture>;
  38908. private _refractionTexture;
  38909. /**
  38910. * Define the texture used to display the refraction.
  38911. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38912. */
  38913. refractionTexture: Nullable<BaseTexture>;
  38914. /**
  38915. * The color of the material lit by the environmental background lighting.
  38916. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38917. */
  38918. ambientColor: Color3;
  38919. /**
  38920. * The basic color of the material as viewed under a light.
  38921. */
  38922. diffuseColor: Color3;
  38923. /**
  38924. * Define how the color and intensity of the highlight given by the light in the material.
  38925. */
  38926. specularColor: Color3;
  38927. /**
  38928. * Define the color of the material as if self lit.
  38929. * This will be mixed in the final result even in the absence of light.
  38930. */
  38931. emissiveColor: Color3;
  38932. /**
  38933. * Defines how sharp are the highlights in the material.
  38934. * The bigger the value the sharper giving a more glossy feeling to the result.
  38935. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38936. */
  38937. specularPower: number;
  38938. private _useAlphaFromDiffuseTexture;
  38939. /**
  38940. * Does the transparency come from the diffuse texture alpha channel.
  38941. */
  38942. useAlphaFromDiffuseTexture: boolean;
  38943. private _useEmissiveAsIllumination;
  38944. /**
  38945. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38946. */
  38947. useEmissiveAsIllumination: boolean;
  38948. private _linkEmissiveWithDiffuse;
  38949. /**
  38950. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38951. * the emissive level when the final color is close to one.
  38952. */
  38953. linkEmissiveWithDiffuse: boolean;
  38954. private _useSpecularOverAlpha;
  38955. /**
  38956. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38957. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38958. */
  38959. useSpecularOverAlpha: boolean;
  38960. private _useReflectionOverAlpha;
  38961. /**
  38962. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38963. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38964. */
  38965. useReflectionOverAlpha: boolean;
  38966. private _disableLighting;
  38967. /**
  38968. * Does lights from the scene impacts this material.
  38969. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38970. */
  38971. disableLighting: boolean;
  38972. private _useObjectSpaceNormalMap;
  38973. /**
  38974. * Allows using an object space normal map (instead of tangent space).
  38975. */
  38976. useObjectSpaceNormalMap: boolean;
  38977. private _useParallax;
  38978. /**
  38979. * Is parallax enabled or not.
  38980. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38981. */
  38982. useParallax: boolean;
  38983. private _useParallaxOcclusion;
  38984. /**
  38985. * Is parallax occlusion enabled or not.
  38986. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38987. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38988. */
  38989. useParallaxOcclusion: boolean;
  38990. /**
  38991. * 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.
  38992. */
  38993. parallaxScaleBias: number;
  38994. private _roughness;
  38995. /**
  38996. * Helps to define how blurry the reflections should appears in the material.
  38997. */
  38998. roughness: number;
  38999. /**
  39000. * In case of refraction, define the value of the indice of refraction.
  39001. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39002. */
  39003. indexOfRefraction: number;
  39004. /**
  39005. * Invert the refraction texture alongside the y axis.
  39006. * It can be useful with procedural textures or probe for instance.
  39007. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39008. */
  39009. invertRefractionY: boolean;
  39010. /**
  39011. * Defines the alpha limits in alpha test mode.
  39012. */
  39013. alphaCutOff: number;
  39014. private _useLightmapAsShadowmap;
  39015. /**
  39016. * In case of light mapping, define whether the map contains light or shadow informations.
  39017. */
  39018. useLightmapAsShadowmap: boolean;
  39019. private _diffuseFresnelParameters;
  39020. /**
  39021. * Define the diffuse fresnel parameters of the material.
  39022. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39023. */
  39024. diffuseFresnelParameters: FresnelParameters;
  39025. private _opacityFresnelParameters;
  39026. /**
  39027. * Define the opacity fresnel parameters of the material.
  39028. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39029. */
  39030. opacityFresnelParameters: FresnelParameters;
  39031. private _reflectionFresnelParameters;
  39032. /**
  39033. * Define the reflection fresnel parameters of the material.
  39034. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39035. */
  39036. reflectionFresnelParameters: FresnelParameters;
  39037. private _refractionFresnelParameters;
  39038. /**
  39039. * Define the refraction fresnel parameters of the material.
  39040. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39041. */
  39042. refractionFresnelParameters: FresnelParameters;
  39043. private _emissiveFresnelParameters;
  39044. /**
  39045. * Define the emissive fresnel parameters of the material.
  39046. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39047. */
  39048. emissiveFresnelParameters: FresnelParameters;
  39049. private _useReflectionFresnelFromSpecular;
  39050. /**
  39051. * If true automatically deducts the fresnels values from the material specularity.
  39052. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39053. */
  39054. useReflectionFresnelFromSpecular: boolean;
  39055. private _useGlossinessFromSpecularMapAlpha;
  39056. /**
  39057. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39058. */
  39059. useGlossinessFromSpecularMapAlpha: boolean;
  39060. private _maxSimultaneousLights;
  39061. /**
  39062. * Defines the maximum number of lights that can be used in the material
  39063. */
  39064. maxSimultaneousLights: number;
  39065. private _invertNormalMapX;
  39066. /**
  39067. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39068. */
  39069. invertNormalMapX: boolean;
  39070. private _invertNormalMapY;
  39071. /**
  39072. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39073. */
  39074. invertNormalMapY: boolean;
  39075. private _twoSidedLighting;
  39076. /**
  39077. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39078. */
  39079. twoSidedLighting: boolean;
  39080. /**
  39081. * Default configuration related to image processing available in the standard Material.
  39082. */
  39083. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39084. /**
  39085. * Gets the image processing configuration used either in this material.
  39086. */
  39087. /**
  39088. * Sets the Default image processing configuration used either in the this material.
  39089. *
  39090. * If sets to null, the scene one is in use.
  39091. */
  39092. imageProcessingConfiguration: ImageProcessingConfiguration;
  39093. /**
  39094. * Keep track of the image processing observer to allow dispose and replace.
  39095. */
  39096. private _imageProcessingObserver;
  39097. /**
  39098. * Attaches a new image processing configuration to the Standard Material.
  39099. * @param configuration
  39100. */
  39101. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39102. /**
  39103. * Gets wether the color curves effect is enabled.
  39104. */
  39105. /**
  39106. * Sets wether the color curves effect is enabled.
  39107. */
  39108. cameraColorCurvesEnabled: boolean;
  39109. /**
  39110. * Gets wether the color grading effect is enabled.
  39111. */
  39112. /**
  39113. * Gets wether the color grading effect is enabled.
  39114. */
  39115. cameraColorGradingEnabled: boolean;
  39116. /**
  39117. * Gets wether tonemapping is enabled or not.
  39118. */
  39119. /**
  39120. * Sets wether tonemapping is enabled or not
  39121. */
  39122. cameraToneMappingEnabled: boolean;
  39123. /**
  39124. * The camera exposure used on this material.
  39125. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39126. * This corresponds to a photographic exposure.
  39127. */
  39128. /**
  39129. * The camera exposure used on this material.
  39130. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39131. * This corresponds to a photographic exposure.
  39132. */
  39133. cameraExposure: number;
  39134. /**
  39135. * Gets The camera contrast used on this material.
  39136. */
  39137. /**
  39138. * Sets The camera contrast used on this material.
  39139. */
  39140. cameraContrast: number;
  39141. /**
  39142. * Gets the Color Grading 2D Lookup Texture.
  39143. */
  39144. /**
  39145. * Sets the Color Grading 2D Lookup Texture.
  39146. */
  39147. cameraColorGradingTexture: Nullable<BaseTexture>;
  39148. /**
  39149. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39150. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39151. * 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;
  39152. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39153. */
  39154. /**
  39155. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39156. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39157. * 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;
  39158. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39159. */
  39160. cameraColorCurves: Nullable<ColorCurves>;
  39161. /**
  39162. * Custom callback helping to override the default shader used in the material.
  39163. */
  39164. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39165. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39166. protected _worldViewProjectionMatrix: Matrix;
  39167. protected _globalAmbientColor: Color3;
  39168. protected _useLogarithmicDepth: boolean;
  39169. /**
  39170. * Instantiates a new standard material.
  39171. * This is the default material used in Babylon. It is the best trade off between quality
  39172. * and performances.
  39173. * @see http://doc.babylonjs.com/babylon101/materials
  39174. * @param name Define the name of the material in the scene
  39175. * @param scene Define the scene the material belong to
  39176. */
  39177. constructor(name: string, scene: Scene);
  39178. /**
  39179. * Gets a boolean indicating that current material needs to register RTT
  39180. */
  39181. readonly hasRenderTargetTextures: boolean;
  39182. /**
  39183. * Gets the current class name of the material e.g. "StandardMaterial"
  39184. * Mainly use in serialization.
  39185. * @returns the class name
  39186. */
  39187. getClassName(): string;
  39188. /**
  39189. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39190. * You can try switching to logarithmic depth.
  39191. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39192. */
  39193. useLogarithmicDepth: boolean;
  39194. /**
  39195. * Specifies if the material will require alpha blending
  39196. * @returns a boolean specifying if alpha blending is needed
  39197. */
  39198. needAlphaBlending(): boolean;
  39199. /**
  39200. * Specifies if this material should be rendered in alpha test mode
  39201. * @returns a boolean specifying if an alpha test is needed.
  39202. */
  39203. needAlphaTesting(): boolean;
  39204. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39205. /**
  39206. * Get the texture used for alpha test purpose.
  39207. * @returns the diffuse texture in case of the standard material.
  39208. */
  39209. getAlphaTestTexture(): Nullable<BaseTexture>;
  39210. /**
  39211. * Get if the submesh is ready to be used and all its information available.
  39212. * Child classes can use it to update shaders
  39213. * @param mesh defines the mesh to check
  39214. * @param subMesh defines which submesh to check
  39215. * @param useInstances specifies that instances should be used
  39216. * @returns a boolean indicating that the submesh is ready or not
  39217. */
  39218. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39219. /**
  39220. * Builds the material UBO layouts.
  39221. * Used internally during the effect preparation.
  39222. */
  39223. buildUniformLayout(): void;
  39224. /**
  39225. * Unbinds the material from the mesh
  39226. */
  39227. unbind(): void;
  39228. /**
  39229. * Binds the submesh to this material by preparing the effect and shader to draw
  39230. * @param world defines the world transformation matrix
  39231. * @param mesh defines the mesh containing the submesh
  39232. * @param subMesh defines the submesh to bind the material to
  39233. */
  39234. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39235. /**
  39236. * Get the list of animatables in the material.
  39237. * @returns the list of animatables object used in the material
  39238. */
  39239. getAnimatables(): IAnimatable[];
  39240. /**
  39241. * Gets the active textures from the material
  39242. * @returns an array of textures
  39243. */
  39244. getActiveTextures(): BaseTexture[];
  39245. /**
  39246. * Specifies if the material uses a texture
  39247. * @param texture defines the texture to check against the material
  39248. * @returns a boolean specifying if the material uses the texture
  39249. */
  39250. hasTexture(texture: BaseTexture): boolean;
  39251. /**
  39252. * Disposes the material
  39253. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39254. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39255. */
  39256. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39257. /**
  39258. * Makes a duplicate of the material, and gives it a new name
  39259. * @param name defines the new name for the duplicated material
  39260. * @returns the cloned material
  39261. */
  39262. clone(name: string): StandardMaterial;
  39263. /**
  39264. * Serializes this material in a JSON representation
  39265. * @returns the serialized material object
  39266. */
  39267. serialize(): any;
  39268. /**
  39269. * Creates a standard material from parsed material data
  39270. * @param source defines the JSON representation of the material
  39271. * @param scene defines the hosting scene
  39272. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39273. * @returns a new standard material
  39274. */
  39275. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39276. /**
  39277. * Are diffuse textures enabled in the application.
  39278. */
  39279. static DiffuseTextureEnabled: boolean;
  39280. /**
  39281. * Are ambient textures enabled in the application.
  39282. */
  39283. static AmbientTextureEnabled: boolean;
  39284. /**
  39285. * Are opacity textures enabled in the application.
  39286. */
  39287. static OpacityTextureEnabled: boolean;
  39288. /**
  39289. * Are reflection textures enabled in the application.
  39290. */
  39291. static ReflectionTextureEnabled: boolean;
  39292. /**
  39293. * Are emissive textures enabled in the application.
  39294. */
  39295. static EmissiveTextureEnabled: boolean;
  39296. /**
  39297. * Are specular textures enabled in the application.
  39298. */
  39299. static SpecularTextureEnabled: boolean;
  39300. /**
  39301. * Are bump textures enabled in the application.
  39302. */
  39303. static BumpTextureEnabled: boolean;
  39304. /**
  39305. * Are lightmap textures enabled in the application.
  39306. */
  39307. static LightmapTextureEnabled: boolean;
  39308. /**
  39309. * Are refraction textures enabled in the application.
  39310. */
  39311. static RefractionTextureEnabled: boolean;
  39312. /**
  39313. * Are color grading textures enabled in the application.
  39314. */
  39315. static ColorGradingTextureEnabled: boolean;
  39316. /**
  39317. * Are fresnels enabled in the application.
  39318. */
  39319. static FresnelEnabled: boolean;
  39320. }
  39321. }
  39322. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39323. import { Scene } from "babylonjs/scene";
  39324. import { Texture } from "babylonjs/Materials/Textures/texture";
  39325. /**
  39326. * A class extending Texture allowing drawing on a texture
  39327. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39328. */
  39329. export class DynamicTexture extends Texture {
  39330. private _generateMipMaps;
  39331. private _canvas;
  39332. private _context;
  39333. private _engine;
  39334. /**
  39335. * Creates a DynamicTexture
  39336. * @param name defines the name of the texture
  39337. * @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
  39338. * @param scene defines the scene where you want the texture
  39339. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39340. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39341. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39342. */
  39343. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39344. /**
  39345. * Get the current class name of the texture useful for serialization or dynamic coding.
  39346. * @returns "DynamicTexture"
  39347. */
  39348. getClassName(): string;
  39349. /**
  39350. * Gets the current state of canRescale
  39351. */
  39352. readonly canRescale: boolean;
  39353. private _recreate;
  39354. /**
  39355. * Scales the texture
  39356. * @param ratio the scale factor to apply to both width and height
  39357. */
  39358. scale(ratio: number): void;
  39359. /**
  39360. * Resizes the texture
  39361. * @param width the new width
  39362. * @param height the new height
  39363. */
  39364. scaleTo(width: number, height: number): void;
  39365. /**
  39366. * Gets the context of the canvas used by the texture
  39367. * @returns the canvas context of the dynamic texture
  39368. */
  39369. getContext(): CanvasRenderingContext2D;
  39370. /**
  39371. * Clears the texture
  39372. */
  39373. clear(): void;
  39374. /**
  39375. * Updates the texture
  39376. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39377. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39378. */
  39379. update(invertY?: boolean, premulAlpha?: boolean): void;
  39380. /**
  39381. * Draws text onto the texture
  39382. * @param text defines the text to be drawn
  39383. * @param x defines the placement of the text from the left
  39384. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39385. * @param font defines the font to be used with font-style, font-size, font-name
  39386. * @param color defines the color used for the text
  39387. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39388. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39389. * @param update defines whether texture is immediately update (default is true)
  39390. */
  39391. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39392. /**
  39393. * Clones the texture
  39394. * @returns the clone of the texture.
  39395. */
  39396. clone(): DynamicTexture;
  39397. /**
  39398. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39399. * @returns a serialized dynamic texture object
  39400. */
  39401. serialize(): any;
  39402. /** @hidden */
  39403. _rebuild(): void;
  39404. }
  39405. }
  39406. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39407. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39408. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39409. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39410. /** @hidden */
  39411. export var imageProcessingPixelShader: {
  39412. name: string;
  39413. shader: string;
  39414. };
  39415. }
  39416. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39417. import { Nullable } from "babylonjs/types";
  39418. import { Color4 } from "babylonjs/Maths/math";
  39419. import { Camera } from "babylonjs/Cameras/camera";
  39420. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39421. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39422. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39423. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39424. import { Engine } from "babylonjs/Engines/engine";
  39425. import "babylonjs/Shaders/imageProcessing.fragment";
  39426. import "babylonjs/Shaders/postprocess.vertex";
  39427. /**
  39428. * ImageProcessingPostProcess
  39429. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39430. */
  39431. export class ImageProcessingPostProcess extends PostProcess {
  39432. /**
  39433. * Default configuration related to image processing available in the PBR Material.
  39434. */
  39435. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39436. /**
  39437. * Gets the image processing configuration used either in this material.
  39438. */
  39439. /**
  39440. * Sets the Default image processing configuration used either in the this material.
  39441. *
  39442. * If sets to null, the scene one is in use.
  39443. */
  39444. imageProcessingConfiguration: ImageProcessingConfiguration;
  39445. /**
  39446. * Keep track of the image processing observer to allow dispose and replace.
  39447. */
  39448. private _imageProcessingObserver;
  39449. /**
  39450. * Attaches a new image processing configuration to the PBR Material.
  39451. * @param configuration
  39452. */
  39453. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39454. /**
  39455. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39456. */
  39457. /**
  39458. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39459. */
  39460. colorCurves: Nullable<ColorCurves>;
  39461. /**
  39462. * Gets wether the color curves effect is enabled.
  39463. */
  39464. /**
  39465. * Sets wether the color curves effect is enabled.
  39466. */
  39467. colorCurvesEnabled: boolean;
  39468. /**
  39469. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39470. */
  39471. /**
  39472. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39473. */
  39474. colorGradingTexture: Nullable<BaseTexture>;
  39475. /**
  39476. * Gets wether the color grading effect is enabled.
  39477. */
  39478. /**
  39479. * Gets wether the color grading effect is enabled.
  39480. */
  39481. colorGradingEnabled: boolean;
  39482. /**
  39483. * Gets exposure used in the effect.
  39484. */
  39485. /**
  39486. * Sets exposure used in the effect.
  39487. */
  39488. exposure: number;
  39489. /**
  39490. * Gets wether tonemapping is enabled or not.
  39491. */
  39492. /**
  39493. * Sets wether tonemapping is enabled or not
  39494. */
  39495. toneMappingEnabled: boolean;
  39496. /**
  39497. * Gets the type of tone mapping effect.
  39498. */
  39499. /**
  39500. * Sets the type of tone mapping effect.
  39501. */
  39502. toneMappingType: number;
  39503. /**
  39504. * Gets contrast used in the effect.
  39505. */
  39506. /**
  39507. * Sets contrast used in the effect.
  39508. */
  39509. contrast: number;
  39510. /**
  39511. * Gets Vignette stretch size.
  39512. */
  39513. /**
  39514. * Sets Vignette stretch size.
  39515. */
  39516. vignetteStretch: number;
  39517. /**
  39518. * Gets Vignette centre X Offset.
  39519. */
  39520. /**
  39521. * Sets Vignette centre X Offset.
  39522. */
  39523. vignetteCentreX: number;
  39524. /**
  39525. * Gets Vignette centre Y Offset.
  39526. */
  39527. /**
  39528. * Sets Vignette centre Y Offset.
  39529. */
  39530. vignetteCentreY: number;
  39531. /**
  39532. * Gets Vignette weight or intensity of the vignette effect.
  39533. */
  39534. /**
  39535. * Sets Vignette weight or intensity of the vignette effect.
  39536. */
  39537. vignetteWeight: number;
  39538. /**
  39539. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39540. * if vignetteEnabled is set to true.
  39541. */
  39542. /**
  39543. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39544. * if vignetteEnabled is set to true.
  39545. */
  39546. vignetteColor: Color4;
  39547. /**
  39548. * Gets Camera field of view used by the Vignette effect.
  39549. */
  39550. /**
  39551. * Sets Camera field of view used by the Vignette effect.
  39552. */
  39553. vignetteCameraFov: number;
  39554. /**
  39555. * Gets the vignette blend mode allowing different kind of effect.
  39556. */
  39557. /**
  39558. * Sets the vignette blend mode allowing different kind of effect.
  39559. */
  39560. vignetteBlendMode: number;
  39561. /**
  39562. * Gets wether the vignette effect is enabled.
  39563. */
  39564. /**
  39565. * Sets wether the vignette effect is enabled.
  39566. */
  39567. vignetteEnabled: boolean;
  39568. private _fromLinearSpace;
  39569. /**
  39570. * Gets wether the input of the processing is in Gamma or Linear Space.
  39571. */
  39572. /**
  39573. * Sets wether the input of the processing is in Gamma or Linear Space.
  39574. */
  39575. fromLinearSpace: boolean;
  39576. /**
  39577. * Defines cache preventing GC.
  39578. */
  39579. private _defines;
  39580. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39581. /**
  39582. * "ImageProcessingPostProcess"
  39583. * @returns "ImageProcessingPostProcess"
  39584. */
  39585. getClassName(): string;
  39586. protected _updateParameters(): void;
  39587. dispose(camera?: Camera): void;
  39588. }
  39589. }
  39590. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39591. import { Scene } from "babylonjs/scene";
  39592. import { Color3 } from "babylonjs/Maths/math";
  39593. import { Mesh } from "babylonjs/Meshes/mesh";
  39594. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39595. /**
  39596. * Class containing static functions to help procedurally build meshes
  39597. */
  39598. export class GroundBuilder {
  39599. /**
  39600. * Creates a ground mesh
  39601. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39602. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39604. * @param name defines the name of the mesh
  39605. * @param options defines the options used to create the mesh
  39606. * @param scene defines the hosting scene
  39607. * @returns the ground mesh
  39608. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39609. */
  39610. static CreateGround(name: string, options: {
  39611. width?: number;
  39612. height?: number;
  39613. subdivisions?: number;
  39614. subdivisionsX?: number;
  39615. subdivisionsY?: number;
  39616. updatable?: boolean;
  39617. }, scene: any): Mesh;
  39618. /**
  39619. * Creates a tiled ground mesh
  39620. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39621. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39622. * * 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
  39623. * * 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
  39624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39625. * @param name defines the name of the mesh
  39626. * @param options defines the options used to create the mesh
  39627. * @param scene defines the hosting scene
  39628. * @returns the tiled ground mesh
  39629. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39630. */
  39631. static CreateTiledGround(name: string, options: {
  39632. xmin: number;
  39633. zmin: number;
  39634. xmax: number;
  39635. zmax: number;
  39636. subdivisions?: {
  39637. w: number;
  39638. h: number;
  39639. };
  39640. precision?: {
  39641. w: number;
  39642. h: number;
  39643. };
  39644. updatable?: boolean;
  39645. }, scene: Scene): Mesh;
  39646. /**
  39647. * Creates a ground mesh from a height map
  39648. * * The parameter `url` sets the URL of the height map image resource.
  39649. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39650. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39651. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39652. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39653. * * 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.
  39654. * * 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).
  39655. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39657. * @param name defines the name of the mesh
  39658. * @param url defines the url to the height map
  39659. * @param options defines the options used to create the mesh
  39660. * @param scene defines the hosting scene
  39661. * @returns the ground mesh
  39662. * @see https://doc.babylonjs.com/babylon101/height_map
  39663. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39664. */
  39665. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39666. width?: number;
  39667. height?: number;
  39668. subdivisions?: number;
  39669. minHeight?: number;
  39670. maxHeight?: number;
  39671. colorFilter?: Color3;
  39672. alphaFilter?: number;
  39673. updatable?: boolean;
  39674. onReady?: (mesh: GroundMesh) => void;
  39675. }, scene: Scene): GroundMesh;
  39676. }
  39677. }
  39678. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39679. import { Vector4 } from "babylonjs/Maths/math";
  39680. import { Mesh } from "babylonjs/Meshes/mesh";
  39681. /**
  39682. * Class containing static functions to help procedurally build meshes
  39683. */
  39684. export class TorusBuilder {
  39685. /**
  39686. * Creates a torus mesh
  39687. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39688. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39689. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39691. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39693. * @param name defines the name of the mesh
  39694. * @param options defines the options used to create the mesh
  39695. * @param scene defines the hosting scene
  39696. * @returns the torus mesh
  39697. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39698. */
  39699. static CreateTorus(name: string, options: {
  39700. diameter?: number;
  39701. thickness?: number;
  39702. tessellation?: number;
  39703. updatable?: boolean;
  39704. sideOrientation?: number;
  39705. frontUVs?: Vector4;
  39706. backUVs?: Vector4;
  39707. }, scene: any): Mesh;
  39708. }
  39709. }
  39710. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39711. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39712. import { Mesh } from "babylonjs/Meshes/mesh";
  39713. /**
  39714. * Class containing static functions to help procedurally build meshes
  39715. */
  39716. export class CylinderBuilder {
  39717. /**
  39718. * Creates a cylinder or a cone mesh
  39719. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39720. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39721. * * 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.
  39722. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39723. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39724. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39725. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39726. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39727. * * 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).
  39728. * * 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
  39729. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39730. * * 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
  39731. * * 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.
  39732. * * If `enclose` is false, a ring surface is one element.
  39733. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39734. * * 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
  39735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39738. * @param name defines the name of the mesh
  39739. * @param options defines the options used to create the mesh
  39740. * @param scene defines the hosting scene
  39741. * @returns the cylinder mesh
  39742. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39743. */
  39744. static CreateCylinder(name: string, options: {
  39745. height?: number;
  39746. diameterTop?: number;
  39747. diameterBottom?: number;
  39748. diameter?: number;
  39749. tessellation?: number;
  39750. subdivisions?: number;
  39751. arc?: number;
  39752. faceColors?: Color4[];
  39753. faceUV?: Vector4[];
  39754. updatable?: boolean;
  39755. hasRings?: boolean;
  39756. enclose?: boolean;
  39757. sideOrientation?: number;
  39758. frontUVs?: Vector4;
  39759. backUVs?: Vector4;
  39760. }, scene: any): Mesh;
  39761. }
  39762. }
  39763. declare module "babylonjs/Gamepads/gamepadManager" {
  39764. import { Observable } from "babylonjs/Misc/observable";
  39765. import { Nullable } from "babylonjs/types";
  39766. import { Scene } from "babylonjs/scene";
  39767. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39768. /**
  39769. * Manager for handling gamepads
  39770. */
  39771. export class GamepadManager {
  39772. private _scene?;
  39773. private _babylonGamepads;
  39774. private _oneGamepadConnected;
  39775. /** @hidden */
  39776. _isMonitoring: boolean;
  39777. private _gamepadEventSupported;
  39778. private _gamepadSupport;
  39779. /**
  39780. * observable to be triggered when the gamepad controller has been connected
  39781. */
  39782. onGamepadConnectedObservable: Observable<Gamepad>;
  39783. /**
  39784. * observable to be triggered when the gamepad controller has been disconnected
  39785. */
  39786. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39787. private _onGamepadConnectedEvent;
  39788. private _onGamepadDisconnectedEvent;
  39789. /**
  39790. * Initializes the gamepad manager
  39791. * @param _scene BabylonJS scene
  39792. */
  39793. constructor(_scene?: Scene | undefined);
  39794. /**
  39795. * The gamepads in the game pad manager
  39796. */
  39797. readonly gamepads: Gamepad[];
  39798. /**
  39799. * Get the gamepad controllers based on type
  39800. * @param type The type of gamepad controller
  39801. * @returns Nullable gamepad
  39802. */
  39803. getGamepadByType(type?: number): Nullable<Gamepad>;
  39804. /**
  39805. * Disposes the gamepad manager
  39806. */
  39807. dispose(): void;
  39808. private _addNewGamepad;
  39809. private _startMonitoringGamepads;
  39810. private _stopMonitoringGamepads;
  39811. /** @hidden */
  39812. _checkGamepadsStatus(): void;
  39813. private _updateGamepadObjects;
  39814. }
  39815. }
  39816. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39817. import { Nullable } from "babylonjs/types";
  39818. import { Scene } from "babylonjs/scene";
  39819. import { ISceneComponent } from "babylonjs/sceneComponent";
  39820. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39821. module "babylonjs/scene" {
  39822. interface Scene {
  39823. /** @hidden */
  39824. _gamepadManager: Nullable<GamepadManager>;
  39825. /**
  39826. * Gets the gamepad manager associated with the scene
  39827. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39828. */
  39829. gamepadManager: GamepadManager;
  39830. }
  39831. }
  39832. module "babylonjs/Cameras/freeCameraInputsManager" {
  39833. /**
  39834. * Interface representing a free camera inputs manager
  39835. */
  39836. interface FreeCameraInputsManager {
  39837. /**
  39838. * Adds gamepad input support to the FreeCameraInputsManager.
  39839. * @returns the FreeCameraInputsManager
  39840. */
  39841. addGamepad(): FreeCameraInputsManager;
  39842. }
  39843. }
  39844. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39845. /**
  39846. * Interface representing an arc rotate camera inputs manager
  39847. */
  39848. interface ArcRotateCameraInputsManager {
  39849. /**
  39850. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39851. * @returns the camera inputs manager
  39852. */
  39853. addGamepad(): ArcRotateCameraInputsManager;
  39854. }
  39855. }
  39856. /**
  39857. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39858. */
  39859. export class GamepadSystemSceneComponent implements ISceneComponent {
  39860. /**
  39861. * The component name helpfull to identify the component in the list of scene components.
  39862. */
  39863. readonly name: string;
  39864. /**
  39865. * The scene the component belongs to.
  39866. */
  39867. scene: Scene;
  39868. /**
  39869. * Creates a new instance of the component for the given scene
  39870. * @param scene Defines the scene to register the component in
  39871. */
  39872. constructor(scene: Scene);
  39873. /**
  39874. * Registers the component in a given scene
  39875. */
  39876. register(): void;
  39877. /**
  39878. * Rebuilds the elements related to this component in case of
  39879. * context lost for instance.
  39880. */
  39881. rebuild(): void;
  39882. /**
  39883. * Disposes the component and the associated ressources
  39884. */
  39885. dispose(): void;
  39886. private _beforeCameraUpdate;
  39887. }
  39888. }
  39889. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39890. import { Observable } from "babylonjs/Misc/observable";
  39891. import { Nullable } from "babylonjs/types";
  39892. import { Camera } from "babylonjs/Cameras/camera";
  39893. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39894. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39895. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39896. import { Scene } from "babylonjs/scene";
  39897. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39898. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39900. import { Mesh } from "babylonjs/Meshes/mesh";
  39901. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39902. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39903. import "babylonjs/Meshes/Builders/groundBuilder";
  39904. import "babylonjs/Meshes/Builders/torusBuilder";
  39905. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39906. import "babylonjs/Gamepads/gamepadSceneComponent";
  39907. import "babylonjs/Animations/animatable";
  39908. /**
  39909. * Options to modify the vr teleportation behavior.
  39910. */
  39911. export interface VRTeleportationOptions {
  39912. /**
  39913. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39914. */
  39915. floorMeshName?: string;
  39916. /**
  39917. * A list of meshes to be used as the teleportation floor. (default: empty)
  39918. */
  39919. floorMeshes?: Mesh[];
  39920. }
  39921. /**
  39922. * Options to modify the vr experience helper's behavior.
  39923. */
  39924. export interface VRExperienceHelperOptions extends WebVROptions {
  39925. /**
  39926. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39927. */
  39928. createDeviceOrientationCamera?: boolean;
  39929. /**
  39930. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39931. */
  39932. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39933. /**
  39934. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39935. */
  39936. laserToggle?: boolean;
  39937. /**
  39938. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39939. */
  39940. floorMeshes?: Mesh[];
  39941. /**
  39942. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39943. */
  39944. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39945. }
  39946. /**
  39947. * Event containing information after VR has been entered
  39948. */
  39949. export class OnAfterEnteringVRObservableEvent {
  39950. /**
  39951. * If entering vr was successful
  39952. */
  39953. success: boolean;
  39954. }
  39955. /**
  39956. * Helps to quickly add VR support to an existing scene.
  39957. * See http://doc.babylonjs.com/how_to/webvr_helper
  39958. */
  39959. export class VRExperienceHelper {
  39960. /** Options to modify the vr experience helper's behavior. */
  39961. webVROptions: VRExperienceHelperOptions;
  39962. private _scene;
  39963. private _position;
  39964. private _btnVR;
  39965. private _btnVRDisplayed;
  39966. private _webVRsupported;
  39967. private _webVRready;
  39968. private _webVRrequesting;
  39969. private _webVRpresenting;
  39970. private _hasEnteredVR;
  39971. private _fullscreenVRpresenting;
  39972. private _canvas;
  39973. private _webVRCamera;
  39974. private _vrDeviceOrientationCamera;
  39975. private _deviceOrientationCamera;
  39976. private _existingCamera;
  39977. private _onKeyDown;
  39978. private _onVrDisplayPresentChange;
  39979. private _onVRDisplayChanged;
  39980. private _onVRRequestPresentStart;
  39981. private _onVRRequestPresentComplete;
  39982. /**
  39983. * Observable raised right before entering VR.
  39984. */
  39985. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39986. /**
  39987. * Observable raised when entering VR has completed.
  39988. */
  39989. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39990. /**
  39991. * Observable raised when exiting VR.
  39992. */
  39993. onExitingVRObservable: Observable<VRExperienceHelper>;
  39994. /**
  39995. * Observable raised when controller mesh is loaded.
  39996. */
  39997. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39998. /** Return this.onEnteringVRObservable
  39999. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40000. */
  40001. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40002. /** Return this.onExitingVRObservable
  40003. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40004. */
  40005. readonly onExitingVR: Observable<VRExperienceHelper>;
  40006. /** Return this.onControllerMeshLoadedObservable
  40007. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40008. */
  40009. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40010. private _rayLength;
  40011. private _useCustomVRButton;
  40012. private _teleportationRequested;
  40013. private _teleportActive;
  40014. private _floorMeshName;
  40015. private _floorMeshesCollection;
  40016. private _rotationAllowed;
  40017. private _teleportBackwardsVector;
  40018. private _teleportationTarget;
  40019. private _isDefaultTeleportationTarget;
  40020. private _postProcessMove;
  40021. private _teleportationFillColor;
  40022. private _teleportationBorderColor;
  40023. private _rotationAngle;
  40024. private _haloCenter;
  40025. private _cameraGazer;
  40026. private _padSensibilityUp;
  40027. private _padSensibilityDown;
  40028. private _leftController;
  40029. private _rightController;
  40030. /**
  40031. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40032. */
  40033. onNewMeshSelected: Observable<AbstractMesh>;
  40034. /**
  40035. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40036. */
  40037. onNewMeshPicked: Observable<PickingInfo>;
  40038. private _circleEase;
  40039. /**
  40040. * Observable raised before camera teleportation
  40041. */
  40042. onBeforeCameraTeleport: Observable<Vector3>;
  40043. /**
  40044. * Observable raised after camera teleportation
  40045. */
  40046. onAfterCameraTeleport: Observable<Vector3>;
  40047. /**
  40048. * Observable raised when current selected mesh gets unselected
  40049. */
  40050. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40051. private _raySelectionPredicate;
  40052. /**
  40053. * To be optionaly changed by user to define custom ray selection
  40054. */
  40055. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40056. /**
  40057. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40058. */
  40059. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40060. /**
  40061. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40062. */
  40063. teleportationEnabled: boolean;
  40064. private _defaultHeight;
  40065. private _teleportationInitialized;
  40066. private _interactionsEnabled;
  40067. private _interactionsRequested;
  40068. private _displayGaze;
  40069. private _displayLaserPointer;
  40070. /**
  40071. * The mesh used to display where the user is going to teleport.
  40072. */
  40073. /**
  40074. * Sets the mesh to be used to display where the user is going to teleport.
  40075. */
  40076. teleportationTarget: Mesh;
  40077. /**
  40078. * 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
  40079. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40080. * See http://doc.babylonjs.com/resources/baking_transformations
  40081. */
  40082. gazeTrackerMesh: Mesh;
  40083. /**
  40084. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40085. */
  40086. updateGazeTrackerScale: boolean;
  40087. /**
  40088. * If the gaze trackers color should be updated when selecting meshes
  40089. */
  40090. updateGazeTrackerColor: boolean;
  40091. /**
  40092. * The gaze tracking mesh corresponding to the left controller
  40093. */
  40094. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40095. /**
  40096. * The gaze tracking mesh corresponding to the right controller
  40097. */
  40098. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40099. /**
  40100. * If the ray of the gaze should be displayed.
  40101. */
  40102. /**
  40103. * Sets if the ray of the gaze should be displayed.
  40104. */
  40105. displayGaze: boolean;
  40106. /**
  40107. * If the ray of the LaserPointer should be displayed.
  40108. */
  40109. /**
  40110. * Sets if the ray of the LaserPointer should be displayed.
  40111. */
  40112. displayLaserPointer: boolean;
  40113. /**
  40114. * The deviceOrientationCamera used as the camera when not in VR.
  40115. */
  40116. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40117. /**
  40118. * Based on the current WebVR support, returns the current VR camera used.
  40119. */
  40120. readonly currentVRCamera: Nullable<Camera>;
  40121. /**
  40122. * The webVRCamera which is used when in VR.
  40123. */
  40124. readonly webVRCamera: WebVRFreeCamera;
  40125. /**
  40126. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40127. */
  40128. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40129. private readonly _teleportationRequestInitiated;
  40130. /**
  40131. * Defines wether or not Pointer lock should be requested when switching to
  40132. * full screen.
  40133. */
  40134. requestPointerLockOnFullScreen: boolean;
  40135. /**
  40136. * Instantiates a VRExperienceHelper.
  40137. * Helps to quickly add VR support to an existing scene.
  40138. * @param scene The scene the VRExperienceHelper belongs to.
  40139. * @param webVROptions Options to modify the vr experience helper's behavior.
  40140. */
  40141. constructor(scene: Scene,
  40142. /** Options to modify the vr experience helper's behavior. */
  40143. webVROptions?: VRExperienceHelperOptions);
  40144. private _onDefaultMeshLoaded;
  40145. private _onResize;
  40146. private _onFullscreenChange;
  40147. /**
  40148. * Gets a value indicating if we are currently in VR mode.
  40149. */
  40150. readonly isInVRMode: boolean;
  40151. private onVrDisplayPresentChange;
  40152. private onVRDisplayChanged;
  40153. private moveButtonToBottomRight;
  40154. private displayVRButton;
  40155. private updateButtonVisibility;
  40156. private _cachedAngularSensibility;
  40157. /**
  40158. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40159. * Otherwise, will use the fullscreen API.
  40160. */
  40161. enterVR(): void;
  40162. /**
  40163. * Attempt to exit VR, or fullscreen.
  40164. */
  40165. exitVR(): void;
  40166. /**
  40167. * The position of the vr experience helper.
  40168. */
  40169. /**
  40170. * Sets the position of the vr experience helper.
  40171. */
  40172. position: Vector3;
  40173. /**
  40174. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40175. */
  40176. enableInteractions(): void;
  40177. private readonly _noControllerIsActive;
  40178. private beforeRender;
  40179. private _isTeleportationFloor;
  40180. /**
  40181. * Adds a floor mesh to be used for teleportation.
  40182. * @param floorMesh the mesh to be used for teleportation.
  40183. */
  40184. addFloorMesh(floorMesh: Mesh): void;
  40185. /**
  40186. * Removes a floor mesh from being used for teleportation.
  40187. * @param floorMesh the mesh to be removed.
  40188. */
  40189. removeFloorMesh(floorMesh: Mesh): void;
  40190. /**
  40191. * Enables interactions and teleportation using the VR controllers and gaze.
  40192. * @param vrTeleportationOptions options to modify teleportation behavior.
  40193. */
  40194. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40195. private _onNewGamepadConnected;
  40196. private _tryEnableInteractionOnController;
  40197. private _onNewGamepadDisconnected;
  40198. private _enableInteractionOnController;
  40199. private _checkTeleportWithRay;
  40200. private _checkRotate;
  40201. private _checkTeleportBackwards;
  40202. private _enableTeleportationOnController;
  40203. private _createTeleportationCircles;
  40204. private _displayTeleportationTarget;
  40205. private _hideTeleportationTarget;
  40206. private _rotateCamera;
  40207. private _moveTeleportationSelectorTo;
  40208. private _workingVector;
  40209. private _workingQuaternion;
  40210. private _workingMatrix;
  40211. /**
  40212. * Teleports the users feet to the desired location
  40213. * @param location The location where the user's feet should be placed
  40214. */
  40215. teleportCamera(location: Vector3): void;
  40216. private _convertNormalToDirectionOfRay;
  40217. private _castRayAndSelectObject;
  40218. private _notifySelectedMeshUnselected;
  40219. /**
  40220. * Sets the color of the laser ray from the vr controllers.
  40221. * @param color new color for the ray.
  40222. */
  40223. changeLaserColor(color: Color3): void;
  40224. /**
  40225. * Sets the color of the ray from the vr headsets gaze.
  40226. * @param color new color for the ray.
  40227. */
  40228. changeGazeColor(color: Color3): void;
  40229. /**
  40230. * Exits VR and disposes of the vr experience helper
  40231. */
  40232. dispose(): void;
  40233. /**
  40234. * Gets the name of the VRExperienceHelper class
  40235. * @returns "VRExperienceHelper"
  40236. */
  40237. getClassName(): string;
  40238. }
  40239. }
  40240. declare module "babylonjs/Cameras/VR/index" {
  40241. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40242. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40243. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40244. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40245. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40246. export * from "babylonjs/Cameras/VR/webVRCamera";
  40247. }
  40248. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40249. import { Observable } from "babylonjs/Misc/observable";
  40250. import { Nullable } from "babylonjs/types";
  40251. import { IDisposable, Scene } from "babylonjs/scene";
  40252. import { Vector3 } from "babylonjs/Maths/math";
  40253. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40254. import { Ray } from "babylonjs/Culling/ray";
  40255. /**
  40256. * Manages an XRSession
  40257. * @see https://doc.babylonjs.com/how_to/webxr
  40258. */
  40259. export class WebXRSessionManager implements IDisposable {
  40260. private scene;
  40261. /**
  40262. * Fires every time a new xrFrame arrives which can be used to update the camera
  40263. */
  40264. onXRFrameObservable: Observable<any>;
  40265. /**
  40266. * Fires when the xr session is ended either by the device or manually done
  40267. */
  40268. onXRSessionEnded: Observable<any>;
  40269. /** @hidden */
  40270. _xrSession: XRSession;
  40271. /** @hidden */
  40272. _frameOfReference: XRFrameOfReference;
  40273. /** @hidden */
  40274. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40275. /** @hidden */
  40276. _currentXRFrame: Nullable<XRFrame>;
  40277. private _xrNavigator;
  40278. private _xrDevice;
  40279. private _tmpMatrix;
  40280. /**
  40281. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40282. * @param scene The scene which the session should be created for
  40283. */
  40284. constructor(scene: Scene);
  40285. /**
  40286. * Initializes the manager
  40287. * After initialization enterXR can be called to start an XR session
  40288. * @returns Promise which resolves after it is initialized
  40289. */
  40290. initializeAsync(): Promise<void>;
  40291. /**
  40292. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40293. * @param sessionCreationOptions xr options to create the session with
  40294. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40295. * @returns Promise which resolves after it enters XR
  40296. */
  40297. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40298. /**
  40299. * Stops the xrSession and restores the renderloop
  40300. * @returns Promise which resolves after it exits XR
  40301. */
  40302. exitXRAsync(): Promise<void>;
  40303. /**
  40304. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40305. * @param ray ray to cast into the environment
  40306. * @returns Promise which resolves with a collision point in the environment if it exists
  40307. */
  40308. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40309. /**
  40310. * Checks if a session would be supported for the creation options specified
  40311. * @param options creation options to check if they are supported
  40312. * @returns true if supported
  40313. */
  40314. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40315. /**
  40316. * @hidden
  40317. * Converts the render layer of xrSession to a render target
  40318. * @param session session to create render target for
  40319. * @param scene scene the new render target should be created for
  40320. */
  40321. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40322. /**
  40323. * Disposes of the session manager
  40324. */
  40325. dispose(): void;
  40326. }
  40327. }
  40328. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40329. import { Scene } from "babylonjs/scene";
  40330. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40331. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40332. /**
  40333. * WebXR Camera which holds the views for the xrSession
  40334. * @see https://doc.babylonjs.com/how_to/webxr
  40335. */
  40336. export class WebXRCamera extends FreeCamera {
  40337. private static _TmpMatrix;
  40338. /**
  40339. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40340. * @param name the name of the camera
  40341. * @param scene the scene to add the camera to
  40342. */
  40343. constructor(name: string, scene: Scene);
  40344. private _updateNumberOfRigCameras;
  40345. /** @hidden */
  40346. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40347. /**
  40348. * Updates the cameras position from the current pose information of the XR session
  40349. * @param xrSessionManager the session containing pose information
  40350. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40351. */
  40352. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40353. }
  40354. }
  40355. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40356. import { Nullable } from "babylonjs/types";
  40357. import { Observable } from "babylonjs/Misc/observable";
  40358. import { IDisposable, Scene } from "babylonjs/scene";
  40359. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40361. import { Ray } from "babylonjs/Culling/ray";
  40362. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40363. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40364. /**
  40365. * States of the webXR experience
  40366. */
  40367. export enum WebXRState {
  40368. /**
  40369. * Transitioning to being in XR mode
  40370. */
  40371. ENTERING_XR = 0,
  40372. /**
  40373. * Transitioning to non XR mode
  40374. */
  40375. EXITING_XR = 1,
  40376. /**
  40377. * In XR mode and presenting
  40378. */
  40379. IN_XR = 2,
  40380. /**
  40381. * Not entered XR mode
  40382. */
  40383. NOT_IN_XR = 3
  40384. }
  40385. /**
  40386. * Helper class used to enable XR
  40387. * @see https://doc.babylonjs.com/how_to/webxr
  40388. */
  40389. export class WebXRExperienceHelper implements IDisposable {
  40390. private scene;
  40391. /**
  40392. * 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
  40393. */
  40394. container: AbstractMesh;
  40395. /**
  40396. * Camera used to render xr content
  40397. */
  40398. camera: WebXRCamera;
  40399. /**
  40400. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40401. */
  40402. state: WebXRState;
  40403. private _setState;
  40404. private static _TmpVector;
  40405. /**
  40406. * Fires when the state of the experience helper has changed
  40407. */
  40408. onStateChangedObservable: Observable<WebXRState>;
  40409. /** @hidden */
  40410. _sessionManager: WebXRSessionManager;
  40411. private _nonVRCamera;
  40412. private _originalSceneAutoClear;
  40413. private _supported;
  40414. /**
  40415. * Creates the experience helper
  40416. * @param scene the scene to attach the experience helper to
  40417. * @returns a promise for the experience helper
  40418. */
  40419. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40420. /**
  40421. * Creates a WebXRExperienceHelper
  40422. * @param scene The scene the helper should be created in
  40423. */
  40424. private constructor();
  40425. /**
  40426. * Exits XR mode and returns the scene to its original state
  40427. * @returns promise that resolves after xr mode has exited
  40428. */
  40429. exitXRAsync(): Promise<void>;
  40430. /**
  40431. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40432. * @param sessionCreationOptions options for the XR session
  40433. * @param frameOfReference frame of reference of the XR session
  40434. * @returns promise that resolves after xr mode has entered
  40435. */
  40436. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40437. /**
  40438. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40439. * @param ray ray to cast into the environment
  40440. * @returns Promise which resolves with a collision point in the environment if it exists
  40441. */
  40442. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40443. /**
  40444. * Updates the global position of the camera by moving the camera's container
  40445. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40446. * @param position The desired global position of the camera
  40447. */
  40448. setPositionOfCameraUsingContainer(position: Vector3): void;
  40449. /**
  40450. * Rotates the xr camera by rotating the camera's container around the camera's position
  40451. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40452. * @param rotation the desired quaternion rotation to apply to the camera
  40453. */
  40454. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40455. /**
  40456. * Checks if the creation options are supported by the xr session
  40457. * @param options creation options
  40458. * @returns true if supported
  40459. */
  40460. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40461. /**
  40462. * Disposes of the experience helper
  40463. */
  40464. dispose(): void;
  40465. }
  40466. }
  40467. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40468. import { Nullable } from "babylonjs/types";
  40469. import { Observable } from "babylonjs/Misc/observable";
  40470. import { IDisposable, Scene } from "babylonjs/scene";
  40471. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40472. /**
  40473. * Button which can be used to enter a different mode of XR
  40474. */
  40475. export class WebXREnterExitUIButton {
  40476. /** button element */
  40477. element: HTMLElement;
  40478. /** XR initialization options for the button */
  40479. initializationOptions: XRSessionCreationOptions;
  40480. /**
  40481. * Creates a WebXREnterExitUIButton
  40482. * @param element button element
  40483. * @param initializationOptions XR initialization options for the button
  40484. */
  40485. constructor(
  40486. /** button element */
  40487. element: HTMLElement,
  40488. /** XR initialization options for the button */
  40489. initializationOptions: XRSessionCreationOptions);
  40490. /**
  40491. * Overwritable function which can be used to update the button's visuals when the state changes
  40492. * @param activeButton the current active button in the UI
  40493. */
  40494. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40495. }
  40496. /**
  40497. * Options to create the webXR UI
  40498. */
  40499. export class WebXREnterExitUIOptions {
  40500. /**
  40501. * Context to enter xr with
  40502. */
  40503. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40504. /**
  40505. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40506. */
  40507. customButtons?: Array<WebXREnterExitUIButton>;
  40508. }
  40509. /**
  40510. * UI to allow the user to enter/exit XR mode
  40511. */
  40512. export class WebXREnterExitUI implements IDisposable {
  40513. private scene;
  40514. private _overlay;
  40515. private _buttons;
  40516. private _activeButton;
  40517. /**
  40518. * Fired every time the active button is changed.
  40519. *
  40520. * When xr is entered via a button that launches xr that button will be the callback parameter
  40521. *
  40522. * When exiting xr the callback parameter will be null)
  40523. */
  40524. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40525. /**
  40526. * Creates UI to allow the user to enter/exit XR mode
  40527. * @param scene the scene to add the ui to
  40528. * @param helper the xr experience helper to enter/exit xr with
  40529. * @param options options to configure the UI
  40530. * @returns the created ui
  40531. */
  40532. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40533. private constructor();
  40534. private _updateButtons;
  40535. /**
  40536. * Disposes of the object
  40537. */
  40538. dispose(): void;
  40539. }
  40540. }
  40541. declare module "babylonjs/Cameras/XR/webXRInput" {
  40542. import { IDisposable, Scene } from "babylonjs/scene";
  40543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40544. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40545. /**
  40546. * Represents an XR input
  40547. */
  40548. export class WebXRController {
  40549. /**
  40550. * 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
  40551. */
  40552. grip?: AbstractMesh;
  40553. /**
  40554. * Pointer which can be used to select objects or attach a visible laser to
  40555. */
  40556. pointer: AbstractMesh;
  40557. /**
  40558. * Creates the controller
  40559. * @see https://doc.babylonjs.com/how_to/webxr
  40560. * @param scene the scene which the controller should be associated to
  40561. */
  40562. constructor(scene: Scene);
  40563. /**
  40564. * Disposes of the object
  40565. */
  40566. dispose(): void;
  40567. }
  40568. /**
  40569. * XR input used to track XR inputs such as controllers/rays
  40570. */
  40571. export class WebXRInput implements IDisposable {
  40572. private helper;
  40573. /**
  40574. * XR controllers being tracked
  40575. */
  40576. controllers: Array<WebXRController>;
  40577. private _tmpMatrix;
  40578. private _frameObserver;
  40579. /**
  40580. * Initializes the WebXRInput
  40581. * @param helper experience helper which the input should be created for
  40582. */
  40583. constructor(helper: WebXRExperienceHelper);
  40584. /**
  40585. * Disposes of the object
  40586. */
  40587. dispose(): void;
  40588. }
  40589. }
  40590. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40591. import { Nullable } from "babylonjs/types";
  40592. import { IDisposable } from "babylonjs/scene";
  40593. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40594. /**
  40595. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40596. */
  40597. export class WebXRManagedOutputCanvas implements IDisposable {
  40598. private _canvas;
  40599. /**
  40600. * xrpresent context of the canvas which can be used to display/mirror xr content
  40601. */
  40602. canvasContext: Nullable<WebGLRenderingContext>;
  40603. /**
  40604. * Initializes the canvas to be added/removed upon entering/exiting xr
  40605. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40606. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40607. */
  40608. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40609. /**
  40610. * Disposes of the object
  40611. */
  40612. dispose(): void;
  40613. private _setManagedOutputCanvas;
  40614. private _addCanvas;
  40615. private _removeCanvas;
  40616. }
  40617. }
  40618. declare module "babylonjs/Cameras/XR/index" {
  40619. export * from "babylonjs/Cameras/XR/webXRCamera";
  40620. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40621. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40622. export * from "babylonjs/Cameras/XR/webXRInput";
  40623. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40624. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40625. }
  40626. declare module "babylonjs/Cameras/RigModes/index" {
  40627. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40628. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40629. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40630. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40631. }
  40632. declare module "babylonjs/Cameras/index" {
  40633. export * from "babylonjs/Cameras/Inputs/index";
  40634. export * from "babylonjs/Cameras/cameraInputsManager";
  40635. export * from "babylonjs/Cameras/camera";
  40636. export * from "babylonjs/Cameras/targetCamera";
  40637. export * from "babylonjs/Cameras/freeCamera";
  40638. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40639. export * from "babylonjs/Cameras/touchCamera";
  40640. export * from "babylonjs/Cameras/arcRotateCamera";
  40641. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40642. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40643. export * from "babylonjs/Cameras/flyCamera";
  40644. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40645. export * from "babylonjs/Cameras/followCamera";
  40646. export * from "babylonjs/Cameras/gamepadCamera";
  40647. export * from "babylonjs/Cameras/Stereoscopic/index";
  40648. export * from "babylonjs/Cameras/universalCamera";
  40649. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40650. export * from "babylonjs/Cameras/VR/index";
  40651. export * from "babylonjs/Cameras/XR/index";
  40652. export * from "babylonjs/Cameras/RigModes/index";
  40653. }
  40654. declare module "babylonjs/Collisions/index" {
  40655. export * from "babylonjs/Collisions/collider";
  40656. export * from "babylonjs/Collisions/collisionCoordinator";
  40657. export * from "babylonjs/Collisions/pickingInfo";
  40658. export * from "babylonjs/Collisions/intersectionInfo";
  40659. }
  40660. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40661. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40662. import { Vector3, Plane } from "babylonjs/Maths/math";
  40663. import { Ray } from "babylonjs/Culling/ray";
  40664. /**
  40665. * Contains an array of blocks representing the octree
  40666. */
  40667. export interface IOctreeContainer<T> {
  40668. /**
  40669. * Blocks within the octree
  40670. */
  40671. blocks: Array<OctreeBlock<T>>;
  40672. }
  40673. /**
  40674. * Class used to store a cell in an octree
  40675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40676. */
  40677. export class OctreeBlock<T> {
  40678. /**
  40679. * Gets the content of the current block
  40680. */
  40681. entries: T[];
  40682. /**
  40683. * Gets the list of block children
  40684. */
  40685. blocks: Array<OctreeBlock<T>>;
  40686. private _depth;
  40687. private _maxDepth;
  40688. private _capacity;
  40689. private _minPoint;
  40690. private _maxPoint;
  40691. private _boundingVectors;
  40692. private _creationFunc;
  40693. /**
  40694. * Creates a new block
  40695. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40696. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40697. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40698. * @param depth defines the current depth of this block in the octree
  40699. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40700. * @param creationFunc defines a callback to call when an element is added to the block
  40701. */
  40702. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40703. /**
  40704. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40705. */
  40706. readonly capacity: number;
  40707. /**
  40708. * Gets the minimum vector (in world space) of the block's bounding box
  40709. */
  40710. readonly minPoint: Vector3;
  40711. /**
  40712. * Gets the maximum vector (in world space) of the block's bounding box
  40713. */
  40714. readonly maxPoint: Vector3;
  40715. /**
  40716. * Add a new element to this block
  40717. * @param entry defines the element to add
  40718. */
  40719. addEntry(entry: T): void;
  40720. /**
  40721. * Remove an element from this block
  40722. * @param entry defines the element to remove
  40723. */
  40724. removeEntry(entry: T): void;
  40725. /**
  40726. * Add an array of elements to this block
  40727. * @param entries defines the array of elements to add
  40728. */
  40729. addEntries(entries: T[]): void;
  40730. /**
  40731. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40732. * @param frustumPlanes defines the frustum planes to test
  40733. * @param selection defines the array to store current content if selection is positive
  40734. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40735. */
  40736. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40737. /**
  40738. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40739. * @param sphereCenter defines the bounding sphere center
  40740. * @param sphereRadius defines the bounding sphere radius
  40741. * @param selection defines the array to store current content if selection is positive
  40742. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40743. */
  40744. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40745. /**
  40746. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40747. * @param ray defines the ray to test with
  40748. * @param selection defines the array to store current content if selection is positive
  40749. */
  40750. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40751. /**
  40752. * Subdivide the content into child blocks (this block will then be empty)
  40753. */
  40754. createInnerBlocks(): void;
  40755. /**
  40756. * @hidden
  40757. */
  40758. 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;
  40759. }
  40760. }
  40761. declare module "babylonjs/Culling/Octrees/octree" {
  40762. import { SmartArray } from "babylonjs/Misc/smartArray";
  40763. import { Vector3, Plane } from "babylonjs/Maths/math";
  40764. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40766. import { Ray } from "babylonjs/Culling/ray";
  40767. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40768. /**
  40769. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40770. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40771. */
  40772. export class Octree<T> {
  40773. /** 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.) */
  40774. maxDepth: number;
  40775. /**
  40776. * Blocks within the octree containing objects
  40777. */
  40778. blocks: Array<OctreeBlock<T>>;
  40779. /**
  40780. * Content stored in the octree
  40781. */
  40782. dynamicContent: T[];
  40783. private _maxBlockCapacity;
  40784. private _selectionContent;
  40785. private _creationFunc;
  40786. /**
  40787. * Creates a octree
  40788. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40789. * @param creationFunc function to be used to instatiate the octree
  40790. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40791. * @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.)
  40792. */
  40793. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40794. /** 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.) */
  40795. maxDepth?: number);
  40796. /**
  40797. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40798. * @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);
  40799. * @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);
  40800. * @param entries meshes to be added to the octree blocks
  40801. */
  40802. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40803. /**
  40804. * Adds a mesh to the octree
  40805. * @param entry Mesh to add to the octree
  40806. */
  40807. addMesh(entry: T): void;
  40808. /**
  40809. * Remove an element from the octree
  40810. * @param entry defines the element to remove
  40811. */
  40812. removeMesh(entry: T): void;
  40813. /**
  40814. * Selects an array of meshes within the frustum
  40815. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40816. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40817. * @returns array of meshes within the frustum
  40818. */
  40819. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40820. /**
  40821. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40822. * @param sphereCenter defines the bounding sphere center
  40823. * @param sphereRadius defines the bounding sphere radius
  40824. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40825. * @returns an array of objects that intersect the sphere
  40826. */
  40827. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40828. /**
  40829. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40830. * @param ray defines the ray to test with
  40831. * @returns array of intersected objects
  40832. */
  40833. intersectsRay(ray: Ray): SmartArray<T>;
  40834. /**
  40835. * Adds a mesh into the octree block if it intersects the block
  40836. */
  40837. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40838. /**
  40839. * Adds a submesh into the octree block if it intersects the block
  40840. */
  40841. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40842. }
  40843. }
  40844. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40845. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40846. import { Scene } from "babylonjs/scene";
  40847. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40849. import { Ray } from "babylonjs/Culling/ray";
  40850. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40851. import { Collider } from "babylonjs/Collisions/collider";
  40852. module "babylonjs/scene" {
  40853. interface Scene {
  40854. /**
  40855. * @hidden
  40856. * Backing Filed
  40857. */
  40858. _selectionOctree: Octree<AbstractMesh>;
  40859. /**
  40860. * Gets the octree used to boost mesh selection (picking)
  40861. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40862. */
  40863. selectionOctree: Octree<AbstractMesh>;
  40864. /**
  40865. * Creates or updates the octree used to boost selection (picking)
  40866. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40867. * @param maxCapacity defines the maximum capacity per leaf
  40868. * @param maxDepth defines the maximum depth of the octree
  40869. * @returns an octree of AbstractMesh
  40870. */
  40871. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40872. }
  40873. }
  40874. module "babylonjs/Meshes/abstractMesh" {
  40875. interface AbstractMesh {
  40876. /**
  40877. * @hidden
  40878. * Backing Field
  40879. */
  40880. _submeshesOctree: Octree<SubMesh>;
  40881. /**
  40882. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40883. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40884. * @param maxCapacity defines the maximum size of each block (64 by default)
  40885. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40886. * @returns the new octree
  40887. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40888. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40889. */
  40890. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40891. }
  40892. }
  40893. /**
  40894. * Defines the octree scene component responsible to manage any octrees
  40895. * in a given scene.
  40896. */
  40897. export class OctreeSceneComponent {
  40898. /**
  40899. * The component name helpfull to identify the component in the list of scene components.
  40900. */
  40901. readonly name: string;
  40902. /**
  40903. * The scene the component belongs to.
  40904. */
  40905. scene: Scene;
  40906. /**
  40907. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40908. */
  40909. readonly checksIsEnabled: boolean;
  40910. /**
  40911. * Creates a new instance of the component for the given scene
  40912. * @param scene Defines the scene to register the component in
  40913. */
  40914. constructor(scene: Scene);
  40915. /**
  40916. * Registers the component in a given scene
  40917. */
  40918. register(): void;
  40919. /**
  40920. * Return the list of active meshes
  40921. * @returns the list of active meshes
  40922. */
  40923. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40924. /**
  40925. * Return the list of active sub meshes
  40926. * @param mesh The mesh to get the candidates sub meshes from
  40927. * @returns the list of active sub meshes
  40928. */
  40929. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40930. private _tempRay;
  40931. /**
  40932. * Return the list of sub meshes intersecting with a given local ray
  40933. * @param mesh defines the mesh to find the submesh for
  40934. * @param localRay defines the ray in local space
  40935. * @returns the list of intersecting sub meshes
  40936. */
  40937. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40938. /**
  40939. * Return the list of sub meshes colliding with a collider
  40940. * @param mesh defines the mesh to find the submesh for
  40941. * @param collider defines the collider to evaluate the collision against
  40942. * @returns the list of colliding sub meshes
  40943. */
  40944. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40945. /**
  40946. * Rebuilds the elements related to this component in case of
  40947. * context lost for instance.
  40948. */
  40949. rebuild(): void;
  40950. /**
  40951. * Disposes the component and the associated ressources.
  40952. */
  40953. dispose(): void;
  40954. }
  40955. }
  40956. declare module "babylonjs/Culling/Octrees/index" {
  40957. export * from "babylonjs/Culling/Octrees/octree";
  40958. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40959. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  40960. }
  40961. declare module "babylonjs/Culling/index" {
  40962. export * from "babylonjs/Culling/boundingBox";
  40963. export * from "babylonjs/Culling/boundingInfo";
  40964. export * from "babylonjs/Culling/boundingSphere";
  40965. export * from "babylonjs/Culling/Octrees/index";
  40966. export * from "babylonjs/Culling/ray";
  40967. }
  40968. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  40969. import { Vector3, Color4 } from "babylonjs/Maths/math";
  40970. import { Nullable } from "babylonjs/types";
  40971. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  40972. import { Scene } from "babylonjs/scene";
  40973. /**
  40974. * Class containing static functions to help procedurally build meshes
  40975. */
  40976. export class LinesBuilder {
  40977. /**
  40978. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40979. * * 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
  40980. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40981. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40982. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40983. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40984. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40985. * * 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
  40986. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40989. * @param name defines the name of the new line system
  40990. * @param options defines the options used to create the line system
  40991. * @param scene defines the hosting scene
  40992. * @returns a new line system mesh
  40993. */
  40994. static CreateLineSystem(name: string, options: {
  40995. lines: Vector3[][];
  40996. updatable?: boolean;
  40997. instance?: Nullable<LinesMesh>;
  40998. colors?: Nullable<Color4[][]>;
  40999. useVertexAlpha?: boolean;
  41000. }, scene: Nullable<Scene>): LinesMesh;
  41001. /**
  41002. * Creates a line mesh
  41003. * 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
  41004. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41005. * * The parameter `points` is an array successive Vector3
  41006. * * 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
  41007. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41008. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41009. * * When updating an instance, remember that only point positions can change, not the number of points
  41010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41011. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41012. * @param name defines the name of the new line system
  41013. * @param options defines the options used to create the line system
  41014. * @param scene defines the hosting scene
  41015. * @returns a new line mesh
  41016. */
  41017. static CreateLines(name: string, options: {
  41018. points: Vector3[];
  41019. updatable?: boolean;
  41020. instance?: Nullable<LinesMesh>;
  41021. colors?: Color4[];
  41022. useVertexAlpha?: boolean;
  41023. }, scene?: Nullable<Scene>): LinesMesh;
  41024. /**
  41025. * Creates a dashed line mesh
  41026. * * 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
  41027. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41028. * * The parameter `points` is an array successive Vector3
  41029. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41030. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41031. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41032. * * 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
  41033. * * When updating an instance, remember that only point positions can change, not the number of points
  41034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41035. * @param name defines the name of the mesh
  41036. * @param options defines the options used to create the mesh
  41037. * @param scene defines the hosting scene
  41038. * @returns the dashed line mesh
  41039. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41040. */
  41041. static CreateDashedLines(name: string, options: {
  41042. points: Vector3[];
  41043. dashSize?: number;
  41044. gapSize?: number;
  41045. dashNb?: number;
  41046. updatable?: boolean;
  41047. instance?: LinesMesh;
  41048. }, scene?: Nullable<Scene>): LinesMesh;
  41049. }
  41050. }
  41051. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41052. import { IDisposable, Scene } from "babylonjs/scene";
  41053. import { Nullable } from "babylonjs/types";
  41054. import { Observable } from "babylonjs/Misc/observable";
  41055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41056. /**
  41057. * Renders a layer on top of an existing scene
  41058. */
  41059. export class UtilityLayerRenderer implements IDisposable {
  41060. /** the original scene that will be rendered on top of */
  41061. originalScene: Scene;
  41062. private _pointerCaptures;
  41063. private _lastPointerEvents;
  41064. private static _DefaultUtilityLayer;
  41065. private static _DefaultKeepDepthUtilityLayer;
  41066. /**
  41067. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41068. */
  41069. pickUtilitySceneFirst: boolean;
  41070. /**
  41071. * 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)
  41072. */
  41073. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41074. /**
  41075. * 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)
  41076. */
  41077. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41078. /**
  41079. * The scene that is rendered on top of the original scene
  41080. */
  41081. utilityLayerScene: Scene;
  41082. /**
  41083. * If the utility layer should automatically be rendered on top of existing scene
  41084. */
  41085. shouldRender: boolean;
  41086. /**
  41087. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41088. */
  41089. onlyCheckPointerDownEvents: boolean;
  41090. /**
  41091. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41092. */
  41093. processAllEvents: boolean;
  41094. /**
  41095. * Observable raised when the pointer move from the utility layer scene to the main scene
  41096. */
  41097. onPointerOutObservable: Observable<number>;
  41098. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41099. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41100. private _afterRenderObserver;
  41101. private _sceneDisposeObserver;
  41102. private _originalPointerObserver;
  41103. /**
  41104. * Instantiates a UtilityLayerRenderer
  41105. * @param originalScene the original scene that will be rendered on top of
  41106. * @param handleEvents boolean indicating if the utility layer should handle events
  41107. */
  41108. constructor(
  41109. /** the original scene that will be rendered on top of */
  41110. originalScene: Scene, handleEvents?: boolean);
  41111. private _notifyObservers;
  41112. /**
  41113. * Renders the utility layers scene on top of the original scene
  41114. */
  41115. render(): void;
  41116. /**
  41117. * Disposes of the renderer
  41118. */
  41119. dispose(): void;
  41120. private _updateCamera;
  41121. }
  41122. }
  41123. declare module "babylonjs/Gizmos/gizmo" {
  41124. import { Nullable } from "babylonjs/types";
  41125. import { IDisposable } from "babylonjs/scene";
  41126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41127. import { Mesh } from "babylonjs/Meshes/mesh";
  41128. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41129. /**
  41130. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41131. */
  41132. export class Gizmo implements IDisposable {
  41133. /** The utility layer the gizmo will be added to */
  41134. gizmoLayer: UtilityLayerRenderer;
  41135. /**
  41136. * The root mesh of the gizmo
  41137. */
  41138. _rootMesh: Mesh;
  41139. private _attachedMesh;
  41140. /**
  41141. * Ratio for the scale of the gizmo (Default: 1)
  41142. */
  41143. scaleRatio: number;
  41144. private _tmpMatrix;
  41145. /**
  41146. * If a custom mesh has been set (Default: false)
  41147. */
  41148. protected _customMeshSet: boolean;
  41149. /**
  41150. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41151. * * When set, interactions will be enabled
  41152. */
  41153. attachedMesh: Nullable<AbstractMesh>;
  41154. /**
  41155. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41156. * @param mesh The mesh to replace the default mesh of the gizmo
  41157. */
  41158. setCustomMesh(mesh: Mesh): void;
  41159. /**
  41160. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41161. */
  41162. updateGizmoRotationToMatchAttachedMesh: boolean;
  41163. /**
  41164. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41165. */
  41166. updateGizmoPositionToMatchAttachedMesh: boolean;
  41167. /**
  41168. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41169. */
  41170. protected _updateScale: boolean;
  41171. protected _interactionsEnabled: boolean;
  41172. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41173. private _beforeRenderObserver;
  41174. /**
  41175. * Creates a gizmo
  41176. * @param gizmoLayer The utility layer the gizmo will be added to
  41177. */
  41178. constructor(
  41179. /** The utility layer the gizmo will be added to */
  41180. gizmoLayer?: UtilityLayerRenderer);
  41181. private _tempVector;
  41182. /**
  41183. * @hidden
  41184. * Updates the gizmo to match the attached mesh's position/rotation
  41185. */
  41186. protected _update(): void;
  41187. /**
  41188. * Disposes of the gizmo
  41189. */
  41190. dispose(): void;
  41191. }
  41192. }
  41193. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41194. import { Observable } from "babylonjs/Misc/observable";
  41195. import { Nullable } from "babylonjs/types";
  41196. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41197. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41199. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41200. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41201. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41202. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41203. import { Scene } from "babylonjs/scene";
  41204. /**
  41205. * Single axis drag gizmo
  41206. */
  41207. export class AxisDragGizmo extends Gizmo {
  41208. /**
  41209. * Drag behavior responsible for the gizmos dragging interactions
  41210. */
  41211. dragBehavior: PointerDragBehavior;
  41212. private _pointerObserver;
  41213. /**
  41214. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41215. */
  41216. snapDistance: number;
  41217. /**
  41218. * Event that fires each time the gizmo snaps to a new location.
  41219. * * snapDistance is the the change in distance
  41220. */
  41221. onSnapObservable: Observable<{
  41222. snapDistance: number;
  41223. }>;
  41224. /** @hidden */
  41225. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41226. /** @hidden */
  41227. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41228. /**
  41229. * Creates an AxisDragGizmo
  41230. * @param gizmoLayer The utility layer the gizmo will be added to
  41231. * @param dragAxis The axis which the gizmo will be able to drag on
  41232. * @param color The color of the gizmo
  41233. */
  41234. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41235. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41236. /**
  41237. * Disposes of the gizmo
  41238. */
  41239. dispose(): void;
  41240. }
  41241. }
  41242. declare module "babylonjs/Debug/axesViewer" {
  41243. import { Vector3 } from "babylonjs/Maths/math";
  41244. import { Nullable } from "babylonjs/types";
  41245. import { Scene } from "babylonjs/scene";
  41246. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41247. /**
  41248. * The Axes viewer will show 3 axes in a specific point in space
  41249. */
  41250. export class AxesViewer {
  41251. private _xAxis;
  41252. private _yAxis;
  41253. private _zAxis;
  41254. private _scaleLinesFactor;
  41255. private _instanced;
  41256. /**
  41257. * Gets the hosting scene
  41258. */
  41259. scene: Scene;
  41260. /**
  41261. * Gets or sets a number used to scale line length
  41262. */
  41263. scaleLines: number;
  41264. /** Gets the node hierarchy used to render x-axis */
  41265. readonly xAxis: TransformNode;
  41266. /** Gets the node hierarchy used to render y-axis */
  41267. readonly yAxis: TransformNode;
  41268. /** Gets the node hierarchy used to render z-axis */
  41269. readonly zAxis: TransformNode;
  41270. /**
  41271. * Creates a new AxesViewer
  41272. * @param scene defines the hosting scene
  41273. * @param scaleLines defines a number used to scale line length (1 by default)
  41274. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41275. * @param xAxis defines the node hierarchy used to render the x-axis
  41276. * @param yAxis defines the node hierarchy used to render the y-axis
  41277. * @param zAxis defines the node hierarchy used to render the z-axis
  41278. */
  41279. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41280. /**
  41281. * Force the viewer to update
  41282. * @param position defines the position of the viewer
  41283. * @param xaxis defines the x axis of the viewer
  41284. * @param yaxis defines the y axis of the viewer
  41285. * @param zaxis defines the z axis of the viewer
  41286. */
  41287. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41288. /**
  41289. * Creates an instance of this axes viewer.
  41290. * @returns a new axes viewer with instanced meshes
  41291. */
  41292. createInstance(): AxesViewer;
  41293. /** Releases resources */
  41294. dispose(): void;
  41295. private static _SetRenderingGroupId;
  41296. }
  41297. }
  41298. declare module "babylonjs/Debug/boneAxesViewer" {
  41299. import { Nullable } from "babylonjs/types";
  41300. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41301. import { Vector3 } from "babylonjs/Maths/math";
  41302. import { Mesh } from "babylonjs/Meshes/mesh";
  41303. import { Bone } from "babylonjs/Bones/bone";
  41304. import { Scene } from "babylonjs/scene";
  41305. /**
  41306. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41307. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41308. */
  41309. export class BoneAxesViewer extends AxesViewer {
  41310. /**
  41311. * Gets or sets the target mesh where to display the axes viewer
  41312. */
  41313. mesh: Nullable<Mesh>;
  41314. /**
  41315. * Gets or sets the target bone where to display the axes viewer
  41316. */
  41317. bone: Nullable<Bone>;
  41318. /** Gets current position */
  41319. pos: Vector3;
  41320. /** Gets direction of X axis */
  41321. xaxis: Vector3;
  41322. /** Gets direction of Y axis */
  41323. yaxis: Vector3;
  41324. /** Gets direction of Z axis */
  41325. zaxis: Vector3;
  41326. /**
  41327. * Creates a new BoneAxesViewer
  41328. * @param scene defines the hosting scene
  41329. * @param bone defines the target bone
  41330. * @param mesh defines the target mesh
  41331. * @param scaleLines defines a scaling factor for line length (1 by default)
  41332. */
  41333. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41334. /**
  41335. * Force the viewer to update
  41336. */
  41337. update(): void;
  41338. /** Releases resources */
  41339. dispose(): void;
  41340. }
  41341. }
  41342. declare module "babylonjs/Debug/debugLayer" {
  41343. import { Observable } from "babylonjs/Misc/observable";
  41344. import { Scene } from "babylonjs/scene";
  41345. /**
  41346. * Interface used to define scene explorer extensibility option
  41347. */
  41348. export interface IExplorerExtensibilityOption {
  41349. /**
  41350. * Define the option label
  41351. */
  41352. label: string;
  41353. /**
  41354. * Defines the action to execute on click
  41355. */
  41356. action: (entity: any) => void;
  41357. }
  41358. /**
  41359. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41360. */
  41361. export interface IExplorerExtensibilityGroup {
  41362. /**
  41363. * Defines a predicate to test if a given type mut be extended
  41364. */
  41365. predicate: (entity: any) => boolean;
  41366. /**
  41367. * Gets the list of options added to a type
  41368. */
  41369. entries: IExplorerExtensibilityOption[];
  41370. }
  41371. /**
  41372. * Interface used to define the options to use to create the Inspector
  41373. */
  41374. export interface IInspectorOptions {
  41375. /**
  41376. * Display in overlay mode (default: false)
  41377. */
  41378. overlay?: boolean;
  41379. /**
  41380. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41381. */
  41382. globalRoot?: HTMLElement;
  41383. /**
  41384. * Display the Scene explorer
  41385. */
  41386. showExplorer?: boolean;
  41387. /**
  41388. * Display the property inspector
  41389. */
  41390. showInspector?: boolean;
  41391. /**
  41392. * Display in embed mode (both panes on the right)
  41393. */
  41394. embedMode?: boolean;
  41395. /**
  41396. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41397. */
  41398. handleResize?: boolean;
  41399. /**
  41400. * Allow the panes to popup (default: true)
  41401. */
  41402. enablePopup?: boolean;
  41403. /**
  41404. * Allow the panes to be closed by users (default: true)
  41405. */
  41406. enableClose?: boolean;
  41407. /**
  41408. * Optional list of extensibility entries
  41409. */
  41410. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41411. /**
  41412. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41413. */
  41414. inspectorURL?: string;
  41415. }
  41416. module "babylonjs/scene" {
  41417. interface Scene {
  41418. /**
  41419. * @hidden
  41420. * Backing field
  41421. */
  41422. _debugLayer: DebugLayer;
  41423. /**
  41424. * Gets the debug layer (aka Inspector) associated with the scene
  41425. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41426. */
  41427. debugLayer: DebugLayer;
  41428. }
  41429. }
  41430. /**
  41431. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41432. * what is happening in your scene
  41433. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41434. */
  41435. export class DebugLayer {
  41436. /**
  41437. * Define the url to get the inspector script from.
  41438. * By default it uses the babylonjs CDN.
  41439. * @ignoreNaming
  41440. */
  41441. static InspectorURL: string;
  41442. private _scene;
  41443. private BJSINSPECTOR;
  41444. /**
  41445. * Observable triggered when a property is changed through the inspector.
  41446. */
  41447. onPropertyChangedObservable: Observable<{
  41448. object: any;
  41449. property: string;
  41450. value: any;
  41451. initialValue: any;
  41452. }>;
  41453. /**
  41454. * Instantiates a new debug layer.
  41455. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41456. * what is happening in your scene
  41457. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41458. * @param scene Defines the scene to inspect
  41459. */
  41460. constructor(scene: Scene);
  41461. /** Creates the inspector window. */
  41462. private _createInspector;
  41463. /**
  41464. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41465. * @param entity defines the entity to select
  41466. * @param lineContainerTitle defines the specific block to highlight
  41467. */
  41468. select(entity: any, lineContainerTitle?: string): void;
  41469. /** Get the inspector from bundle or global */
  41470. private _getGlobalInspector;
  41471. /**
  41472. * Get if the inspector is visible or not.
  41473. * @returns true if visible otherwise, false
  41474. */
  41475. isVisible(): boolean;
  41476. /**
  41477. * Hide the inspector and close its window.
  41478. */
  41479. hide(): void;
  41480. /**
  41481. * Launch the debugLayer.
  41482. * @param config Define the configuration of the inspector
  41483. * @return a promise fulfilled when the debug layer is visible
  41484. */
  41485. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41486. }
  41487. }
  41488. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41489. import { Nullable } from "babylonjs/types";
  41490. import { Scene } from "babylonjs/scene";
  41491. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41492. import { Mesh } from "babylonjs/Meshes/mesh";
  41493. /**
  41494. * Class containing static functions to help procedurally build meshes
  41495. */
  41496. export class BoxBuilder {
  41497. /**
  41498. * Creates a box mesh
  41499. * * The parameter `size` sets the size (float) of each box side (default 1)
  41500. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41501. * * 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)
  41502. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41506. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41507. * @param name defines the name of the mesh
  41508. * @param options defines the options used to create the mesh
  41509. * @param scene defines the hosting scene
  41510. * @returns the box mesh
  41511. */
  41512. static CreateBox(name: string, options: {
  41513. size?: number;
  41514. width?: number;
  41515. height?: number;
  41516. depth?: number;
  41517. faceUV?: Vector4[];
  41518. faceColors?: Color4[];
  41519. sideOrientation?: number;
  41520. frontUVs?: Vector4;
  41521. backUVs?: Vector4;
  41522. updatable?: boolean;
  41523. }, scene?: Nullable<Scene>): Mesh;
  41524. }
  41525. }
  41526. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41527. import { Vector4 } from "babylonjs/Maths/math";
  41528. import { Mesh } from "babylonjs/Meshes/mesh";
  41529. /**
  41530. * Class containing static functions to help procedurally build meshes
  41531. */
  41532. export class SphereBuilder {
  41533. /**
  41534. * Creates a sphere mesh
  41535. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41536. * * 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`)
  41537. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41538. * * 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
  41539. * * 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)
  41540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41543. * @param name defines the name of the mesh
  41544. * @param options defines the options used to create the mesh
  41545. * @param scene defines the hosting scene
  41546. * @returns the sphere mesh
  41547. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41548. */
  41549. static CreateSphere(name: string, options: {
  41550. segments?: number;
  41551. diameter?: number;
  41552. diameterX?: number;
  41553. diameterY?: number;
  41554. diameterZ?: number;
  41555. arc?: number;
  41556. slice?: number;
  41557. sideOrientation?: number;
  41558. frontUVs?: Vector4;
  41559. backUVs?: Vector4;
  41560. updatable?: boolean;
  41561. }, scene: any): Mesh;
  41562. }
  41563. }
  41564. declare module "babylonjs/Debug/physicsViewer" {
  41565. import { Nullable } from "babylonjs/types";
  41566. import { Scene } from "babylonjs/scene";
  41567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41568. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41569. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41570. /**
  41571. * Used to show the physics impostor around the specific mesh
  41572. */
  41573. export class PhysicsViewer {
  41574. /** @hidden */
  41575. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41576. /** @hidden */
  41577. protected _meshes: Array<Nullable<AbstractMesh>>;
  41578. /** @hidden */
  41579. protected _scene: Nullable<Scene>;
  41580. /** @hidden */
  41581. protected _numMeshes: number;
  41582. /** @hidden */
  41583. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41584. private _renderFunction;
  41585. private _utilityLayer;
  41586. private _debugBoxMesh;
  41587. private _debugSphereMesh;
  41588. private _debugMaterial;
  41589. /**
  41590. * Creates a new PhysicsViewer
  41591. * @param scene defines the hosting scene
  41592. */
  41593. constructor(scene: Scene);
  41594. /** @hidden */
  41595. protected _updateDebugMeshes(): void;
  41596. /**
  41597. * Renders a specified physic impostor
  41598. * @param impostor defines the impostor to render
  41599. * @returns the new debug mesh used to render the impostor
  41600. */
  41601. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41602. /**
  41603. * Hides a specified physic impostor
  41604. * @param impostor defines the impostor to hide
  41605. */
  41606. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41607. private _getDebugMaterial;
  41608. private _getDebugBoxMesh;
  41609. private _getDebugSphereMesh;
  41610. private _getDebugMesh;
  41611. /** Releases all resources */
  41612. dispose(): void;
  41613. }
  41614. }
  41615. declare module "babylonjs/Debug/rayHelper" {
  41616. import { Nullable } from "babylonjs/types";
  41617. import { Ray } from "babylonjs/Culling/ray";
  41618. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41619. import { Scene } from "babylonjs/scene";
  41620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41621. import "babylonjs/Meshes/Builders/linesBuilder";
  41622. /**
  41623. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41624. * in order to better appreciate the issue one might have.
  41625. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41626. */
  41627. export class RayHelper {
  41628. /**
  41629. * Defines the ray we are currently tryin to visualize.
  41630. */
  41631. ray: Nullable<Ray>;
  41632. private _renderPoints;
  41633. private _renderLine;
  41634. private _renderFunction;
  41635. private _scene;
  41636. private _updateToMeshFunction;
  41637. private _attachedToMesh;
  41638. private _meshSpaceDirection;
  41639. private _meshSpaceOrigin;
  41640. /**
  41641. * Helper function to create a colored helper in a scene in one line.
  41642. * @param ray Defines the ray we are currently tryin to visualize
  41643. * @param scene Defines the scene the ray is used in
  41644. * @param color Defines the color we want to see the ray in
  41645. * @returns The newly created ray helper.
  41646. */
  41647. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41648. /**
  41649. * Instantiate a new ray helper.
  41650. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41651. * in order to better appreciate the issue one might have.
  41652. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41653. * @param ray Defines the ray we are currently tryin to visualize
  41654. */
  41655. constructor(ray: Ray);
  41656. /**
  41657. * Shows the ray we are willing to debug.
  41658. * @param scene Defines the scene the ray needs to be rendered in
  41659. * @param color Defines the color the ray needs to be rendered in
  41660. */
  41661. show(scene: Scene, color?: Color3): void;
  41662. /**
  41663. * Hides the ray we are debugging.
  41664. */
  41665. hide(): void;
  41666. private _render;
  41667. /**
  41668. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41669. * @param mesh Defines the mesh we want the helper attached to
  41670. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41671. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41672. * @param length Defines the length of the ray
  41673. */
  41674. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41675. /**
  41676. * Detach the ray helper from the mesh it has previously been attached to.
  41677. */
  41678. detachFromMesh(): void;
  41679. private _updateToMesh;
  41680. /**
  41681. * Dispose the helper and release its associated resources.
  41682. */
  41683. dispose(): void;
  41684. }
  41685. }
  41686. declare module "babylonjs/Debug/skeletonViewer" {
  41687. import { Color3 } from "babylonjs/Maths/math";
  41688. import { Scene } from "babylonjs/scene";
  41689. import { Nullable } from "babylonjs/types";
  41690. import { Skeleton } from "babylonjs/Bones/skeleton";
  41691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41692. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41693. /**
  41694. * Class used to render a debug view of a given skeleton
  41695. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41696. */
  41697. export class SkeletonViewer {
  41698. /** defines the skeleton to render */
  41699. skeleton: Skeleton;
  41700. /** defines the mesh attached to the skeleton */
  41701. mesh: AbstractMesh;
  41702. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41703. autoUpdateBonesMatrices: boolean;
  41704. /** defines the rendering group id to use with the viewer */
  41705. renderingGroupId: number;
  41706. /** Gets or sets the color used to render the skeleton */
  41707. color: Color3;
  41708. private _scene;
  41709. private _debugLines;
  41710. private _debugMesh;
  41711. private _isEnabled;
  41712. private _renderFunction;
  41713. private _utilityLayer;
  41714. /**
  41715. * Returns the mesh used to render the bones
  41716. */
  41717. readonly debugMesh: Nullable<LinesMesh>;
  41718. /**
  41719. * Creates a new SkeletonViewer
  41720. * @param skeleton defines the skeleton to render
  41721. * @param mesh defines the mesh attached to the skeleton
  41722. * @param scene defines the hosting scene
  41723. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41724. * @param renderingGroupId defines the rendering group id to use with the viewer
  41725. */
  41726. constructor(
  41727. /** defines the skeleton to render */
  41728. skeleton: Skeleton,
  41729. /** defines the mesh attached to the skeleton */
  41730. mesh: AbstractMesh, scene: Scene,
  41731. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41732. autoUpdateBonesMatrices?: boolean,
  41733. /** defines the rendering group id to use with the viewer */
  41734. renderingGroupId?: number);
  41735. /** Gets or sets a boolean indicating if the viewer is enabled */
  41736. isEnabled: boolean;
  41737. private _getBonePosition;
  41738. private _getLinesForBonesWithLength;
  41739. private _getLinesForBonesNoLength;
  41740. /** Update the viewer to sync with current skeleton state */
  41741. update(): void;
  41742. /** Release associated resources */
  41743. dispose(): void;
  41744. }
  41745. }
  41746. declare module "babylonjs/Debug/index" {
  41747. export * from "babylonjs/Debug/axesViewer";
  41748. export * from "babylonjs/Debug/boneAxesViewer";
  41749. export * from "babylonjs/Debug/debugLayer";
  41750. export * from "babylonjs/Debug/physicsViewer";
  41751. export * from "babylonjs/Debug/rayHelper";
  41752. export * from "babylonjs/Debug/skeletonViewer";
  41753. }
  41754. declare module "babylonjs/Engines/nullEngine" {
  41755. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41756. import { Scene } from "babylonjs/scene";
  41757. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41758. import { Engine } from "babylonjs/Engines/engine";
  41759. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41760. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41761. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41762. import { Effect } from "babylonjs/Materials/effect";
  41763. /**
  41764. * Options to create the null engine
  41765. */
  41766. export class NullEngineOptions {
  41767. /**
  41768. * Render width (Default: 512)
  41769. */
  41770. renderWidth: number;
  41771. /**
  41772. * Render height (Default: 256)
  41773. */
  41774. renderHeight: number;
  41775. /**
  41776. * Texture size (Default: 512)
  41777. */
  41778. textureSize: number;
  41779. /**
  41780. * If delta time between frames should be constant
  41781. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41782. */
  41783. deterministicLockstep: boolean;
  41784. /**
  41785. * Maximum about of steps between frames (Default: 4)
  41786. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41787. */
  41788. lockstepMaxSteps: number;
  41789. }
  41790. /**
  41791. * The null engine class provides support for headless version of babylon.js.
  41792. * This can be used in server side scenario or for testing purposes
  41793. */
  41794. export class NullEngine extends Engine {
  41795. private _options;
  41796. /**
  41797. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41798. */
  41799. isDeterministicLockStep(): boolean;
  41800. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41801. getLockstepMaxSteps(): number;
  41802. /**
  41803. * Sets hardware scaling, used to save performance if needed
  41804. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41805. */
  41806. getHardwareScalingLevel(): number;
  41807. constructor(options?: NullEngineOptions);
  41808. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41809. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41810. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41811. getRenderWidth(useScreen?: boolean): number;
  41812. getRenderHeight(useScreen?: boolean): number;
  41813. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41814. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41815. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41816. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41817. bindSamplers(effect: Effect): void;
  41818. enableEffect(effect: Effect): void;
  41819. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41820. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41821. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41822. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41823. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41824. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41825. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41826. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41827. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41828. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41829. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41830. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41831. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41832. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41833. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41834. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41835. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41836. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41837. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41838. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41839. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41840. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41841. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41842. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41843. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41844. bindBuffers(vertexBuffers: {
  41845. [key: string]: VertexBuffer;
  41846. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41847. wipeCaches(bruteForce?: boolean): void;
  41848. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41849. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41850. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41851. /** @hidden */
  41852. _createTexture(): WebGLTexture;
  41853. /** @hidden */
  41854. _releaseTexture(texture: InternalTexture): void;
  41855. 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;
  41856. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41857. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41858. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41859. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41860. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41861. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41862. areAllEffectsReady(): boolean;
  41863. /**
  41864. * @hidden
  41865. * Get the current error code of the webGL context
  41866. * @returns the error code
  41867. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41868. */
  41869. getError(): number;
  41870. /** @hidden */
  41871. _getUnpackAlignement(): number;
  41872. /** @hidden */
  41873. _unpackFlipY(value: boolean): void;
  41874. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41875. /**
  41876. * Updates a dynamic vertex buffer.
  41877. * @param vertexBuffer the vertex buffer to update
  41878. * @param data the data used to update the vertex buffer
  41879. * @param byteOffset the byte offset of the data (optional)
  41880. * @param byteLength the byte length of the data (optional)
  41881. */
  41882. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41883. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41884. /** @hidden */
  41885. _bindTexture(channel: number, texture: InternalTexture): void;
  41886. /** @hidden */
  41887. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41888. releaseEffects(): void;
  41889. displayLoadingUI(): void;
  41890. hideLoadingUI(): void;
  41891. /** @hidden */
  41892. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41893. /** @hidden */
  41894. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41895. /** @hidden */
  41896. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41897. /** @hidden */
  41898. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41899. }
  41900. }
  41901. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41902. import { Nullable, int } from "babylonjs/types";
  41903. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41904. /** @hidden */
  41905. export class _OcclusionDataStorage {
  41906. /** @hidden */
  41907. occlusionInternalRetryCounter: number;
  41908. /** @hidden */
  41909. isOcclusionQueryInProgress: boolean;
  41910. /** @hidden */
  41911. isOccluded: boolean;
  41912. /** @hidden */
  41913. occlusionRetryCount: number;
  41914. /** @hidden */
  41915. occlusionType: number;
  41916. /** @hidden */
  41917. occlusionQueryAlgorithmType: number;
  41918. }
  41919. module "babylonjs/Engines/engine" {
  41920. interface Engine {
  41921. /**
  41922. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41923. * @return the new query
  41924. */
  41925. createQuery(): WebGLQuery;
  41926. /**
  41927. * Delete and release a webGL query
  41928. * @param query defines the query to delete
  41929. * @return the current engine
  41930. */
  41931. deleteQuery(query: WebGLQuery): Engine;
  41932. /**
  41933. * Check if a given query has resolved and got its value
  41934. * @param query defines the query to check
  41935. * @returns true if the query got its value
  41936. */
  41937. isQueryResultAvailable(query: WebGLQuery): boolean;
  41938. /**
  41939. * Gets the value of a given query
  41940. * @param query defines the query to check
  41941. * @returns the value of the query
  41942. */
  41943. getQueryResult(query: WebGLQuery): number;
  41944. /**
  41945. * Initiates an occlusion query
  41946. * @param algorithmType defines the algorithm to use
  41947. * @param query defines the query to use
  41948. * @returns the current engine
  41949. * @see http://doc.babylonjs.com/features/occlusionquery
  41950. */
  41951. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41952. /**
  41953. * Ends an occlusion query
  41954. * @see http://doc.babylonjs.com/features/occlusionquery
  41955. * @param algorithmType defines the algorithm to use
  41956. * @returns the current engine
  41957. */
  41958. endOcclusionQuery(algorithmType: number): Engine;
  41959. /**
  41960. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41961. * Please note that only one query can be issued at a time
  41962. * @returns a time token used to track the time span
  41963. */
  41964. startTimeQuery(): Nullable<_TimeToken>;
  41965. /**
  41966. * Ends a time query
  41967. * @param token defines the token used to measure the time span
  41968. * @returns the time spent (in ns)
  41969. */
  41970. endTimeQuery(token: _TimeToken): int;
  41971. /** @hidden */
  41972. _currentNonTimestampToken: Nullable<_TimeToken>;
  41973. /** @hidden */
  41974. _createTimeQuery(): WebGLQuery;
  41975. /** @hidden */
  41976. _deleteTimeQuery(query: WebGLQuery): void;
  41977. /** @hidden */
  41978. _getGlAlgorithmType(algorithmType: number): number;
  41979. /** @hidden */
  41980. _getTimeQueryResult(query: WebGLQuery): any;
  41981. /** @hidden */
  41982. _getTimeQueryAvailability(query: WebGLQuery): any;
  41983. }
  41984. }
  41985. module "babylonjs/Meshes/abstractMesh" {
  41986. interface AbstractMesh {
  41987. /**
  41988. * Backing filed
  41989. * @hidden
  41990. */
  41991. __occlusionDataStorage: _OcclusionDataStorage;
  41992. /**
  41993. * Access property
  41994. * @hidden
  41995. */
  41996. _occlusionDataStorage: _OcclusionDataStorage;
  41997. /**
  41998. * 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.
  41999. * The default value is -1 which means don't break the query and wait till the result
  42000. * @see http://doc.babylonjs.com/features/occlusionquery
  42001. */
  42002. occlusionRetryCount: number;
  42003. /**
  42004. * 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:
  42005. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42006. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42007. * * 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.
  42008. * @see http://doc.babylonjs.com/features/occlusionquery
  42009. */
  42010. occlusionType: number;
  42011. /**
  42012. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42013. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42014. * * 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.
  42015. * @see http://doc.babylonjs.com/features/occlusionquery
  42016. */
  42017. occlusionQueryAlgorithmType: number;
  42018. /**
  42019. * 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
  42020. * @see http://doc.babylonjs.com/features/occlusionquery
  42021. */
  42022. isOccluded: boolean;
  42023. /**
  42024. * Flag to check the progress status of the query
  42025. * @see http://doc.babylonjs.com/features/occlusionquery
  42026. */
  42027. isOcclusionQueryInProgress: boolean;
  42028. }
  42029. }
  42030. }
  42031. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42032. import { Nullable } from "babylonjs/types";
  42033. /** @hidden */
  42034. export var _forceTransformFeedbackToBundle: boolean;
  42035. module "babylonjs/Engines/engine" {
  42036. interface Engine {
  42037. /**
  42038. * Creates a webGL transform feedback object
  42039. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42040. * @returns the webGL transform feedback object
  42041. */
  42042. createTransformFeedback(): WebGLTransformFeedback;
  42043. /**
  42044. * Delete a webGL transform feedback object
  42045. * @param value defines the webGL transform feedback object to delete
  42046. */
  42047. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42048. /**
  42049. * Bind a webGL transform feedback object to the webgl context
  42050. * @param value defines the webGL transform feedback object to bind
  42051. */
  42052. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42053. /**
  42054. * Begins a transform feedback operation
  42055. * @param usePoints defines if points or triangles must be used
  42056. */
  42057. beginTransformFeedback(usePoints: boolean): void;
  42058. /**
  42059. * Ends a transform feedback operation
  42060. */
  42061. endTransformFeedback(): void;
  42062. /**
  42063. * Specify the varyings to use with transform feedback
  42064. * @param program defines the associated webGL program
  42065. * @param value defines the list of strings representing the varying names
  42066. */
  42067. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42068. /**
  42069. * Bind a webGL buffer for a transform feedback operation
  42070. * @param value defines the webGL buffer to bind
  42071. */
  42072. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42073. }
  42074. }
  42075. }
  42076. declare module "babylonjs/Engines/Extensions/index" {
  42077. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42078. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42079. }
  42080. declare module "babylonjs/Engines/index" {
  42081. export * from "babylonjs/Engines/constants";
  42082. export * from "babylonjs/Engines/engine";
  42083. export * from "babylonjs/Engines/engineStore";
  42084. export * from "babylonjs/Engines/nullEngine";
  42085. export * from "babylonjs/Engines/Extensions/index";
  42086. }
  42087. declare module "babylonjs/Events/clipboardEvents" {
  42088. /**
  42089. * Gather the list of clipboard event types as constants.
  42090. */
  42091. export class ClipboardEventTypes {
  42092. /**
  42093. * The clipboard event is fired when a copy command is active (pressed).
  42094. */
  42095. static readonly COPY: number;
  42096. /**
  42097. * The clipboard event is fired when a cut command is active (pressed).
  42098. */
  42099. static readonly CUT: number;
  42100. /**
  42101. * The clipboard event is fired when a paste command is active (pressed).
  42102. */
  42103. static readonly PASTE: number;
  42104. }
  42105. /**
  42106. * This class is used to store clipboard related info for the onClipboardObservable event.
  42107. */
  42108. export class ClipboardInfo {
  42109. /**
  42110. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42111. */
  42112. type: number;
  42113. /**
  42114. * Defines the related dom event
  42115. */
  42116. event: ClipboardEvent;
  42117. /**
  42118. *Creates an instance of ClipboardInfo.
  42119. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42120. * @param event Defines the related dom event
  42121. */
  42122. constructor(
  42123. /**
  42124. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42125. */
  42126. type: number,
  42127. /**
  42128. * Defines the related dom event
  42129. */
  42130. event: ClipboardEvent);
  42131. /**
  42132. * Get the clipboard event's type from the keycode.
  42133. * @param keyCode Defines the keyCode for the current keyboard event.
  42134. * @return {number}
  42135. */
  42136. static GetTypeFromCharacter(keyCode: number): number;
  42137. }
  42138. }
  42139. declare module "babylonjs/Events/index" {
  42140. export * from "babylonjs/Events/keyboardEvents";
  42141. export * from "babylonjs/Events/pointerEvents";
  42142. export * from "babylonjs/Events/clipboardEvents";
  42143. }
  42144. declare module "babylonjs/Loading/sceneLoader" {
  42145. import { Observable } from "babylonjs/Misc/observable";
  42146. import { Nullable } from "babylonjs/types";
  42147. import { Scene } from "babylonjs/scene";
  42148. import { Engine } from "babylonjs/Engines/engine";
  42149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42150. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42151. import { AssetContainer } from "babylonjs/assetContainer";
  42152. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42153. import { Skeleton } from "babylonjs/Bones/skeleton";
  42154. /**
  42155. * Class used to represent data loading progression
  42156. */
  42157. export class SceneLoaderProgressEvent {
  42158. /** defines if data length to load can be evaluated */
  42159. readonly lengthComputable: boolean;
  42160. /** defines the loaded data length */
  42161. readonly loaded: number;
  42162. /** defines the data length to load */
  42163. readonly total: number;
  42164. /**
  42165. * Create a new progress event
  42166. * @param lengthComputable defines if data length to load can be evaluated
  42167. * @param loaded defines the loaded data length
  42168. * @param total defines the data length to load
  42169. */
  42170. constructor(
  42171. /** defines if data length to load can be evaluated */
  42172. lengthComputable: boolean,
  42173. /** defines the loaded data length */
  42174. loaded: number,
  42175. /** defines the data length to load */
  42176. total: number);
  42177. /**
  42178. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42179. * @param event defines the source event
  42180. * @returns a new SceneLoaderProgressEvent
  42181. */
  42182. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42183. }
  42184. /**
  42185. * Interface used by SceneLoader plugins to define supported file extensions
  42186. */
  42187. export interface ISceneLoaderPluginExtensions {
  42188. /**
  42189. * Defines the list of supported extensions
  42190. */
  42191. [extension: string]: {
  42192. isBinary: boolean;
  42193. };
  42194. }
  42195. /**
  42196. * Interface used by SceneLoader plugin factory
  42197. */
  42198. export interface ISceneLoaderPluginFactory {
  42199. /**
  42200. * Defines the name of the factory
  42201. */
  42202. name: string;
  42203. /**
  42204. * Function called to create a new plugin
  42205. * @return the new plugin
  42206. */
  42207. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42208. /**
  42209. * Boolean indicating if the plugin can direct load specific data
  42210. */
  42211. canDirectLoad?: (data: string) => boolean;
  42212. }
  42213. /**
  42214. * Interface used to define a SceneLoader plugin
  42215. */
  42216. export interface ISceneLoaderPlugin {
  42217. /**
  42218. * The friendly name of this plugin.
  42219. */
  42220. name: string;
  42221. /**
  42222. * The file extensions supported by this plugin.
  42223. */
  42224. extensions: string | ISceneLoaderPluginExtensions;
  42225. /**
  42226. * Import meshes into a scene.
  42227. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42228. * @param scene The scene to import into
  42229. * @param data The data to import
  42230. * @param rootUrl The root url for scene and resources
  42231. * @param meshes The meshes array to import into
  42232. * @param particleSystems The particle systems array to import into
  42233. * @param skeletons The skeletons array to import into
  42234. * @param onError The callback when import fails
  42235. * @returns True if successful or false otherwise
  42236. */
  42237. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42238. /**
  42239. * Load into a scene.
  42240. * @param scene The scene to load into
  42241. * @param data The data to import
  42242. * @param rootUrl The root url for scene and resources
  42243. * @param onError The callback when import fails
  42244. * @returns true if successful or false otherwise
  42245. */
  42246. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42247. /**
  42248. * The callback that returns true if the data can be directly loaded.
  42249. */
  42250. canDirectLoad?: (data: string) => boolean;
  42251. /**
  42252. * The callback that allows custom handling of the root url based on the response url.
  42253. */
  42254. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42255. /**
  42256. * Load into an asset container.
  42257. * @param scene The scene to load into
  42258. * @param data The data to import
  42259. * @param rootUrl The root url for scene and resources
  42260. * @param onError The callback when import fails
  42261. * @returns The loaded asset container
  42262. */
  42263. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42264. }
  42265. /**
  42266. * Interface used to define an async SceneLoader plugin
  42267. */
  42268. export interface ISceneLoaderPluginAsync {
  42269. /**
  42270. * The friendly name of this plugin.
  42271. */
  42272. name: string;
  42273. /**
  42274. * The file extensions supported by this plugin.
  42275. */
  42276. extensions: string | ISceneLoaderPluginExtensions;
  42277. /**
  42278. * Import meshes into a scene.
  42279. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42280. * @param scene The scene to import into
  42281. * @param data The data to import
  42282. * @param rootUrl The root url for scene and resources
  42283. * @param onProgress The callback when the load progresses
  42284. * @param fileName Defines the name of the file to load
  42285. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42286. */
  42287. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42288. meshes: AbstractMesh[];
  42289. particleSystems: IParticleSystem[];
  42290. skeletons: Skeleton[];
  42291. animationGroups: AnimationGroup[];
  42292. }>;
  42293. /**
  42294. * Load into a scene.
  42295. * @param scene The scene to load into
  42296. * @param data The data to import
  42297. * @param rootUrl The root url for scene and resources
  42298. * @param onProgress The callback when the load progresses
  42299. * @param fileName Defines the name of the file to load
  42300. * @returns Nothing
  42301. */
  42302. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42303. /**
  42304. * The callback that returns true if the data can be directly loaded.
  42305. */
  42306. canDirectLoad?: (data: string) => boolean;
  42307. /**
  42308. * The callback that allows custom handling of the root url based on the response url.
  42309. */
  42310. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42311. /**
  42312. * Load into an asset container.
  42313. * @param scene The scene to load into
  42314. * @param data The data to import
  42315. * @param rootUrl The root url for scene and resources
  42316. * @param onProgress The callback when the load progresses
  42317. * @param fileName Defines the name of the file to load
  42318. * @returns The loaded asset container
  42319. */
  42320. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42321. }
  42322. /**
  42323. * Class used to load scene from various file formats using registered plugins
  42324. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42325. */
  42326. export class SceneLoader {
  42327. /**
  42328. * No logging while loading
  42329. */
  42330. static readonly NO_LOGGING: number;
  42331. /**
  42332. * Minimal logging while loading
  42333. */
  42334. static readonly MINIMAL_LOGGING: number;
  42335. /**
  42336. * Summary logging while loading
  42337. */
  42338. static readonly SUMMARY_LOGGING: number;
  42339. /**
  42340. * Detailled logging while loading
  42341. */
  42342. static readonly DETAILED_LOGGING: number;
  42343. /**
  42344. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42345. */
  42346. static ForceFullSceneLoadingForIncremental: boolean;
  42347. /**
  42348. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42349. */
  42350. static ShowLoadingScreen: boolean;
  42351. /**
  42352. * Defines the current logging level (while loading the scene)
  42353. * @ignorenaming
  42354. */
  42355. static loggingLevel: number;
  42356. /**
  42357. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42358. */
  42359. static CleanBoneMatrixWeights: boolean;
  42360. /**
  42361. * Event raised when a plugin is used to load a scene
  42362. */
  42363. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42364. private static _registeredPlugins;
  42365. private static _getDefaultPlugin;
  42366. private static _getPluginForExtension;
  42367. private static _getPluginForDirectLoad;
  42368. private static _getPluginForFilename;
  42369. private static _getDirectLoad;
  42370. private static _loadData;
  42371. private static _getFileInfo;
  42372. /**
  42373. * Gets a plugin that can load the given extension
  42374. * @param extension defines the extension to load
  42375. * @returns a plugin or null if none works
  42376. */
  42377. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42378. /**
  42379. * Gets a boolean indicating that the given extension can be loaded
  42380. * @param extension defines the extension to load
  42381. * @returns true if the extension is supported
  42382. */
  42383. static IsPluginForExtensionAvailable(extension: string): boolean;
  42384. /**
  42385. * Adds a new plugin to the list of registered plugins
  42386. * @param plugin defines the plugin to add
  42387. */
  42388. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42389. /**
  42390. * Import meshes into a scene
  42391. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42392. * @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)
  42393. * @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)
  42394. * @param scene the instance of BABYLON.Scene to append to
  42395. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42396. * @param onProgress a callback with a progress event for each file being loaded
  42397. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42398. * @param pluginExtension the extension used to determine the plugin
  42399. * @returns The loaded plugin
  42400. */
  42401. 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>;
  42402. /**
  42403. * Import meshes into a scene
  42404. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42405. * @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)
  42406. * @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)
  42407. * @param scene the instance of BABYLON.Scene to append to
  42408. * @param onProgress a callback with a progress event for each file being loaded
  42409. * @param pluginExtension the extension used to determine the plugin
  42410. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42411. */
  42412. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42413. meshes: AbstractMesh[];
  42414. particleSystems: IParticleSystem[];
  42415. skeletons: Skeleton[];
  42416. animationGroups: AnimationGroup[];
  42417. }>;
  42418. /**
  42419. * Load a scene
  42420. * @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)
  42421. * @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)
  42422. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42423. * @param onSuccess a callback with the scene when import succeeds
  42424. * @param onProgress a callback with a progress event for each file being loaded
  42425. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42426. * @param pluginExtension the extension used to determine the plugin
  42427. * @returns The loaded plugin
  42428. */
  42429. 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>;
  42430. /**
  42431. * Load a scene
  42432. * @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)
  42433. * @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)
  42434. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42435. * @param onProgress a callback with a progress event for each file being loaded
  42436. * @param pluginExtension the extension used to determine the plugin
  42437. * @returns The loaded scene
  42438. */
  42439. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42440. /**
  42441. * Append a scene
  42442. * @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)
  42443. * @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)
  42444. * @param scene is the instance of BABYLON.Scene to append to
  42445. * @param onSuccess a callback with the scene when import succeeds
  42446. * @param onProgress a callback with a progress event for each file being loaded
  42447. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42448. * @param pluginExtension the extension used to determine the plugin
  42449. * @returns The loaded plugin
  42450. */
  42451. 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>;
  42452. /**
  42453. * Append a scene
  42454. * @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)
  42455. * @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)
  42456. * @param scene is the instance of BABYLON.Scene to append to
  42457. * @param onProgress a callback with a progress event for each file being loaded
  42458. * @param pluginExtension the extension used to determine the plugin
  42459. * @returns The given scene
  42460. */
  42461. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42462. /**
  42463. * Load a scene into an asset container
  42464. * @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)
  42465. * @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)
  42466. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42467. * @param onSuccess a callback with the scene when import succeeds
  42468. * @param onProgress a callback with a progress event for each file being loaded
  42469. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42470. * @param pluginExtension the extension used to determine the plugin
  42471. * @returns The loaded plugin
  42472. */
  42473. 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>;
  42474. /**
  42475. * Load a scene into an asset container
  42476. * @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)
  42477. * @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)
  42478. * @param scene is the instance of Scene to append to
  42479. * @param onProgress a callback with a progress event for each file being loaded
  42480. * @param pluginExtension the extension used to determine the plugin
  42481. * @returns The loaded asset container
  42482. */
  42483. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42484. }
  42485. }
  42486. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42487. import { Scene } from "babylonjs/scene";
  42488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42489. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42490. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42491. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42492. /**
  42493. * Google Daydream controller
  42494. */
  42495. export class DaydreamController extends WebVRController {
  42496. /**
  42497. * Base Url for the controller model.
  42498. */
  42499. static MODEL_BASE_URL: string;
  42500. /**
  42501. * File name for the controller model.
  42502. */
  42503. static MODEL_FILENAME: string;
  42504. /**
  42505. * Gamepad Id prefix used to identify Daydream Controller.
  42506. */
  42507. static readonly GAMEPAD_ID_PREFIX: string;
  42508. /**
  42509. * Creates a new DaydreamController from a gamepad
  42510. * @param vrGamepad the gamepad that the controller should be created from
  42511. */
  42512. constructor(vrGamepad: any);
  42513. /**
  42514. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42515. * @param scene scene in which to add meshes
  42516. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42517. */
  42518. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42519. /**
  42520. * Called once for each button that changed state since the last frame
  42521. * @param buttonIdx Which button index changed
  42522. * @param state New state of the button
  42523. * @param changes Which properties on the state changed since last frame
  42524. */
  42525. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42526. }
  42527. }
  42528. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42529. import { Scene } from "babylonjs/scene";
  42530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42531. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42532. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42533. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42534. /**
  42535. * Gear VR Controller
  42536. */
  42537. export class GearVRController extends WebVRController {
  42538. /**
  42539. * Base Url for the controller model.
  42540. */
  42541. static MODEL_BASE_URL: string;
  42542. /**
  42543. * File name for the controller model.
  42544. */
  42545. static MODEL_FILENAME: string;
  42546. /**
  42547. * Gamepad Id prefix used to identify this controller.
  42548. */
  42549. static readonly GAMEPAD_ID_PREFIX: string;
  42550. private readonly _buttonIndexToObservableNameMap;
  42551. /**
  42552. * Creates a new GearVRController from a gamepad
  42553. * @param vrGamepad the gamepad that the controller should be created from
  42554. */
  42555. constructor(vrGamepad: any);
  42556. /**
  42557. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42558. * @param scene scene in which to add meshes
  42559. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42560. */
  42561. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42562. /**
  42563. * Called once for each button that changed state since the last frame
  42564. * @param buttonIdx Which button index changed
  42565. * @param state New state of the button
  42566. * @param changes Which properties on the state changed since last frame
  42567. */
  42568. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42569. }
  42570. }
  42571. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42572. import { Scene } from "babylonjs/scene";
  42573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42574. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42575. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42576. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42577. /**
  42578. * Generic Controller
  42579. */
  42580. export class GenericController extends WebVRController {
  42581. /**
  42582. * Base Url for the controller model.
  42583. */
  42584. static readonly MODEL_BASE_URL: string;
  42585. /**
  42586. * File name for the controller model.
  42587. */
  42588. static readonly MODEL_FILENAME: string;
  42589. /**
  42590. * Creates a new GenericController from a gamepad
  42591. * @param vrGamepad the gamepad that the controller should be created from
  42592. */
  42593. constructor(vrGamepad: any);
  42594. /**
  42595. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42596. * @param scene scene in which to add meshes
  42597. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42598. */
  42599. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42600. /**
  42601. * Called once for each button that changed state since the last frame
  42602. * @param buttonIdx Which button index changed
  42603. * @param state New state of the button
  42604. * @param changes Which properties on the state changed since last frame
  42605. */
  42606. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42607. }
  42608. }
  42609. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42610. import { Observable } from "babylonjs/Misc/observable";
  42611. import { Scene } from "babylonjs/scene";
  42612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42613. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42614. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42615. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42616. /**
  42617. * Oculus Touch Controller
  42618. */
  42619. export class OculusTouchController extends WebVRController {
  42620. /**
  42621. * Base Url for the controller model.
  42622. */
  42623. static MODEL_BASE_URL: string;
  42624. /**
  42625. * File name for the left controller model.
  42626. */
  42627. static MODEL_LEFT_FILENAME: string;
  42628. /**
  42629. * File name for the right controller model.
  42630. */
  42631. static MODEL_RIGHT_FILENAME: string;
  42632. /**
  42633. * Fired when the secondary trigger on this controller is modified
  42634. */
  42635. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42636. /**
  42637. * Fired when the thumb rest on this controller is modified
  42638. */
  42639. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42640. /**
  42641. * Creates a new OculusTouchController from a gamepad
  42642. * @param vrGamepad the gamepad that the controller should be created from
  42643. */
  42644. constructor(vrGamepad: any);
  42645. /**
  42646. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42647. * @param scene scene in which to add meshes
  42648. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42649. */
  42650. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42651. /**
  42652. * Fired when the A button on this controller is modified
  42653. */
  42654. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42655. /**
  42656. * Fired when the B button on this controller is modified
  42657. */
  42658. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42659. /**
  42660. * Fired when the X button on this controller is modified
  42661. */
  42662. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42663. /**
  42664. * Fired when the Y button on this controller is modified
  42665. */
  42666. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42667. /**
  42668. * Called once for each button that changed state since the last frame
  42669. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42670. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42671. * 2) secondary trigger (same)
  42672. * 3) A (right) X (left), touch, pressed = value
  42673. * 4) B / Y
  42674. * 5) thumb rest
  42675. * @param buttonIdx Which button index changed
  42676. * @param state New state of the button
  42677. * @param changes Which properties on the state changed since last frame
  42678. */
  42679. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42680. }
  42681. }
  42682. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42683. import { Scene } from "babylonjs/scene";
  42684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42685. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42686. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42687. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42688. import { Observable } from "babylonjs/Misc/observable";
  42689. /**
  42690. * Vive Controller
  42691. */
  42692. export class ViveController extends WebVRController {
  42693. /**
  42694. * Base Url for the controller model.
  42695. */
  42696. static MODEL_BASE_URL: string;
  42697. /**
  42698. * File name for the controller model.
  42699. */
  42700. static MODEL_FILENAME: string;
  42701. /**
  42702. * Creates a new ViveController from a gamepad
  42703. * @param vrGamepad the gamepad that the controller should be created from
  42704. */
  42705. constructor(vrGamepad: any);
  42706. /**
  42707. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42708. * @param scene scene in which to add meshes
  42709. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42710. */
  42711. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42712. /**
  42713. * Fired when the left button on this controller is modified
  42714. */
  42715. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42716. /**
  42717. * Fired when the right button on this controller is modified
  42718. */
  42719. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42720. /**
  42721. * Fired when the menu button on this controller is modified
  42722. */
  42723. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42724. /**
  42725. * Called once for each button that changed state since the last frame
  42726. * Vive mapping:
  42727. * 0: touchpad
  42728. * 1: trigger
  42729. * 2: left AND right buttons
  42730. * 3: menu button
  42731. * @param buttonIdx Which button index changed
  42732. * @param state New state of the button
  42733. * @param changes Which properties on the state changed since last frame
  42734. */
  42735. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42736. }
  42737. }
  42738. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42739. import { Observable } from "babylonjs/Misc/observable";
  42740. import { Scene } from "babylonjs/scene";
  42741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42742. import { Ray } from "babylonjs/Culling/ray";
  42743. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42744. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42745. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42746. /**
  42747. * Defines the WindowsMotionController object that the state of the windows motion controller
  42748. */
  42749. export class WindowsMotionController extends WebVRController {
  42750. /**
  42751. * The base url used to load the left and right controller models
  42752. */
  42753. static MODEL_BASE_URL: string;
  42754. /**
  42755. * The name of the left controller model file
  42756. */
  42757. static MODEL_LEFT_FILENAME: string;
  42758. /**
  42759. * The name of the right controller model file
  42760. */
  42761. static MODEL_RIGHT_FILENAME: string;
  42762. /**
  42763. * The controller name prefix for this controller type
  42764. */
  42765. static readonly GAMEPAD_ID_PREFIX: string;
  42766. /**
  42767. * The controller id pattern for this controller type
  42768. */
  42769. private static readonly GAMEPAD_ID_PATTERN;
  42770. private _loadedMeshInfo;
  42771. private readonly _mapping;
  42772. /**
  42773. * Fired when the trackpad on this controller is clicked
  42774. */
  42775. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42776. /**
  42777. * Fired when the trackpad on this controller is modified
  42778. */
  42779. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42780. /**
  42781. * The current x and y values of this controller's trackpad
  42782. */
  42783. trackpad: StickValues;
  42784. /**
  42785. * Creates a new WindowsMotionController from a gamepad
  42786. * @param vrGamepad the gamepad that the controller should be created from
  42787. */
  42788. constructor(vrGamepad: any);
  42789. /**
  42790. * Fired when the trigger on this controller is modified
  42791. */
  42792. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42793. /**
  42794. * Fired when the menu button on this controller is modified
  42795. */
  42796. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42797. /**
  42798. * Fired when the grip button on this controller is modified
  42799. */
  42800. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42801. /**
  42802. * Fired when the thumbstick button on this controller is modified
  42803. */
  42804. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42805. /**
  42806. * Fired when the touchpad button on this controller is modified
  42807. */
  42808. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42809. /**
  42810. * Fired when the touchpad values on this controller are modified
  42811. */
  42812. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42813. private _updateTrackpad;
  42814. /**
  42815. * Called once per frame by the engine.
  42816. */
  42817. update(): void;
  42818. /**
  42819. * Called once for each button that changed state since the last frame
  42820. * @param buttonIdx Which button index changed
  42821. * @param state New state of the button
  42822. * @param changes Which properties on the state changed since last frame
  42823. */
  42824. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42825. /**
  42826. * Moves the buttons on the controller mesh based on their current state
  42827. * @param buttonName the name of the button to move
  42828. * @param buttonValue the value of the button which determines the buttons new position
  42829. */
  42830. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42831. /**
  42832. * Moves the axis on the controller mesh based on its current state
  42833. * @param axis the index of the axis
  42834. * @param axisValue the value of the axis which determines the meshes new position
  42835. * @hidden
  42836. */
  42837. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42838. /**
  42839. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42840. * @param scene scene in which to add meshes
  42841. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42842. */
  42843. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42844. /**
  42845. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42846. * can be transformed by button presses and axes values, based on this._mapping.
  42847. *
  42848. * @param scene scene in which the meshes exist
  42849. * @param meshes list of meshes that make up the controller model to process
  42850. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42851. */
  42852. private processModel;
  42853. private createMeshInfo;
  42854. /**
  42855. * Gets the ray of the controller in the direction the controller is pointing
  42856. * @param length the length the resulting ray should be
  42857. * @returns a ray in the direction the controller is pointing
  42858. */
  42859. getForwardRay(length?: number): Ray;
  42860. /**
  42861. * Disposes of the controller
  42862. */
  42863. dispose(): void;
  42864. }
  42865. }
  42866. declare module "babylonjs/Gamepads/Controllers/index" {
  42867. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42868. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42869. export * from "babylonjs/Gamepads/Controllers/genericController";
  42870. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42871. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42872. export * from "babylonjs/Gamepads/Controllers/viveController";
  42873. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42874. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42875. }
  42876. declare module "babylonjs/Gamepads/index" {
  42877. export * from "babylonjs/Gamepads/Controllers/index";
  42878. export * from "babylonjs/Gamepads/gamepad";
  42879. export * from "babylonjs/Gamepads/gamepadManager";
  42880. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42881. export * from "babylonjs/Gamepads/xboxGamepad";
  42882. }
  42883. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42884. import { Observable } from "babylonjs/Misc/observable";
  42885. import { Nullable } from "babylonjs/types";
  42886. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42888. import { Mesh } from "babylonjs/Meshes/mesh";
  42889. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42890. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42891. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42892. /**
  42893. * Single axis scale gizmo
  42894. */
  42895. export class AxisScaleGizmo extends Gizmo {
  42896. private _coloredMaterial;
  42897. /**
  42898. * Drag behavior responsible for the gizmos dragging interactions
  42899. */
  42900. dragBehavior: PointerDragBehavior;
  42901. private _pointerObserver;
  42902. /**
  42903. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42904. */
  42905. snapDistance: number;
  42906. /**
  42907. * Event that fires each time the gizmo snaps to a new location.
  42908. * * snapDistance is the the change in distance
  42909. */
  42910. onSnapObservable: Observable<{
  42911. snapDistance: number;
  42912. }>;
  42913. /**
  42914. * If the scaling operation should be done on all axis (default: false)
  42915. */
  42916. uniformScaling: boolean;
  42917. /**
  42918. * Creates an AxisScaleGizmo
  42919. * @param gizmoLayer The utility layer the gizmo will be added to
  42920. * @param dragAxis The axis which the gizmo will be able to scale on
  42921. * @param color The color of the gizmo
  42922. */
  42923. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42924. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42925. /**
  42926. * Disposes of the gizmo
  42927. */
  42928. dispose(): void;
  42929. /**
  42930. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42931. * @param mesh The mesh to replace the default mesh of the gizmo
  42932. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42933. */
  42934. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42935. }
  42936. }
  42937. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42938. import { Observable } from "babylonjs/Misc/observable";
  42939. import { Nullable } from "babylonjs/types";
  42940. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42942. import { Mesh } from "babylonjs/Meshes/mesh";
  42943. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42944. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42945. import "babylonjs/Meshes/Builders/boxBuilder";
  42946. /**
  42947. * Bounding box gizmo
  42948. */
  42949. export class BoundingBoxGizmo extends Gizmo {
  42950. private _lineBoundingBox;
  42951. private _rotateSpheresParent;
  42952. private _scaleBoxesParent;
  42953. private _boundingDimensions;
  42954. private _renderObserver;
  42955. private _pointerObserver;
  42956. private _scaleDragSpeed;
  42957. private _tmpQuaternion;
  42958. private _tmpVector;
  42959. private _tmpRotationMatrix;
  42960. /**
  42961. * 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)
  42962. */
  42963. ignoreChildren: boolean;
  42964. /**
  42965. * 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)
  42966. */
  42967. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42968. /**
  42969. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42970. */
  42971. rotationSphereSize: number;
  42972. /**
  42973. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42974. */
  42975. scaleBoxSize: number;
  42976. /**
  42977. * 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)
  42978. */
  42979. fixedDragMeshScreenSize: boolean;
  42980. /**
  42981. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42982. */
  42983. fixedDragMeshScreenSizeDistanceFactor: number;
  42984. /**
  42985. * Fired when a rotation sphere or scale box is dragged
  42986. */
  42987. onDragStartObservable: Observable<{}>;
  42988. /**
  42989. * Fired when a scale box is dragged
  42990. */
  42991. onScaleBoxDragObservable: Observable<{}>;
  42992. /**
  42993. * Fired when a scale box drag is ended
  42994. */
  42995. onScaleBoxDragEndObservable: Observable<{}>;
  42996. /**
  42997. * Fired when a rotation sphere is dragged
  42998. */
  42999. onRotationSphereDragObservable: Observable<{}>;
  43000. /**
  43001. * Fired when a rotation sphere drag is ended
  43002. */
  43003. onRotationSphereDragEndObservable: Observable<{}>;
  43004. /**
  43005. * 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)
  43006. */
  43007. scalePivot: Nullable<Vector3>;
  43008. private _anchorMesh;
  43009. private _existingMeshScale;
  43010. private _dragMesh;
  43011. private pointerDragBehavior;
  43012. private coloredMaterial;
  43013. private hoverColoredMaterial;
  43014. /**
  43015. * Sets the color of the bounding box gizmo
  43016. * @param color the color to set
  43017. */
  43018. setColor(color: Color3): void;
  43019. /**
  43020. * Creates an BoundingBoxGizmo
  43021. * @param gizmoLayer The utility layer the gizmo will be added to
  43022. * @param color The color of the gizmo
  43023. */
  43024. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43025. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43026. private _selectNode;
  43027. /**
  43028. * Updates the bounding box information for the Gizmo
  43029. */
  43030. updateBoundingBox(): void;
  43031. private _updateRotationSpheres;
  43032. private _updateScaleBoxes;
  43033. /**
  43034. * Enables rotation on the specified axis and disables rotation on the others
  43035. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43036. */
  43037. setEnabledRotationAxis(axis: string): void;
  43038. /**
  43039. * Enables/disables scaling
  43040. * @param enable if scaling should be enabled
  43041. */
  43042. setEnabledScaling(enable: boolean): void;
  43043. private _updateDummy;
  43044. /**
  43045. * Enables a pointer drag behavior on the bounding box of the gizmo
  43046. */
  43047. enableDragBehavior(): void;
  43048. /**
  43049. * Disposes of the gizmo
  43050. */
  43051. dispose(): void;
  43052. /**
  43053. * 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)
  43054. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43055. * @returns the bounding box mesh with the passed in mesh as a child
  43056. */
  43057. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43058. /**
  43059. * CustomMeshes are not supported by this gizmo
  43060. * @param mesh The mesh to replace the default mesh of the gizmo
  43061. */
  43062. setCustomMesh(mesh: Mesh): void;
  43063. }
  43064. }
  43065. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43066. import { Observable } from "babylonjs/Misc/observable";
  43067. import { Nullable } from "babylonjs/types";
  43068. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43070. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43071. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43072. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43073. import "babylonjs/Meshes/Builders/linesBuilder";
  43074. /**
  43075. * Single plane rotation gizmo
  43076. */
  43077. export class PlaneRotationGizmo extends Gizmo {
  43078. /**
  43079. * Drag behavior responsible for the gizmos dragging interactions
  43080. */
  43081. dragBehavior: PointerDragBehavior;
  43082. private _pointerObserver;
  43083. /**
  43084. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43085. */
  43086. snapDistance: number;
  43087. /**
  43088. * Event that fires each time the gizmo snaps to a new location.
  43089. * * snapDistance is the the change in distance
  43090. */
  43091. onSnapObservable: Observable<{
  43092. snapDistance: number;
  43093. }>;
  43094. /**
  43095. * Creates a PlaneRotationGizmo
  43096. * @param gizmoLayer The utility layer the gizmo will be added to
  43097. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43098. * @param color The color of the gizmo
  43099. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43100. */
  43101. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43102. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43103. /**
  43104. * Disposes of the gizmo
  43105. */
  43106. dispose(): void;
  43107. }
  43108. }
  43109. declare module "babylonjs/Gizmos/rotationGizmo" {
  43110. import { Observable } from "babylonjs/Misc/observable";
  43111. import { Nullable } from "babylonjs/types";
  43112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43113. import { Mesh } from "babylonjs/Meshes/mesh";
  43114. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43115. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43116. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43117. /**
  43118. * Gizmo that enables rotating a mesh along 3 axis
  43119. */
  43120. export class RotationGizmo extends Gizmo {
  43121. /**
  43122. * Internal gizmo used for interactions on the x axis
  43123. */
  43124. xGizmo: PlaneRotationGizmo;
  43125. /**
  43126. * Internal gizmo used for interactions on the y axis
  43127. */
  43128. yGizmo: PlaneRotationGizmo;
  43129. /**
  43130. * Internal gizmo used for interactions on the z axis
  43131. */
  43132. zGizmo: PlaneRotationGizmo;
  43133. /** Fires an event when any of it's sub gizmos are dragged */
  43134. onDragStartObservable: Observable<{}>;
  43135. /** Fires an event when any of it's sub gizmos are released from dragging */
  43136. onDragEndObservable: Observable<{}>;
  43137. attachedMesh: Nullable<AbstractMesh>;
  43138. /**
  43139. * Creates a RotationGizmo
  43140. * @param gizmoLayer The utility layer the gizmo will be added to
  43141. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43142. */
  43143. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43144. updateGizmoRotationToMatchAttachedMesh: boolean;
  43145. /**
  43146. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43147. */
  43148. snapDistance: number;
  43149. /**
  43150. * Ratio for the scale of the gizmo (Default: 1)
  43151. */
  43152. scaleRatio: number;
  43153. /**
  43154. * Disposes of the gizmo
  43155. */
  43156. dispose(): void;
  43157. /**
  43158. * CustomMeshes are not supported by this gizmo
  43159. * @param mesh The mesh to replace the default mesh of the gizmo
  43160. */
  43161. setCustomMesh(mesh: Mesh): void;
  43162. }
  43163. }
  43164. declare module "babylonjs/Gizmos/positionGizmo" {
  43165. import { Observable } from "babylonjs/Misc/observable";
  43166. import { Nullable } from "babylonjs/types";
  43167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43168. import { Mesh } from "babylonjs/Meshes/mesh";
  43169. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43170. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43171. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43172. /**
  43173. * Gizmo that enables dragging a mesh along 3 axis
  43174. */
  43175. export class PositionGizmo extends Gizmo {
  43176. /**
  43177. * Internal gizmo used for interactions on the x axis
  43178. */
  43179. xGizmo: AxisDragGizmo;
  43180. /**
  43181. * Internal gizmo used for interactions on the y axis
  43182. */
  43183. yGizmo: AxisDragGizmo;
  43184. /**
  43185. * Internal gizmo used for interactions on the z axis
  43186. */
  43187. zGizmo: AxisDragGizmo;
  43188. /** Fires an event when any of it's sub gizmos are dragged */
  43189. onDragStartObservable: Observable<{}>;
  43190. /** Fires an event when any of it's sub gizmos are released from dragging */
  43191. onDragEndObservable: Observable<{}>;
  43192. attachedMesh: Nullable<AbstractMesh>;
  43193. /**
  43194. * Creates a PositionGizmo
  43195. * @param gizmoLayer The utility layer the gizmo will be added to
  43196. */
  43197. constructor(gizmoLayer?: UtilityLayerRenderer);
  43198. updateGizmoRotationToMatchAttachedMesh: boolean;
  43199. /**
  43200. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43201. */
  43202. snapDistance: number;
  43203. /**
  43204. * Ratio for the scale of the gizmo (Default: 1)
  43205. */
  43206. scaleRatio: number;
  43207. /**
  43208. * Disposes of the gizmo
  43209. */
  43210. dispose(): void;
  43211. /**
  43212. * CustomMeshes are not supported by this gizmo
  43213. * @param mesh The mesh to replace the default mesh of the gizmo
  43214. */
  43215. setCustomMesh(mesh: Mesh): void;
  43216. }
  43217. }
  43218. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43219. import { Scene } from "babylonjs/scene";
  43220. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43221. import { Mesh } from "babylonjs/Meshes/mesh";
  43222. /**
  43223. * Class containing static functions to help procedurally build meshes
  43224. */
  43225. export class PolyhedronBuilder {
  43226. /**
  43227. * Creates a polyhedron mesh
  43228. * * 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
  43229. * * The parameter `size` (positive float, default 1) sets the polygon size
  43230. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43231. * * 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`
  43232. * * 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
  43233. * * 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)`)
  43234. * * 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
  43235. * * 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
  43236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43239. * @param name defines the name of the mesh
  43240. * @param options defines the options used to create the mesh
  43241. * @param scene defines the hosting scene
  43242. * @returns the polyhedron mesh
  43243. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43244. */
  43245. static CreatePolyhedron(name: string, options: {
  43246. type?: number;
  43247. size?: number;
  43248. sizeX?: number;
  43249. sizeY?: number;
  43250. sizeZ?: number;
  43251. custom?: any;
  43252. faceUV?: Vector4[];
  43253. faceColors?: Color4[];
  43254. flat?: boolean;
  43255. updatable?: boolean;
  43256. sideOrientation?: number;
  43257. frontUVs?: Vector4;
  43258. backUVs?: Vector4;
  43259. }, scene: Scene): Mesh;
  43260. }
  43261. }
  43262. declare module "babylonjs/Gizmos/scaleGizmo" {
  43263. import { Observable } from "babylonjs/Misc/observable";
  43264. import { Nullable } from "babylonjs/types";
  43265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43266. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43267. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43268. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43269. /**
  43270. * Gizmo that enables scaling a mesh along 3 axis
  43271. */
  43272. export class ScaleGizmo extends Gizmo {
  43273. /**
  43274. * Internal gizmo used for interactions on the x axis
  43275. */
  43276. xGizmo: AxisScaleGizmo;
  43277. /**
  43278. * Internal gizmo used for interactions on the y axis
  43279. */
  43280. yGizmo: AxisScaleGizmo;
  43281. /**
  43282. * Internal gizmo used for interactions on the z axis
  43283. */
  43284. zGizmo: AxisScaleGizmo;
  43285. /**
  43286. * Internal gizmo used to scale all axis equally
  43287. */
  43288. uniformScaleGizmo: AxisScaleGizmo;
  43289. /** Fires an event when any of it's sub gizmos are dragged */
  43290. onDragStartObservable: Observable<{}>;
  43291. /** Fires an event when any of it's sub gizmos are released from dragging */
  43292. onDragEndObservable: Observable<{}>;
  43293. attachedMesh: Nullable<AbstractMesh>;
  43294. /**
  43295. * Creates a ScaleGizmo
  43296. * @param gizmoLayer The utility layer the gizmo will be added to
  43297. */
  43298. constructor(gizmoLayer?: UtilityLayerRenderer);
  43299. updateGizmoRotationToMatchAttachedMesh: boolean;
  43300. /**
  43301. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43302. */
  43303. snapDistance: number;
  43304. /**
  43305. * Ratio for the scale of the gizmo (Default: 1)
  43306. */
  43307. scaleRatio: number;
  43308. /**
  43309. * Disposes of the gizmo
  43310. */
  43311. dispose(): void;
  43312. }
  43313. }
  43314. declare module "babylonjs/Gizmos/gizmoManager" {
  43315. import { Observable } from "babylonjs/Misc/observable";
  43316. import { Nullable } from "babylonjs/types";
  43317. import { Scene, IDisposable } from "babylonjs/scene";
  43318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43319. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43320. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43321. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43322. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43323. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43324. /**
  43325. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43326. */
  43327. export class GizmoManager implements IDisposable {
  43328. private scene;
  43329. /**
  43330. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43331. */
  43332. gizmos: {
  43333. positionGizmo: Nullable<PositionGizmo>;
  43334. rotationGizmo: Nullable<RotationGizmo>;
  43335. scaleGizmo: Nullable<ScaleGizmo>;
  43336. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43337. };
  43338. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43339. clearGizmoOnEmptyPointerEvent: boolean;
  43340. /** Fires an event when the manager is attached to a mesh */
  43341. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43342. private _gizmosEnabled;
  43343. private _pointerObserver;
  43344. private _attachedMesh;
  43345. private _boundingBoxColor;
  43346. private _defaultUtilityLayer;
  43347. private _defaultKeepDepthUtilityLayer;
  43348. /**
  43349. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43350. */
  43351. boundingBoxDragBehavior: SixDofDragBehavior;
  43352. /**
  43353. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43354. */
  43355. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43356. /**
  43357. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43358. */
  43359. usePointerToAttachGizmos: boolean;
  43360. /**
  43361. * Instatiates a gizmo manager
  43362. * @param scene the scene to overlay the gizmos on top of
  43363. */
  43364. constructor(scene: Scene);
  43365. /**
  43366. * Attaches a set of gizmos to the specified mesh
  43367. * @param mesh The mesh the gizmo's should be attached to
  43368. */
  43369. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43370. /**
  43371. * If the position gizmo is enabled
  43372. */
  43373. positionGizmoEnabled: boolean;
  43374. /**
  43375. * If the rotation gizmo is enabled
  43376. */
  43377. rotationGizmoEnabled: boolean;
  43378. /**
  43379. * If the scale gizmo is enabled
  43380. */
  43381. scaleGizmoEnabled: boolean;
  43382. /**
  43383. * If the boundingBox gizmo is enabled
  43384. */
  43385. boundingBoxGizmoEnabled: boolean;
  43386. /**
  43387. * Disposes of the gizmo manager
  43388. */
  43389. dispose(): void;
  43390. }
  43391. }
  43392. declare module "babylonjs/Gizmos/lightGizmo" {
  43393. import { Nullable } from "babylonjs/types";
  43394. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43395. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43396. import { Light } from "babylonjs/Lights/light";
  43397. /**
  43398. * Gizmo that enables viewing a light
  43399. */
  43400. export class LightGizmo extends Gizmo {
  43401. private _box;
  43402. /**
  43403. * Creates a LightGizmo
  43404. * @param gizmoLayer The utility layer the gizmo will be added to
  43405. */
  43406. constructor(gizmoLayer?: UtilityLayerRenderer);
  43407. private _light;
  43408. /**
  43409. * The light that the gizmo is attached to
  43410. */
  43411. light: Nullable<Light>;
  43412. /**
  43413. * @hidden
  43414. * Updates the gizmo to match the attached mesh's position/rotation
  43415. */
  43416. protected _update(): void;
  43417. }
  43418. }
  43419. declare module "babylonjs/Gizmos/index" {
  43420. export * from "babylonjs/Gizmos/axisDragGizmo";
  43421. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43422. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43423. export * from "babylonjs/Gizmos/gizmo";
  43424. export * from "babylonjs/Gizmos/gizmoManager";
  43425. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43426. export * from "babylonjs/Gizmos/positionGizmo";
  43427. export * from "babylonjs/Gizmos/rotationGizmo";
  43428. export * from "babylonjs/Gizmos/scaleGizmo";
  43429. export * from "babylonjs/Gizmos/lightGizmo";
  43430. }
  43431. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43432. /** @hidden */
  43433. export var backgroundFragmentDeclaration: {
  43434. name: string;
  43435. shader: string;
  43436. };
  43437. }
  43438. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43439. /** @hidden */
  43440. export var backgroundUboDeclaration: {
  43441. name: string;
  43442. shader: string;
  43443. };
  43444. }
  43445. declare module "babylonjs/Shaders/background.fragment" {
  43446. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43447. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43448. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43449. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43450. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43451. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43452. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43453. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43454. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43455. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43456. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43457. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43458. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43459. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43460. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43461. /** @hidden */
  43462. export var backgroundPixelShader: {
  43463. name: string;
  43464. shader: string;
  43465. };
  43466. }
  43467. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43468. /** @hidden */
  43469. export var backgroundVertexDeclaration: {
  43470. name: string;
  43471. shader: string;
  43472. };
  43473. }
  43474. declare module "babylonjs/Shaders/background.vertex" {
  43475. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43476. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43477. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43478. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43479. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43480. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43481. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43482. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43483. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43484. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43485. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43486. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43487. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43488. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43489. /** @hidden */
  43490. export var backgroundVertexShader: {
  43491. name: string;
  43492. shader: string;
  43493. };
  43494. }
  43495. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43496. import { Nullable, int, float } from "babylonjs/types";
  43497. import { Scene } from "babylonjs/scene";
  43498. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43499. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43501. import { Mesh } from "babylonjs/Meshes/mesh";
  43502. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43503. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43504. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43505. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43506. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43507. import "babylonjs/Shaders/background.fragment";
  43508. import "babylonjs/Shaders/background.vertex";
  43509. /**
  43510. * Background material used to create an efficient environement around your scene.
  43511. */
  43512. export class BackgroundMaterial extends PushMaterial {
  43513. /**
  43514. * Standard reflectance value at parallel view angle.
  43515. */
  43516. static StandardReflectance0: number;
  43517. /**
  43518. * Standard reflectance value at grazing angle.
  43519. */
  43520. static StandardReflectance90: number;
  43521. protected _primaryColor: Color3;
  43522. /**
  43523. * Key light Color (multiply against the environement texture)
  43524. */
  43525. primaryColor: Color3;
  43526. protected __perceptualColor: Nullable<Color3>;
  43527. /**
  43528. * Experimental Internal Use Only.
  43529. *
  43530. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43531. * This acts as a helper to set the primary color to a more "human friendly" value.
  43532. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43533. * output color as close as possible from the chosen value.
  43534. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43535. * part of lighting setup.)
  43536. */
  43537. _perceptualColor: Nullable<Color3>;
  43538. protected _primaryColorShadowLevel: float;
  43539. /**
  43540. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43541. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43542. */
  43543. primaryColorShadowLevel: float;
  43544. protected _primaryColorHighlightLevel: float;
  43545. /**
  43546. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43547. * The primary color is used at the level chosen to define what the white area would look.
  43548. */
  43549. primaryColorHighlightLevel: float;
  43550. protected _reflectionTexture: Nullable<BaseTexture>;
  43551. /**
  43552. * Reflection Texture used in the material.
  43553. * Should be author in a specific way for the best result (refer to the documentation).
  43554. */
  43555. reflectionTexture: Nullable<BaseTexture>;
  43556. protected _reflectionBlur: float;
  43557. /**
  43558. * Reflection Texture level of blur.
  43559. *
  43560. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43561. * texture twice.
  43562. */
  43563. reflectionBlur: float;
  43564. protected _diffuseTexture: Nullable<BaseTexture>;
  43565. /**
  43566. * Diffuse Texture used in the material.
  43567. * Should be author in a specific way for the best result (refer to the documentation).
  43568. */
  43569. diffuseTexture: Nullable<BaseTexture>;
  43570. protected _shadowLights: Nullable<IShadowLight[]>;
  43571. /**
  43572. * Specify the list of lights casting shadow on the material.
  43573. * All scene shadow lights will be included if null.
  43574. */
  43575. shadowLights: Nullable<IShadowLight[]>;
  43576. protected _shadowLevel: float;
  43577. /**
  43578. * Helps adjusting the shadow to a softer level if required.
  43579. * 0 means black shadows and 1 means no shadows.
  43580. */
  43581. shadowLevel: float;
  43582. protected _sceneCenter: Vector3;
  43583. /**
  43584. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43585. * It is usually zero but might be interesting to modify according to your setup.
  43586. */
  43587. sceneCenter: Vector3;
  43588. protected _opacityFresnel: boolean;
  43589. /**
  43590. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43591. * This helps ensuring a nice transition when the camera goes under the ground.
  43592. */
  43593. opacityFresnel: boolean;
  43594. protected _reflectionFresnel: boolean;
  43595. /**
  43596. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43597. * This helps adding a mirror texture on the ground.
  43598. */
  43599. reflectionFresnel: boolean;
  43600. protected _reflectionFalloffDistance: number;
  43601. /**
  43602. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43603. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43604. */
  43605. reflectionFalloffDistance: number;
  43606. protected _reflectionAmount: number;
  43607. /**
  43608. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43609. */
  43610. reflectionAmount: number;
  43611. protected _reflectionReflectance0: number;
  43612. /**
  43613. * This specifies the weight of the reflection at grazing angle.
  43614. */
  43615. reflectionReflectance0: number;
  43616. protected _reflectionReflectance90: number;
  43617. /**
  43618. * This specifies the weight of the reflection at a perpendicular point of view.
  43619. */
  43620. reflectionReflectance90: number;
  43621. /**
  43622. * Sets the reflection reflectance fresnel values according to the default standard
  43623. * empirically know to work well :-)
  43624. */
  43625. reflectionStandardFresnelWeight: number;
  43626. protected _useRGBColor: boolean;
  43627. /**
  43628. * Helps to directly use the maps channels instead of their level.
  43629. */
  43630. useRGBColor: boolean;
  43631. protected _enableNoise: boolean;
  43632. /**
  43633. * This helps reducing the banding effect that could occur on the background.
  43634. */
  43635. enableNoise: boolean;
  43636. /**
  43637. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43638. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43639. * Recommended to be keep at 1.0 except for special cases.
  43640. */
  43641. fovMultiplier: number;
  43642. private _fovMultiplier;
  43643. /**
  43644. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43645. */
  43646. useEquirectangularFOV: boolean;
  43647. private _maxSimultaneousLights;
  43648. /**
  43649. * Number of Simultaneous lights allowed on the material.
  43650. */
  43651. maxSimultaneousLights: int;
  43652. /**
  43653. * Default configuration related to image processing available in the Background Material.
  43654. */
  43655. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43656. /**
  43657. * Keep track of the image processing observer to allow dispose and replace.
  43658. */
  43659. private _imageProcessingObserver;
  43660. /**
  43661. * Attaches a new image processing configuration to the PBR Material.
  43662. * @param configuration (if null the scene configuration will be use)
  43663. */
  43664. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43665. /**
  43666. * Gets the image processing configuration used either in this material.
  43667. */
  43668. /**
  43669. * Sets the Default image processing configuration used either in the this material.
  43670. *
  43671. * If sets to null, the scene one is in use.
  43672. */
  43673. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43674. /**
  43675. * Gets wether the color curves effect is enabled.
  43676. */
  43677. /**
  43678. * Sets wether the color curves effect is enabled.
  43679. */
  43680. cameraColorCurvesEnabled: boolean;
  43681. /**
  43682. * Gets wether the color grading effect is enabled.
  43683. */
  43684. /**
  43685. * Gets wether the color grading effect is enabled.
  43686. */
  43687. cameraColorGradingEnabled: boolean;
  43688. /**
  43689. * Gets wether tonemapping is enabled or not.
  43690. */
  43691. /**
  43692. * Sets wether tonemapping is enabled or not
  43693. */
  43694. cameraToneMappingEnabled: boolean;
  43695. /**
  43696. * The camera exposure used on this material.
  43697. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43698. * This corresponds to a photographic exposure.
  43699. */
  43700. /**
  43701. * The camera exposure used on this material.
  43702. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43703. * This corresponds to a photographic exposure.
  43704. */
  43705. cameraExposure: float;
  43706. /**
  43707. * Gets The camera contrast used on this material.
  43708. */
  43709. /**
  43710. * Sets The camera contrast used on this material.
  43711. */
  43712. cameraContrast: float;
  43713. /**
  43714. * Gets the Color Grading 2D Lookup Texture.
  43715. */
  43716. /**
  43717. * Sets the Color Grading 2D Lookup Texture.
  43718. */
  43719. cameraColorGradingTexture: Nullable<BaseTexture>;
  43720. /**
  43721. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43722. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43723. * 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;
  43724. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43725. */
  43726. /**
  43727. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43728. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43729. * 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;
  43730. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43731. */
  43732. cameraColorCurves: Nullable<ColorCurves>;
  43733. /**
  43734. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43735. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43736. */
  43737. switchToBGR: boolean;
  43738. private _renderTargets;
  43739. private _reflectionControls;
  43740. private _white;
  43741. private _primaryShadowColor;
  43742. private _primaryHighlightColor;
  43743. /**
  43744. * Instantiates a Background Material in the given scene
  43745. * @param name The friendly name of the material
  43746. * @param scene The scene to add the material to
  43747. */
  43748. constructor(name: string, scene: Scene);
  43749. /**
  43750. * Gets a boolean indicating that current material needs to register RTT
  43751. */
  43752. readonly hasRenderTargetTextures: boolean;
  43753. /**
  43754. * The entire material has been created in order to prevent overdraw.
  43755. * @returns false
  43756. */
  43757. needAlphaTesting(): boolean;
  43758. /**
  43759. * The entire material has been created in order to prevent overdraw.
  43760. * @returns true if blending is enable
  43761. */
  43762. needAlphaBlending(): boolean;
  43763. /**
  43764. * Checks wether the material is ready to be rendered for a given mesh.
  43765. * @param mesh The mesh to render
  43766. * @param subMesh The submesh to check against
  43767. * @param useInstances Specify wether or not the material is used with instances
  43768. * @returns true if all the dependencies are ready (Textures, Effects...)
  43769. */
  43770. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43771. /**
  43772. * Compute the primary color according to the chosen perceptual color.
  43773. */
  43774. private _computePrimaryColorFromPerceptualColor;
  43775. /**
  43776. * Compute the highlights and shadow colors according to their chosen levels.
  43777. */
  43778. private _computePrimaryColors;
  43779. /**
  43780. * Build the uniform buffer used in the material.
  43781. */
  43782. buildUniformLayout(): void;
  43783. /**
  43784. * Unbind the material.
  43785. */
  43786. unbind(): void;
  43787. /**
  43788. * Bind only the world matrix to the material.
  43789. * @param world The world matrix to bind.
  43790. */
  43791. bindOnlyWorldMatrix(world: Matrix): void;
  43792. /**
  43793. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43794. * @param world The world matrix to bind.
  43795. * @param subMesh The submesh to bind for.
  43796. */
  43797. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43798. /**
  43799. * Dispose the material.
  43800. * @param forceDisposeEffect Force disposal of the associated effect.
  43801. * @param forceDisposeTextures Force disposal of the associated textures.
  43802. */
  43803. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43804. /**
  43805. * Clones the material.
  43806. * @param name The cloned name.
  43807. * @returns The cloned material.
  43808. */
  43809. clone(name: string): BackgroundMaterial;
  43810. /**
  43811. * Serializes the current material to its JSON representation.
  43812. * @returns The JSON representation.
  43813. */
  43814. serialize(): any;
  43815. /**
  43816. * Gets the class name of the material
  43817. * @returns "BackgroundMaterial"
  43818. */
  43819. getClassName(): string;
  43820. /**
  43821. * Parse a JSON input to create back a background material.
  43822. * @param source The JSON data to parse
  43823. * @param scene The scene to create the parsed material in
  43824. * @param rootUrl The root url of the assets the material depends upon
  43825. * @returns the instantiated BackgroundMaterial.
  43826. */
  43827. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43828. }
  43829. }
  43830. declare module "babylonjs/Helpers/environmentHelper" {
  43831. import { Observable } from "babylonjs/Misc/observable";
  43832. import { Nullable } from "babylonjs/types";
  43833. import { Scene } from "babylonjs/scene";
  43834. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43836. import { Mesh } from "babylonjs/Meshes/mesh";
  43837. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43838. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43839. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43840. import "babylonjs/Meshes/Builders/planeBuilder";
  43841. import "babylonjs/Meshes/Builders/boxBuilder";
  43842. /**
  43843. * Represents the different options available during the creation of
  43844. * a Environment helper.
  43845. *
  43846. * This can control the default ground, skybox and image processing setup of your scene.
  43847. */
  43848. export interface IEnvironmentHelperOptions {
  43849. /**
  43850. * Specifies wether or not to create a ground.
  43851. * True by default.
  43852. */
  43853. createGround: boolean;
  43854. /**
  43855. * Specifies the ground size.
  43856. * 15 by default.
  43857. */
  43858. groundSize: number;
  43859. /**
  43860. * The texture used on the ground for the main color.
  43861. * Comes from the BabylonJS CDN by default.
  43862. *
  43863. * Remarks: Can be either a texture or a url.
  43864. */
  43865. groundTexture: string | BaseTexture;
  43866. /**
  43867. * The color mixed in the ground texture by default.
  43868. * BabylonJS clearColor by default.
  43869. */
  43870. groundColor: Color3;
  43871. /**
  43872. * Specifies the ground opacity.
  43873. * 1 by default.
  43874. */
  43875. groundOpacity: number;
  43876. /**
  43877. * Enables the ground to receive shadows.
  43878. * True by default.
  43879. */
  43880. enableGroundShadow: boolean;
  43881. /**
  43882. * Helps preventing the shadow to be fully black on the ground.
  43883. * 0.5 by default.
  43884. */
  43885. groundShadowLevel: number;
  43886. /**
  43887. * Creates a mirror texture attach to the ground.
  43888. * false by default.
  43889. */
  43890. enableGroundMirror: boolean;
  43891. /**
  43892. * Specifies the ground mirror size ratio.
  43893. * 0.3 by default as the default kernel is 64.
  43894. */
  43895. groundMirrorSizeRatio: number;
  43896. /**
  43897. * Specifies the ground mirror blur kernel size.
  43898. * 64 by default.
  43899. */
  43900. groundMirrorBlurKernel: number;
  43901. /**
  43902. * Specifies the ground mirror visibility amount.
  43903. * 1 by default
  43904. */
  43905. groundMirrorAmount: number;
  43906. /**
  43907. * Specifies the ground mirror reflectance weight.
  43908. * This uses the standard weight of the background material to setup the fresnel effect
  43909. * of the mirror.
  43910. * 1 by default.
  43911. */
  43912. groundMirrorFresnelWeight: number;
  43913. /**
  43914. * Specifies the ground mirror Falloff distance.
  43915. * This can helps reducing the size of the reflection.
  43916. * 0 by Default.
  43917. */
  43918. groundMirrorFallOffDistance: number;
  43919. /**
  43920. * Specifies the ground mirror texture type.
  43921. * Unsigned Int by Default.
  43922. */
  43923. groundMirrorTextureType: number;
  43924. /**
  43925. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43926. * the shown objects.
  43927. */
  43928. groundYBias: number;
  43929. /**
  43930. * Specifies wether or not to create a skybox.
  43931. * True by default.
  43932. */
  43933. createSkybox: boolean;
  43934. /**
  43935. * Specifies the skybox size.
  43936. * 20 by default.
  43937. */
  43938. skyboxSize: number;
  43939. /**
  43940. * The texture used on the skybox for the main color.
  43941. * Comes from the BabylonJS CDN by default.
  43942. *
  43943. * Remarks: Can be either a texture or a url.
  43944. */
  43945. skyboxTexture: string | BaseTexture;
  43946. /**
  43947. * The color mixed in the skybox texture by default.
  43948. * BabylonJS clearColor by default.
  43949. */
  43950. skyboxColor: Color3;
  43951. /**
  43952. * The background rotation around the Y axis of the scene.
  43953. * This helps aligning the key lights of your scene with the background.
  43954. * 0 by default.
  43955. */
  43956. backgroundYRotation: number;
  43957. /**
  43958. * Compute automatically the size of the elements to best fit with the scene.
  43959. */
  43960. sizeAuto: boolean;
  43961. /**
  43962. * Default position of the rootMesh if autoSize is not true.
  43963. */
  43964. rootPosition: Vector3;
  43965. /**
  43966. * Sets up the image processing in the scene.
  43967. * true by default.
  43968. */
  43969. setupImageProcessing: boolean;
  43970. /**
  43971. * The texture used as your environment texture in the scene.
  43972. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43973. *
  43974. * Remarks: Can be either a texture or a url.
  43975. */
  43976. environmentTexture: string | BaseTexture;
  43977. /**
  43978. * The value of the exposure to apply to the scene.
  43979. * 0.6 by default if setupImageProcessing is true.
  43980. */
  43981. cameraExposure: number;
  43982. /**
  43983. * The value of the contrast to apply to the scene.
  43984. * 1.6 by default if setupImageProcessing is true.
  43985. */
  43986. cameraContrast: number;
  43987. /**
  43988. * Specifies wether or not tonemapping should be enabled in the scene.
  43989. * true by default if setupImageProcessing is true.
  43990. */
  43991. toneMappingEnabled: boolean;
  43992. }
  43993. /**
  43994. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43995. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43996. * It also helps with the default setup of your imageProcessing configuration.
  43997. */
  43998. export class EnvironmentHelper {
  43999. /**
  44000. * Default ground texture URL.
  44001. */
  44002. private static _groundTextureCDNUrl;
  44003. /**
  44004. * Default skybox texture URL.
  44005. */
  44006. private static _skyboxTextureCDNUrl;
  44007. /**
  44008. * Default environment texture URL.
  44009. */
  44010. private static _environmentTextureCDNUrl;
  44011. /**
  44012. * Creates the default options for the helper.
  44013. */
  44014. private static _getDefaultOptions;
  44015. private _rootMesh;
  44016. /**
  44017. * Gets the root mesh created by the helper.
  44018. */
  44019. readonly rootMesh: Mesh;
  44020. private _skybox;
  44021. /**
  44022. * Gets the skybox created by the helper.
  44023. */
  44024. readonly skybox: Nullable<Mesh>;
  44025. private _skyboxTexture;
  44026. /**
  44027. * Gets the skybox texture created by the helper.
  44028. */
  44029. readonly skyboxTexture: Nullable<BaseTexture>;
  44030. private _skyboxMaterial;
  44031. /**
  44032. * Gets the skybox material created by the helper.
  44033. */
  44034. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44035. private _ground;
  44036. /**
  44037. * Gets the ground mesh created by the helper.
  44038. */
  44039. readonly ground: Nullable<Mesh>;
  44040. private _groundTexture;
  44041. /**
  44042. * Gets the ground texture created by the helper.
  44043. */
  44044. readonly groundTexture: Nullable<BaseTexture>;
  44045. private _groundMirror;
  44046. /**
  44047. * Gets the ground mirror created by the helper.
  44048. */
  44049. readonly groundMirror: Nullable<MirrorTexture>;
  44050. /**
  44051. * Gets the ground mirror render list to helps pushing the meshes
  44052. * you wish in the ground reflection.
  44053. */
  44054. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44055. private _groundMaterial;
  44056. /**
  44057. * Gets the ground material created by the helper.
  44058. */
  44059. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44060. /**
  44061. * Stores the creation options.
  44062. */
  44063. private readonly _scene;
  44064. private _options;
  44065. /**
  44066. * This observable will be notified with any error during the creation of the environment,
  44067. * mainly texture creation errors.
  44068. */
  44069. onErrorObservable: Observable<{
  44070. message?: string;
  44071. exception?: any;
  44072. }>;
  44073. /**
  44074. * constructor
  44075. * @param options Defines the options we want to customize the helper
  44076. * @param scene The scene to add the material to
  44077. */
  44078. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44079. /**
  44080. * Updates the background according to the new options
  44081. * @param options
  44082. */
  44083. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44084. /**
  44085. * Sets the primary color of all the available elements.
  44086. * @param color the main color to affect to the ground and the background
  44087. */
  44088. setMainColor(color: Color3): void;
  44089. /**
  44090. * Setup the image processing according to the specified options.
  44091. */
  44092. private _setupImageProcessing;
  44093. /**
  44094. * Setup the environment texture according to the specified options.
  44095. */
  44096. private _setupEnvironmentTexture;
  44097. /**
  44098. * Setup the background according to the specified options.
  44099. */
  44100. private _setupBackground;
  44101. /**
  44102. * Get the scene sizes according to the setup.
  44103. */
  44104. private _getSceneSize;
  44105. /**
  44106. * Setup the ground according to the specified options.
  44107. */
  44108. private _setupGround;
  44109. /**
  44110. * Setup the ground material according to the specified options.
  44111. */
  44112. private _setupGroundMaterial;
  44113. /**
  44114. * Setup the ground diffuse texture according to the specified options.
  44115. */
  44116. private _setupGroundDiffuseTexture;
  44117. /**
  44118. * Setup the ground mirror texture according to the specified options.
  44119. */
  44120. private _setupGroundMirrorTexture;
  44121. /**
  44122. * Setup the ground to receive the mirror texture.
  44123. */
  44124. private _setupMirrorInGroundMaterial;
  44125. /**
  44126. * Setup the skybox according to the specified options.
  44127. */
  44128. private _setupSkybox;
  44129. /**
  44130. * Setup the skybox material according to the specified options.
  44131. */
  44132. private _setupSkyboxMaterial;
  44133. /**
  44134. * Setup the skybox reflection texture according to the specified options.
  44135. */
  44136. private _setupSkyboxReflectionTexture;
  44137. private _errorHandler;
  44138. /**
  44139. * Dispose all the elements created by the Helper.
  44140. */
  44141. dispose(): void;
  44142. }
  44143. }
  44144. declare module "babylonjs/Helpers/photoDome" {
  44145. import { Observable } from "babylonjs/Misc/observable";
  44146. import { Nullable } from "babylonjs/types";
  44147. import { Scene } from "babylonjs/scene";
  44148. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44149. import { Mesh } from "babylonjs/Meshes/mesh";
  44150. import { Texture } from "babylonjs/Materials/Textures/texture";
  44151. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44152. import "babylonjs/Meshes/Builders/sphereBuilder";
  44153. /**
  44154. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44155. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44156. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44157. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44158. */
  44159. export class PhotoDome extends TransformNode {
  44160. private _useDirectMapping;
  44161. /**
  44162. * The texture being displayed on the sphere
  44163. */
  44164. protected _photoTexture: Texture;
  44165. /**
  44166. * Gets or sets the texture being displayed on the sphere
  44167. */
  44168. photoTexture: Texture;
  44169. /**
  44170. * Observable raised when an error occured while loading the 360 image
  44171. */
  44172. onLoadErrorObservable: Observable<string>;
  44173. /**
  44174. * The skybox material
  44175. */
  44176. protected _material: BackgroundMaterial;
  44177. /**
  44178. * The surface used for the skybox
  44179. */
  44180. protected _mesh: Mesh;
  44181. /**
  44182. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44183. * Also see the options.resolution property.
  44184. */
  44185. fovMultiplier: number;
  44186. /**
  44187. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44188. * @param name Element's name, child elements will append suffixes for their own names.
  44189. * @param urlsOfPhoto defines the url of the photo to display
  44190. * @param options defines an object containing optional or exposed sub element properties
  44191. * @param onError defines a callback called when an error occured while loading the texture
  44192. */
  44193. constructor(name: string, urlOfPhoto: string, options: {
  44194. resolution?: number;
  44195. size?: number;
  44196. useDirectMapping?: boolean;
  44197. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44198. /**
  44199. * Releases resources associated with this node.
  44200. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44201. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44202. */
  44203. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44204. }
  44205. }
  44206. declare module "babylonjs/Misc/textureTools" {
  44207. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44208. import { Texture } from "babylonjs/Materials/Textures/texture";
  44209. import { Scene } from "babylonjs/scene";
  44210. /**
  44211. * Class used to host texture specific utilities
  44212. */
  44213. export class TextureTools {
  44214. /**
  44215. * Uses the GPU to create a copy texture rescaled at a given size
  44216. * @param texture Texture to copy from
  44217. * @param width defines the desired width
  44218. * @param height defines the desired height
  44219. * @param useBilinearMode defines if bilinear mode has to be used
  44220. * @return the generated texture
  44221. */
  44222. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44223. /**
  44224. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44225. * @param scene defines the hosting scene
  44226. * @returns the environment BRDF texture
  44227. */
  44228. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44229. private static _environmentBRDFBase64Texture;
  44230. }
  44231. }
  44232. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44233. import { Nullable } from "babylonjs/types";
  44234. import { IAnimatable } from "babylonjs/Misc/tools";
  44235. import { Color3 } from "babylonjs/Maths/math";
  44236. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44237. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44238. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44239. import { Engine } from "babylonjs/Engines/engine";
  44240. import { Scene } from "babylonjs/scene";
  44241. /**
  44242. * @hidden
  44243. */
  44244. export interface IMaterialClearCoatDefines {
  44245. CLEARCOAT: boolean;
  44246. CLEARCOAT_DEFAULTIOR: boolean;
  44247. CLEARCOAT_TEXTURE: boolean;
  44248. CLEARCOAT_TEXTUREDIRECTUV: number;
  44249. CLEARCOAT_BUMP: boolean;
  44250. CLEARCOAT_BUMPDIRECTUV: number;
  44251. CLEARCOAT_TINT: boolean;
  44252. CLEARCOAT_TINT_TEXTURE: boolean;
  44253. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44254. /** @hidden */
  44255. _areTexturesDirty: boolean;
  44256. }
  44257. /**
  44258. * Define the code related to the clear coat parameters of the pbr material.
  44259. */
  44260. export class PBRClearCoatConfiguration {
  44261. /**
  44262. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44263. * The default fits with a polyurethane material.
  44264. */
  44265. private static readonly _DefaultIndiceOfRefraction;
  44266. private _isEnabled;
  44267. /**
  44268. * Defines if the clear coat is enabled in the material.
  44269. */
  44270. isEnabled: boolean;
  44271. /**
  44272. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44273. */
  44274. intensity: number;
  44275. /**
  44276. * Defines the clear coat layer roughness.
  44277. */
  44278. roughness: number;
  44279. private _indiceOfRefraction;
  44280. /**
  44281. * Defines the indice of refraction of the clear coat.
  44282. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44283. * The default fits with a polyurethane material.
  44284. * Changing the default value is more performance intensive.
  44285. */
  44286. indiceOfRefraction: number;
  44287. private _texture;
  44288. /**
  44289. * Stores the clear coat values in a texture.
  44290. */
  44291. texture: Nullable<BaseTexture>;
  44292. private _bumpTexture;
  44293. /**
  44294. * Define the clear coat specific bump texture.
  44295. */
  44296. bumpTexture: Nullable<BaseTexture>;
  44297. private _isTintEnabled;
  44298. /**
  44299. * Defines if the clear coat tint is enabled in the material.
  44300. */
  44301. isTintEnabled: boolean;
  44302. /**
  44303. * Defines if the clear coat tint is enabled in the material.
  44304. * This is only use if tint is enabled
  44305. */
  44306. tintColor: Color3;
  44307. /**
  44308. * Defines if the distance at which the tint color should be found in the
  44309. * clear coat media.
  44310. * This is only use if tint is enabled
  44311. */
  44312. tintColorAtDistance: number;
  44313. /**
  44314. * Defines the clear coat layer thickness.
  44315. * This is only use if tint is enabled
  44316. */
  44317. tintThickness: number;
  44318. private _tintTexture;
  44319. /**
  44320. * Stores the clear tint values in a texture.
  44321. * rgb is tint
  44322. * a is a thickness factor
  44323. */
  44324. tintTexture: Nullable<BaseTexture>;
  44325. /** @hidden */
  44326. private _internalMarkAllSubMeshesAsTexturesDirty;
  44327. /** @hidden */
  44328. _markAllSubMeshesAsTexturesDirty(): void;
  44329. /**
  44330. * Instantiate a new istance of clear coat configuration.
  44331. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44332. */
  44333. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44334. /**
  44335. * Specifies that the submesh is ready to be used.
  44336. * @param defines the list of "defines" to update.
  44337. * @param scene defines the scene the material belongs to.
  44338. * @param engine defines the engine the material belongs to.
  44339. * @param disableBumpMap defines wether the material disables bump or not.
  44340. * @returns - boolean indicating that the submesh is ready or not.
  44341. */
  44342. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44343. /**
  44344. * Checks to see if a texture is used in the material.
  44345. * @param defines the list of "defines" to update.
  44346. * @param scene defines the scene to the material belongs to.
  44347. */
  44348. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44349. /**
  44350. * Binds the material data.
  44351. * @param uniformBuffer defines the Uniform buffer to fill in.
  44352. * @param scene defines the scene the material belongs to.
  44353. * @param engine defines the engine the material belongs to.
  44354. * @param disableBumpMap defines wether the material disables bump or not.
  44355. * @param isFrozen defines wether the material is frozen or not.
  44356. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44357. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44358. */
  44359. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44360. /**
  44361. * Checks to see if a texture is used in the material.
  44362. * @param texture - Base texture to use.
  44363. * @returns - Boolean specifying if a texture is used in the material.
  44364. */
  44365. hasTexture(texture: BaseTexture): boolean;
  44366. /**
  44367. * Returns an array of the actively used textures.
  44368. * @param activeTextures Array of BaseTextures
  44369. */
  44370. getActiveTextures(activeTextures: BaseTexture[]): void;
  44371. /**
  44372. * Returns the animatable textures.
  44373. * @param animatables Array of animatable textures.
  44374. */
  44375. getAnimatables(animatables: IAnimatable[]): void;
  44376. /**
  44377. * Disposes the resources of the material.
  44378. * @param forceDisposeTextures - Forces the disposal of all textures.
  44379. */
  44380. dispose(forceDisposeTextures?: boolean): void;
  44381. /**
  44382. * Get the current class name of the texture useful for serialization or dynamic coding.
  44383. * @returns "PBRClearCoatConfiguration"
  44384. */
  44385. getClassName(): string;
  44386. /**
  44387. * Makes a duplicate of the current configuration into another one.
  44388. * @param clearCoatConfiguration define the config where to copy the info
  44389. */
  44390. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44391. /**
  44392. * Serializes this clear coat configuration.
  44393. * @returns - An object with the serialized config.
  44394. */
  44395. serialize(): any;
  44396. /**
  44397. * Parses a Clear Coat Configuration from a serialized object.
  44398. * @param source - Serialized object.
  44399. */
  44400. parse(source: any): void;
  44401. /**
  44402. * Add fallbacks to the effect fallbacks list.
  44403. * @param defines defines the Base texture to use.
  44404. * @param fallbacks defines the current fallback list.
  44405. * @param currentRank defines the current fallback rank.
  44406. * @returns the new fallback rank.
  44407. */
  44408. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44409. /**
  44410. * Add the required uniforms to the current list.
  44411. * @param uniforms defines the current uniform list.
  44412. */
  44413. static AddUniforms(uniforms: string[]): void;
  44414. /**
  44415. * Add the required samplers to the current list.
  44416. * @param samplers defines the current sampler list.
  44417. */
  44418. static AddSamplers(samplers: string[]): void;
  44419. /**
  44420. * Add the required uniforms to the current buffer.
  44421. * @param uniformBuffer defines the current uniform buffer.
  44422. */
  44423. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44424. }
  44425. }
  44426. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44427. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44428. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44430. /**
  44431. * @hidden
  44432. */
  44433. export interface IMaterialAnisotropicDefines {
  44434. ANISOTROPIC: boolean;
  44435. MAINUV1: boolean;
  44436. _areMiscDirty: boolean;
  44437. _needUVs: boolean;
  44438. }
  44439. /**
  44440. * Define the code related to the anisotropic parameters of the pbr material.
  44441. */
  44442. export class PBRAnisotropicConfiguration {
  44443. private _isEnabled;
  44444. /**
  44445. * Defines if the anisotropy is enabled in the material.
  44446. */
  44447. isEnabled: boolean;
  44448. /**
  44449. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44450. */
  44451. intensity: number;
  44452. /**
  44453. * Defines if the effect is along the tangents or bitangents.
  44454. * By default, the effect is "strectching" the highlights along the tangents.
  44455. */
  44456. followTangents: boolean;
  44457. /** @hidden */
  44458. private _internalMarkAllSubMeshesAsMiscDirty;
  44459. /** @hidden */
  44460. _markAllSubMeshesAsMiscDirty(): void;
  44461. /**
  44462. * Instantiate a new istance of clear coat configuration.
  44463. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44464. */
  44465. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44466. /**
  44467. * Checks to see if a texture is used in the material.
  44468. * @param defines the list of "defines" to update.
  44469. * @param mesh the mesh we are preparing the defines for.
  44470. */
  44471. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  44472. /**
  44473. * Binds the material data.
  44474. * @param uniformBuffer defines the Uniform buffer to fill in.
  44475. * @param isFrozen defines wether the material is frozen or not.
  44476. */
  44477. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  44478. /**
  44479. * Get the current class name of the texture useful for serialization or dynamic coding.
  44480. * @returns "PBRAnisotropicConfiguration"
  44481. */
  44482. getClassName(): string;
  44483. /**
  44484. * Makes a duplicate of the current configuration into another one.
  44485. * @param anisotropicConfiguration define the config where to copy the info
  44486. */
  44487. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44488. /**
  44489. * Serializes this clear coat configuration.
  44490. * @returns - An object with the serialized config.
  44491. */
  44492. serialize(): any;
  44493. /**
  44494. * Parses a Clear Coat Configuration from a serialized object.
  44495. * @param source - Serialized object.
  44496. */
  44497. parse(source: any): void;
  44498. /**
  44499. * Add fallbacks to the effect fallbacks list.
  44500. * @param defines defines the Base texture to use.
  44501. * @param fallbacks defines the current fallback list.
  44502. * @param currentRank defines the current fallback rank.
  44503. * @returns the new fallback rank.
  44504. */
  44505. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44506. /**
  44507. * Add the required uniforms to the current list.
  44508. * @param uniforms defines the current uniform list.
  44509. */
  44510. static AddUniforms(uniforms: string[]): void;
  44511. /**
  44512. * Add the required uniforms to the current buffer.
  44513. * @param uniformBuffer defines the current uniform buffer.
  44514. */
  44515. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44516. }
  44517. }
  44518. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44519. /**
  44520. * @hidden
  44521. */
  44522. export interface IMaterialBRDFDefines {
  44523. BRDF_V_HEIGHT_CORRELATED: boolean;
  44524. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44525. /** @hidden */
  44526. _areMiscDirty: boolean;
  44527. }
  44528. /**
  44529. * Define the code related to the BRDF parameters of the pbr material.
  44530. */
  44531. export class PBRBRDFConfiguration {
  44532. private _useEnergyConservation;
  44533. /**
  44534. * Defines if the material uses energy conservation.
  44535. */
  44536. useEnergyConservation: boolean;
  44537. private _useSmithVisibilityHeightCorrelated;
  44538. /**
  44539. * LEGACY Mode set to false
  44540. * Defines if the material uses height smith correlated visibility term.
  44541. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44542. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44543. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44544. * Not relying on height correlated will also disable energy conservation.
  44545. */
  44546. useSmithVisibilityHeightCorrelated: boolean;
  44547. /** @hidden */
  44548. private _internalMarkAllSubMeshesAsMiscDirty;
  44549. /** @hidden */
  44550. _markAllSubMeshesAsMiscDirty(): void;
  44551. /**
  44552. * Instantiate a new istance of clear coat configuration.
  44553. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44554. */
  44555. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44556. /**
  44557. * Checks to see if a texture is used in the material.
  44558. * @param defines the list of "defines" to update.
  44559. */
  44560. prepareDefines(defines: IMaterialBRDFDefines): void;
  44561. /**
  44562. * Get the current class name of the texture useful for serialization or dynamic coding.
  44563. * @returns "PBRClearCoatConfiguration"
  44564. */
  44565. getClassName(): string;
  44566. /**
  44567. * Makes a duplicate of the current configuration into another one.
  44568. * @param brdfConfiguration define the config where to copy the info
  44569. */
  44570. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44571. /**
  44572. * Serializes this BRDF configuration.
  44573. * @returns - An object with the serialized config.
  44574. */
  44575. serialize(): any;
  44576. /**
  44577. * Parses a BRDF Configuration from a serialized object.
  44578. * @param source - Serialized object.
  44579. */
  44580. parse(source: any): void;
  44581. }
  44582. }
  44583. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44584. /** @hidden */
  44585. export var pbrFragmentDeclaration: {
  44586. name: string;
  44587. shader: string;
  44588. };
  44589. }
  44590. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44591. /** @hidden */
  44592. export var pbrUboDeclaration: {
  44593. name: string;
  44594. shader: string;
  44595. };
  44596. }
  44597. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44598. /** @hidden */
  44599. export var pbrFunctions: {
  44600. name: string;
  44601. shader: string;
  44602. };
  44603. }
  44604. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44605. /** @hidden */
  44606. export var harmonicsFunctions: {
  44607. name: string;
  44608. shader: string;
  44609. };
  44610. }
  44611. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44612. /** @hidden */
  44613. export var pbrPreLightingFunctions: {
  44614. name: string;
  44615. shader: string;
  44616. };
  44617. }
  44618. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44619. /** @hidden */
  44620. export var pbrFalloffLightingFunctions: {
  44621. name: string;
  44622. shader: string;
  44623. };
  44624. }
  44625. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44626. /** @hidden */
  44627. export var pbrLightingFunctions: {
  44628. name: string;
  44629. shader: string;
  44630. };
  44631. }
  44632. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  44633. /** @hidden */
  44634. export var pbrDebug: {
  44635. name: string;
  44636. shader: string;
  44637. };
  44638. }
  44639. declare module "babylonjs/Shaders/pbr.fragment" {
  44640. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44641. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44642. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44643. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44644. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44645. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44646. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44647. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44648. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44649. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44650. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44651. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44652. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44653. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44654. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44655. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44656. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44657. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44658. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44659. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44660. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44661. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44662. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44663. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44664. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  44665. /** @hidden */
  44666. export var pbrPixelShader: {
  44667. name: string;
  44668. shader: string;
  44669. };
  44670. }
  44671. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44672. /** @hidden */
  44673. export var pbrVertexDeclaration: {
  44674. name: string;
  44675. shader: string;
  44676. };
  44677. }
  44678. declare module "babylonjs/Shaders/pbr.vertex" {
  44679. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44680. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44681. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44682. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44683. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44684. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44685. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44686. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44687. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44688. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44689. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44690. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44691. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44692. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44693. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44694. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44695. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44696. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44697. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44698. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44699. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44700. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44701. /** @hidden */
  44702. export var pbrVertexShader: {
  44703. name: string;
  44704. shader: string;
  44705. };
  44706. }
  44707. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44708. import { IAnimatable } from "babylonjs/Misc/tools";
  44709. import { Nullable } from "babylonjs/types";
  44710. import { Scene } from "babylonjs/scene";
  44711. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44712. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44714. import { Mesh } from "babylonjs/Meshes/mesh";
  44715. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  44716. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  44717. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  44718. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44719. import { Material } from "babylonjs/Materials/material";
  44720. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44721. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44722. import "babylonjs/Shaders/pbr.fragment";
  44723. import "babylonjs/Shaders/pbr.vertex";
  44724. /**
  44725. * The Physically based material base class of BJS.
  44726. *
  44727. * This offers the main features of a standard PBR material.
  44728. * For more information, please refer to the documentation :
  44729. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44730. */
  44731. export abstract class PBRBaseMaterial extends PushMaterial {
  44732. /**
  44733. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44734. */
  44735. static readonly PBRMATERIAL_OPAQUE: number;
  44736. /**
  44737. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44738. */
  44739. static readonly PBRMATERIAL_ALPHATEST: number;
  44740. /**
  44741. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44742. */
  44743. static readonly PBRMATERIAL_ALPHABLEND: number;
  44744. /**
  44745. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44746. * They are also discarded below the alpha cutoff threshold to improve performances.
  44747. */
  44748. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44749. /**
  44750. * Defines the default value of how much AO map is occluding the analytical lights
  44751. * (point spot...).
  44752. */
  44753. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44754. /**
  44755. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44756. */
  44757. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44758. /**
  44759. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44760. * to enhance interoperability with other engines.
  44761. */
  44762. static readonly LIGHTFALLOFF_GLTF: number;
  44763. /**
  44764. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44765. * to enhance interoperability with other materials.
  44766. */
  44767. static readonly LIGHTFALLOFF_STANDARD: number;
  44768. /**
  44769. * Intensity of the direct lights e.g. the four lights available in your scene.
  44770. * This impacts both the direct diffuse and specular highlights.
  44771. */
  44772. protected _directIntensity: number;
  44773. /**
  44774. * Intensity of the emissive part of the material.
  44775. * This helps controlling the emissive effect without modifying the emissive color.
  44776. */
  44777. protected _emissiveIntensity: number;
  44778. /**
  44779. * Intensity of the environment e.g. how much the environment will light the object
  44780. * either through harmonics for rough material or through the refelction for shiny ones.
  44781. */
  44782. protected _environmentIntensity: number;
  44783. /**
  44784. * This is a special control allowing the reduction of the specular highlights coming from the
  44785. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44786. */
  44787. protected _specularIntensity: number;
  44788. /**
  44789. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44790. */
  44791. private _lightingInfos;
  44792. /**
  44793. * Debug Control allowing disabling the bump map on this material.
  44794. */
  44795. protected _disableBumpMap: boolean;
  44796. /**
  44797. * AKA Diffuse Texture in standard nomenclature.
  44798. */
  44799. protected _albedoTexture: BaseTexture;
  44800. /**
  44801. * AKA Occlusion Texture in other nomenclature.
  44802. */
  44803. protected _ambientTexture: BaseTexture;
  44804. /**
  44805. * AKA Occlusion Texture Intensity in other nomenclature.
  44806. */
  44807. protected _ambientTextureStrength: number;
  44808. /**
  44809. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44810. * 1 means it completely occludes it
  44811. * 0 mean it has no impact
  44812. */
  44813. protected _ambientTextureImpactOnAnalyticalLights: number;
  44814. /**
  44815. * Stores the alpha values in a texture.
  44816. */
  44817. protected _opacityTexture: BaseTexture;
  44818. /**
  44819. * Stores the reflection values in a texture.
  44820. */
  44821. protected _reflectionTexture: BaseTexture;
  44822. /**
  44823. * Stores the refraction values in a texture.
  44824. */
  44825. protected _refractionTexture: BaseTexture;
  44826. /**
  44827. * Stores the emissive values in a texture.
  44828. */
  44829. protected _emissiveTexture: BaseTexture;
  44830. /**
  44831. * AKA Specular texture in other nomenclature.
  44832. */
  44833. protected _reflectivityTexture: BaseTexture;
  44834. /**
  44835. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44836. */
  44837. protected _metallicTexture: BaseTexture;
  44838. /**
  44839. * Specifies the metallic scalar of the metallic/roughness workflow.
  44840. * Can also be used to scale the metalness values of the metallic texture.
  44841. */
  44842. protected _metallic: Nullable<number>;
  44843. /**
  44844. * Specifies the roughness scalar of the metallic/roughness workflow.
  44845. * Can also be used to scale the roughness values of the metallic texture.
  44846. */
  44847. protected _roughness: Nullable<number>;
  44848. /**
  44849. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44850. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44851. */
  44852. protected _microSurfaceTexture: BaseTexture;
  44853. /**
  44854. * Stores surface normal data used to displace a mesh in a texture.
  44855. */
  44856. protected _bumpTexture: BaseTexture;
  44857. /**
  44858. * Stores the pre-calculated light information of a mesh in a texture.
  44859. */
  44860. protected _lightmapTexture: BaseTexture;
  44861. /**
  44862. * The color of a material in ambient lighting.
  44863. */
  44864. protected _ambientColor: Color3;
  44865. /**
  44866. * AKA Diffuse Color in other nomenclature.
  44867. */
  44868. protected _albedoColor: Color3;
  44869. /**
  44870. * AKA Specular Color in other nomenclature.
  44871. */
  44872. protected _reflectivityColor: Color3;
  44873. /**
  44874. * The color applied when light is reflected from a material.
  44875. */
  44876. protected _reflectionColor: Color3;
  44877. /**
  44878. * The color applied when light is emitted from a material.
  44879. */
  44880. protected _emissiveColor: Color3;
  44881. /**
  44882. * AKA Glossiness in other nomenclature.
  44883. */
  44884. protected _microSurface: number;
  44885. /**
  44886. * source material index of refraction (IOR)' / 'destination material IOR.
  44887. */
  44888. protected _indexOfRefraction: number;
  44889. /**
  44890. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44891. */
  44892. protected _invertRefractionY: boolean;
  44893. /**
  44894. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44895. * Materials half opaque for instance using refraction could benefit from this control.
  44896. */
  44897. protected _linkRefractionWithTransparency: boolean;
  44898. /**
  44899. * Specifies that the material will use the light map as a show map.
  44900. */
  44901. protected _useLightmapAsShadowmap: boolean;
  44902. /**
  44903. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44904. * makes the reflect vector face the model (under horizon).
  44905. */
  44906. protected _useHorizonOcclusion: boolean;
  44907. /**
  44908. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44909. * too much the area relying on ambient texture to define their ambient occlusion.
  44910. */
  44911. protected _useRadianceOcclusion: boolean;
  44912. /**
  44913. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44914. */
  44915. protected _useAlphaFromAlbedoTexture: boolean;
  44916. /**
  44917. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44918. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44919. */
  44920. protected _useSpecularOverAlpha: boolean;
  44921. /**
  44922. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44923. */
  44924. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44925. /**
  44926. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44927. */
  44928. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44929. /**
  44930. * Specifies if the metallic texture contains the roughness information in its green channel.
  44931. */
  44932. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44933. /**
  44934. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44935. */
  44936. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44937. /**
  44938. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44939. */
  44940. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44941. /**
  44942. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44943. */
  44944. protected _useAmbientInGrayScale: boolean;
  44945. /**
  44946. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44947. * The material will try to infer what glossiness each pixel should be.
  44948. */
  44949. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44950. /**
  44951. * Defines the falloff type used in this material.
  44952. * It by default is Physical.
  44953. */
  44954. protected _lightFalloff: number;
  44955. /**
  44956. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44957. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44958. */
  44959. protected _useRadianceOverAlpha: boolean;
  44960. /**
  44961. * Allows using an object space normal map (instead of tangent space).
  44962. */
  44963. protected _useObjectSpaceNormalMap: boolean;
  44964. /**
  44965. * Allows using the bump map in parallax mode.
  44966. */
  44967. protected _useParallax: boolean;
  44968. /**
  44969. * Allows using the bump map in parallax occlusion mode.
  44970. */
  44971. protected _useParallaxOcclusion: boolean;
  44972. /**
  44973. * Controls the scale bias of the parallax mode.
  44974. */
  44975. protected _parallaxScaleBias: number;
  44976. /**
  44977. * If sets to true, disables all the lights affecting the material.
  44978. */
  44979. protected _disableLighting: boolean;
  44980. /**
  44981. * Number of Simultaneous lights allowed on the material.
  44982. */
  44983. protected _maxSimultaneousLights: number;
  44984. /**
  44985. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44986. */
  44987. protected _invertNormalMapX: boolean;
  44988. /**
  44989. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44990. */
  44991. protected _invertNormalMapY: boolean;
  44992. /**
  44993. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44994. */
  44995. protected _twoSidedLighting: boolean;
  44996. /**
  44997. * Defines the alpha limits in alpha test mode.
  44998. */
  44999. protected _alphaCutOff: number;
  45000. /**
  45001. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45002. */
  45003. protected _forceAlphaTest: boolean;
  45004. /**
  45005. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45006. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45007. */
  45008. protected _useAlphaFresnel: boolean;
  45009. /**
  45010. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45011. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45012. */
  45013. protected _useLinearAlphaFresnel: boolean;
  45014. /**
  45015. * The transparency mode of the material.
  45016. */
  45017. protected _transparencyMode: Nullable<number>;
  45018. /**
  45019. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45020. * from cos thetav and roughness:
  45021. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45022. */
  45023. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45024. /**
  45025. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45026. */
  45027. protected _forceIrradianceInFragment: boolean;
  45028. /**
  45029. * Force normal to face away from face.
  45030. */
  45031. protected _forceNormalForward: boolean;
  45032. /**
  45033. * Enables specular anti aliasing in the PBR shader.
  45034. * It will both interacts on the Geometry for analytical and IBL lighting.
  45035. * It also prefilter the roughness map based on the bump values.
  45036. */
  45037. protected _enableSpecularAntiAliasing: boolean;
  45038. /**
  45039. * Default configuration related to image processing available in the PBR Material.
  45040. */
  45041. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45042. /**
  45043. * Keep track of the image processing observer to allow dispose and replace.
  45044. */
  45045. private _imageProcessingObserver;
  45046. /**
  45047. * Attaches a new image processing configuration to the PBR Material.
  45048. * @param configuration
  45049. */
  45050. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45051. /**
  45052. * Stores the available render targets.
  45053. */
  45054. private _renderTargets;
  45055. /**
  45056. * Sets the global ambient color for the material used in lighting calculations.
  45057. */
  45058. private _globalAmbientColor;
  45059. /**
  45060. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45061. */
  45062. private _useLogarithmicDepth;
  45063. /**
  45064. * If set to true, no lighting calculations will be applied.
  45065. */
  45066. private _unlit;
  45067. private _debugMode;
  45068. /**
  45069. * @hidden
  45070. * This is reserved for the inspector.
  45071. * Defines the material debug mode.
  45072. * It helps seeing only some components of the material while troubleshooting.
  45073. */
  45074. debugMode: number;
  45075. /**
  45076. * @hidden
  45077. * This is reserved for the inspector.
  45078. * Specify from where on screen the debug mode should start.
  45079. * The value goes from -1 (full screen) to 1 (not visible)
  45080. * It helps with side by side comparison against the final render
  45081. * This defaults to -1
  45082. */
  45083. private debugLimit;
  45084. /**
  45085. * @hidden
  45086. * This is reserved for the inspector.
  45087. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45088. * You can use the factor to better multiply the final value.
  45089. */
  45090. private debugFactor;
  45091. /**
  45092. * Defines the clear coat layer parameters for the material.
  45093. */
  45094. readonly clearCoat: PBRClearCoatConfiguration;
  45095. /**
  45096. * Defines the anisotropic parameters for the material.
  45097. */
  45098. readonly anisotropy: PBRAnisotropicConfiguration;
  45099. /**
  45100. * Defines the BRDF parameters for the material.
  45101. */
  45102. readonly brdf: PBRBRDFConfiguration;
  45103. /**
  45104. * Instantiates a new PBRMaterial instance.
  45105. *
  45106. * @param name The material name
  45107. * @param scene The scene the material will be use in.
  45108. */
  45109. constructor(name: string, scene: Scene);
  45110. /**
  45111. * Gets a boolean indicating that current material needs to register RTT
  45112. */
  45113. readonly hasRenderTargetTextures: boolean;
  45114. /**
  45115. * Gets the name of the material class.
  45116. */
  45117. getClassName(): string;
  45118. /**
  45119. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45120. */
  45121. /**
  45122. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45123. */
  45124. useLogarithmicDepth: boolean;
  45125. /**
  45126. * Gets the current transparency mode.
  45127. */
  45128. /**
  45129. * Sets the transparency mode of the material.
  45130. *
  45131. * | Value | Type | Description |
  45132. * | ----- | ----------------------------------- | ----------- |
  45133. * | 0 | OPAQUE | |
  45134. * | 1 | ALPHATEST | |
  45135. * | 2 | ALPHABLEND | |
  45136. * | 3 | ALPHATESTANDBLEND | |
  45137. *
  45138. */
  45139. transparencyMode: Nullable<number>;
  45140. /**
  45141. * Returns true if alpha blending should be disabled.
  45142. */
  45143. private readonly _disableAlphaBlending;
  45144. /**
  45145. * Specifies whether or not this material should be rendered in alpha blend mode.
  45146. */
  45147. needAlphaBlending(): boolean;
  45148. /**
  45149. * Specifies if the mesh will require alpha blending.
  45150. * @param mesh - BJS mesh.
  45151. */
  45152. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45153. /**
  45154. * Specifies whether or not this material should be rendered in alpha test mode.
  45155. */
  45156. needAlphaTesting(): boolean;
  45157. /**
  45158. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45159. */
  45160. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45161. /**
  45162. * Gets the texture used for the alpha test.
  45163. */
  45164. getAlphaTestTexture(): BaseTexture;
  45165. /**
  45166. * Specifies that the submesh is ready to be used.
  45167. * @param mesh - BJS mesh.
  45168. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45169. * @param useInstances - Specifies that instances should be used.
  45170. * @returns - boolean indicating that the submesh is ready or not.
  45171. */
  45172. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45173. /**
  45174. * Specifies if the material uses metallic roughness workflow.
  45175. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45176. */
  45177. isMetallicWorkflow(): boolean;
  45178. private _prepareEffect;
  45179. private _prepareDefines;
  45180. /**
  45181. * Force shader compilation
  45182. */
  45183. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45184. clipPlane: boolean;
  45185. }>): void;
  45186. /**
  45187. * Initializes the uniform buffer layout for the shader.
  45188. */
  45189. buildUniformLayout(): void;
  45190. /**
  45191. * Unbinds the textures.
  45192. */
  45193. unbind(): void;
  45194. /**
  45195. * Binds the submesh data.
  45196. * @param world - The world matrix.
  45197. * @param mesh - The BJS mesh.
  45198. * @param subMesh - A submesh of the BJS mesh.
  45199. */
  45200. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45201. /**
  45202. * Returns the animatable textures.
  45203. * @returns - Array of animatable textures.
  45204. */
  45205. getAnimatables(): IAnimatable[];
  45206. /**
  45207. * Returns the texture used for reflections.
  45208. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45209. */
  45210. private _getReflectionTexture;
  45211. /**
  45212. * Returns the texture used for refraction or null if none is used.
  45213. * @returns - Refection texture if present. If no refraction texture and refraction
  45214. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45215. */
  45216. private _getRefractionTexture;
  45217. /**
  45218. * Returns an array of the actively used textures.
  45219. * @returns - Array of BaseTextures
  45220. */
  45221. getActiveTextures(): BaseTexture[];
  45222. /**
  45223. * Checks to see if a texture is used in the material.
  45224. * @param texture - Base texture to use.
  45225. * @returns - Boolean specifying if a texture is used in the material.
  45226. */
  45227. hasTexture(texture: BaseTexture): boolean;
  45228. /**
  45229. * Disposes the resources of the material.
  45230. * @param forceDisposeEffect - Forces the disposal of effects.
  45231. * @param forceDisposeTextures - Forces the disposal of all textures.
  45232. */
  45233. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45234. }
  45235. }
  45236. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45237. import { Nullable } from "babylonjs/types";
  45238. import { Scene } from "babylonjs/scene";
  45239. import { Color3 } from "babylonjs/Maths/math";
  45240. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45241. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45242. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45243. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45244. /**
  45245. * The Physically based material of BJS.
  45246. *
  45247. * This offers the main features of a standard PBR material.
  45248. * For more information, please refer to the documentation :
  45249. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45250. */
  45251. export class PBRMaterial extends PBRBaseMaterial {
  45252. /**
  45253. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45254. */
  45255. static readonly PBRMATERIAL_OPAQUE: number;
  45256. /**
  45257. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45258. */
  45259. static readonly PBRMATERIAL_ALPHATEST: number;
  45260. /**
  45261. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45262. */
  45263. static readonly PBRMATERIAL_ALPHABLEND: number;
  45264. /**
  45265. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45266. * They are also discarded below the alpha cutoff threshold to improve performances.
  45267. */
  45268. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45269. /**
  45270. * Defines the default value of how much AO map is occluding the analytical lights
  45271. * (point spot...).
  45272. */
  45273. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45274. /**
  45275. * Intensity of the direct lights e.g. the four lights available in your scene.
  45276. * This impacts both the direct diffuse and specular highlights.
  45277. */
  45278. directIntensity: number;
  45279. /**
  45280. * Intensity of the emissive part of the material.
  45281. * This helps controlling the emissive effect without modifying the emissive color.
  45282. */
  45283. emissiveIntensity: number;
  45284. /**
  45285. * Intensity of the environment e.g. how much the environment will light the object
  45286. * either through harmonics for rough material or through the refelction for shiny ones.
  45287. */
  45288. environmentIntensity: number;
  45289. /**
  45290. * This is a special control allowing the reduction of the specular highlights coming from the
  45291. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45292. */
  45293. specularIntensity: number;
  45294. /**
  45295. * Debug Control allowing disabling the bump map on this material.
  45296. */
  45297. disableBumpMap: boolean;
  45298. /**
  45299. * AKA Diffuse Texture in standard nomenclature.
  45300. */
  45301. albedoTexture: BaseTexture;
  45302. /**
  45303. * AKA Occlusion Texture in other nomenclature.
  45304. */
  45305. ambientTexture: BaseTexture;
  45306. /**
  45307. * AKA Occlusion Texture Intensity in other nomenclature.
  45308. */
  45309. ambientTextureStrength: number;
  45310. /**
  45311. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45312. * 1 means it completely occludes it
  45313. * 0 mean it has no impact
  45314. */
  45315. ambientTextureImpactOnAnalyticalLights: number;
  45316. /**
  45317. * Stores the alpha values in a texture.
  45318. */
  45319. opacityTexture: BaseTexture;
  45320. /**
  45321. * Stores the reflection values in a texture.
  45322. */
  45323. reflectionTexture: Nullable<BaseTexture>;
  45324. /**
  45325. * Stores the emissive values in a texture.
  45326. */
  45327. emissiveTexture: BaseTexture;
  45328. /**
  45329. * AKA Specular texture in other nomenclature.
  45330. */
  45331. reflectivityTexture: BaseTexture;
  45332. /**
  45333. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45334. */
  45335. metallicTexture: BaseTexture;
  45336. /**
  45337. * Specifies the metallic scalar of the metallic/roughness workflow.
  45338. * Can also be used to scale the metalness values of the metallic texture.
  45339. */
  45340. metallic: Nullable<number>;
  45341. /**
  45342. * Specifies the roughness scalar of the metallic/roughness workflow.
  45343. * Can also be used to scale the roughness values of the metallic texture.
  45344. */
  45345. roughness: Nullable<number>;
  45346. /**
  45347. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45348. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45349. */
  45350. microSurfaceTexture: BaseTexture;
  45351. /**
  45352. * Stores surface normal data used to displace a mesh in a texture.
  45353. */
  45354. bumpTexture: BaseTexture;
  45355. /**
  45356. * Stores the pre-calculated light information of a mesh in a texture.
  45357. */
  45358. lightmapTexture: BaseTexture;
  45359. /**
  45360. * Stores the refracted light information in a texture.
  45361. */
  45362. refractionTexture: BaseTexture;
  45363. /**
  45364. * The color of a material in ambient lighting.
  45365. */
  45366. ambientColor: Color3;
  45367. /**
  45368. * AKA Diffuse Color in other nomenclature.
  45369. */
  45370. albedoColor: Color3;
  45371. /**
  45372. * AKA Specular Color in other nomenclature.
  45373. */
  45374. reflectivityColor: Color3;
  45375. /**
  45376. * The color reflected from the material.
  45377. */
  45378. reflectionColor: Color3;
  45379. /**
  45380. * The color emitted from the material.
  45381. */
  45382. emissiveColor: Color3;
  45383. /**
  45384. * AKA Glossiness in other nomenclature.
  45385. */
  45386. microSurface: number;
  45387. /**
  45388. * source material index of refraction (IOR)' / 'destination material IOR.
  45389. */
  45390. indexOfRefraction: number;
  45391. /**
  45392. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45393. */
  45394. invertRefractionY: boolean;
  45395. /**
  45396. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45397. * Materials half opaque for instance using refraction could benefit from this control.
  45398. */
  45399. linkRefractionWithTransparency: boolean;
  45400. /**
  45401. * If true, the light map contains occlusion information instead of lighting info.
  45402. */
  45403. useLightmapAsShadowmap: boolean;
  45404. /**
  45405. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45406. */
  45407. useAlphaFromAlbedoTexture: boolean;
  45408. /**
  45409. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45410. */
  45411. forceAlphaTest: boolean;
  45412. /**
  45413. * Defines the alpha limits in alpha test mode.
  45414. */
  45415. alphaCutOff: number;
  45416. /**
  45417. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45418. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45419. */
  45420. useSpecularOverAlpha: boolean;
  45421. /**
  45422. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45423. */
  45424. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45425. /**
  45426. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45427. */
  45428. useRoughnessFromMetallicTextureAlpha: boolean;
  45429. /**
  45430. * Specifies if the metallic texture contains the roughness information in its green channel.
  45431. */
  45432. useRoughnessFromMetallicTextureGreen: boolean;
  45433. /**
  45434. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45435. */
  45436. useMetallnessFromMetallicTextureBlue: boolean;
  45437. /**
  45438. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45439. */
  45440. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45441. /**
  45442. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45443. */
  45444. useAmbientInGrayScale: boolean;
  45445. /**
  45446. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45447. * The material will try to infer what glossiness each pixel should be.
  45448. */
  45449. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45450. /**
  45451. * BJS is using an harcoded light falloff based on a manually sets up range.
  45452. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45453. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45454. */
  45455. /**
  45456. * BJS is using an harcoded light falloff based on a manually sets up range.
  45457. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45458. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45459. */
  45460. usePhysicalLightFalloff: boolean;
  45461. /**
  45462. * In order to support the falloff compatibility with gltf, a special mode has been added
  45463. * to reproduce the gltf light falloff.
  45464. */
  45465. /**
  45466. * In order to support the falloff compatibility with gltf, a special mode has been added
  45467. * to reproduce the gltf light falloff.
  45468. */
  45469. useGLTFLightFalloff: boolean;
  45470. /**
  45471. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45472. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45473. */
  45474. useRadianceOverAlpha: boolean;
  45475. /**
  45476. * Allows using an object space normal map (instead of tangent space).
  45477. */
  45478. useObjectSpaceNormalMap: boolean;
  45479. /**
  45480. * Allows using the bump map in parallax mode.
  45481. */
  45482. useParallax: boolean;
  45483. /**
  45484. * Allows using the bump map in parallax occlusion mode.
  45485. */
  45486. useParallaxOcclusion: boolean;
  45487. /**
  45488. * Controls the scale bias of the parallax mode.
  45489. */
  45490. parallaxScaleBias: number;
  45491. /**
  45492. * If sets to true, disables all the lights affecting the material.
  45493. */
  45494. disableLighting: boolean;
  45495. /**
  45496. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45497. */
  45498. forceIrradianceInFragment: boolean;
  45499. /**
  45500. * Number of Simultaneous lights allowed on the material.
  45501. */
  45502. maxSimultaneousLights: number;
  45503. /**
  45504. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45505. */
  45506. invertNormalMapX: boolean;
  45507. /**
  45508. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45509. */
  45510. invertNormalMapY: boolean;
  45511. /**
  45512. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45513. */
  45514. twoSidedLighting: boolean;
  45515. /**
  45516. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45517. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45518. */
  45519. useAlphaFresnel: boolean;
  45520. /**
  45521. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45522. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45523. */
  45524. useLinearAlphaFresnel: boolean;
  45525. /**
  45526. * Let user defines the brdf lookup texture used for IBL.
  45527. * A default 8bit version is embedded but you could point at :
  45528. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45529. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45530. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45531. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45532. */
  45533. environmentBRDFTexture: Nullable<BaseTexture>;
  45534. /**
  45535. * Force normal to face away from face.
  45536. */
  45537. forceNormalForward: boolean;
  45538. /**
  45539. * Enables specular anti aliasing in the PBR shader.
  45540. * It will both interacts on the Geometry for analytical and IBL lighting.
  45541. * It also prefilter the roughness map based on the bump values.
  45542. */
  45543. enableSpecularAntiAliasing: boolean;
  45544. /**
  45545. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45546. * makes the reflect vector face the model (under horizon).
  45547. */
  45548. useHorizonOcclusion: boolean;
  45549. /**
  45550. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45551. * too much the area relying on ambient texture to define their ambient occlusion.
  45552. */
  45553. useRadianceOcclusion: boolean;
  45554. /**
  45555. * If set to true, no lighting calculations will be applied.
  45556. */
  45557. unlit: boolean;
  45558. /**
  45559. * Gets the image processing configuration used either in this material.
  45560. */
  45561. /**
  45562. * Sets the Default image processing configuration used either in the this material.
  45563. *
  45564. * If sets to null, the scene one is in use.
  45565. */
  45566. imageProcessingConfiguration: ImageProcessingConfiguration;
  45567. /**
  45568. * Gets wether the color curves effect is enabled.
  45569. */
  45570. /**
  45571. * Sets wether the color curves effect is enabled.
  45572. */
  45573. cameraColorCurvesEnabled: boolean;
  45574. /**
  45575. * Gets wether the color grading effect is enabled.
  45576. */
  45577. /**
  45578. * Gets wether the color grading effect is enabled.
  45579. */
  45580. cameraColorGradingEnabled: boolean;
  45581. /**
  45582. * Gets wether tonemapping is enabled or not.
  45583. */
  45584. /**
  45585. * Sets wether tonemapping is enabled or not
  45586. */
  45587. cameraToneMappingEnabled: boolean;
  45588. /**
  45589. * The camera exposure used on this material.
  45590. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45591. * This corresponds to a photographic exposure.
  45592. */
  45593. /**
  45594. * The camera exposure used on this material.
  45595. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45596. * This corresponds to a photographic exposure.
  45597. */
  45598. cameraExposure: number;
  45599. /**
  45600. * Gets The camera contrast used on this material.
  45601. */
  45602. /**
  45603. * Sets The camera contrast used on this material.
  45604. */
  45605. cameraContrast: number;
  45606. /**
  45607. * Gets the Color Grading 2D Lookup Texture.
  45608. */
  45609. /**
  45610. * Sets the Color Grading 2D Lookup Texture.
  45611. */
  45612. cameraColorGradingTexture: Nullable<BaseTexture>;
  45613. /**
  45614. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45615. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45616. * 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;
  45617. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45618. */
  45619. /**
  45620. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45621. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45622. * 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;
  45623. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45624. */
  45625. cameraColorCurves: Nullable<ColorCurves>;
  45626. /**
  45627. * Instantiates a new PBRMaterial instance.
  45628. *
  45629. * @param name The material name
  45630. * @param scene The scene the material will be use in.
  45631. */
  45632. constructor(name: string, scene: Scene);
  45633. /**
  45634. * Returns the name of this material class.
  45635. */
  45636. getClassName(): string;
  45637. /**
  45638. * Makes a duplicate of the current material.
  45639. * @param name - name to use for the new material.
  45640. */
  45641. clone(name: string): PBRMaterial;
  45642. /**
  45643. * Serializes this PBR Material.
  45644. * @returns - An object with the serialized material.
  45645. */
  45646. serialize(): any;
  45647. /**
  45648. * Parses a PBR Material from a serialized object.
  45649. * @param source - Serialized object.
  45650. * @param scene - BJS scene instance.
  45651. * @param rootUrl - url for the scene object
  45652. * @returns - PBRMaterial
  45653. */
  45654. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45655. }
  45656. }
  45657. declare module "babylonjs/Helpers/sceneHelpers" {
  45658. import { Nullable } from "babylonjs/types";
  45659. import { Mesh } from "babylonjs/Meshes/mesh";
  45660. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45661. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  45662. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45663. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  45664. import "babylonjs/Meshes/Builders/boxBuilder";
  45665. /** @hidden */
  45666. export var _forceSceneHelpersToBundle: boolean;
  45667. module "babylonjs/scene" {
  45668. interface Scene {
  45669. /**
  45670. * Creates a default light for the scene.
  45671. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45672. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45673. */
  45674. createDefaultLight(replace?: boolean): void;
  45675. /**
  45676. * Creates a default camera for the scene.
  45677. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45678. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45679. * @param replace has default false, when true replaces the active camera in the scene
  45680. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45681. */
  45682. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45683. /**
  45684. * Creates a default camera and a default light.
  45685. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45686. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45687. * @param replace has the default false, when true replaces the active camera/light in the scene
  45688. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45689. */
  45690. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45691. /**
  45692. * Creates a new sky box
  45693. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45694. * @param environmentTexture defines the texture to use as environment texture
  45695. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45696. * @param scale defines the overall scale of the skybox
  45697. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45698. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45699. * @returns a new mesh holding the sky box
  45700. */
  45701. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45702. /**
  45703. * Creates a new environment
  45704. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45705. * @param options defines the options you can use to configure the environment
  45706. * @returns the new EnvironmentHelper
  45707. */
  45708. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45709. /**
  45710. * Creates a new VREXperienceHelper
  45711. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45712. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45713. * @returns a new VREXperienceHelper
  45714. */
  45715. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45716. /**
  45717. * Creates a new XREXperienceHelper
  45718. * @see http://doc.babylonjs.com/how_to/webxr
  45719. * @returns a promise for a new XREXperienceHelper
  45720. */
  45721. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45722. }
  45723. }
  45724. }
  45725. declare module "babylonjs/Helpers/videoDome" {
  45726. import { Scene } from "babylonjs/scene";
  45727. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45728. import { Mesh } from "babylonjs/Meshes/mesh";
  45729. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  45730. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45731. import "babylonjs/Meshes/Builders/sphereBuilder";
  45732. /**
  45733. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45734. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45735. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45736. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45737. */
  45738. export class VideoDome extends TransformNode {
  45739. /**
  45740. * Define the video source as a Monoscopic panoramic 360 video.
  45741. */
  45742. static readonly MODE_MONOSCOPIC: number;
  45743. /**
  45744. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45745. */
  45746. static readonly MODE_TOPBOTTOM: number;
  45747. /**
  45748. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45749. */
  45750. static readonly MODE_SIDEBYSIDE: number;
  45751. private _useDirectMapping;
  45752. /**
  45753. * The video texture being displayed on the sphere
  45754. */
  45755. protected _videoTexture: VideoTexture;
  45756. /**
  45757. * Gets the video texture being displayed on the sphere
  45758. */
  45759. readonly videoTexture: VideoTexture;
  45760. /**
  45761. * The skybox material
  45762. */
  45763. protected _material: BackgroundMaterial;
  45764. /**
  45765. * The surface used for the skybox
  45766. */
  45767. protected _mesh: Mesh;
  45768. /**
  45769. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45770. * Also see the options.resolution property.
  45771. */
  45772. fovMultiplier: number;
  45773. private _videoMode;
  45774. /**
  45775. * Gets or set the current video mode for the video. It can be:
  45776. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45777. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45778. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45779. */
  45780. videoMode: number;
  45781. /**
  45782. * Oberserver used in Stereoscopic VR Mode.
  45783. */
  45784. private _onBeforeCameraRenderObserver;
  45785. /**
  45786. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45787. * @param name Element's name, child elements will append suffixes for their own names.
  45788. * @param urlsOrVideo defines the url(s) or the video element to use
  45789. * @param options An object containing optional or exposed sub element properties
  45790. */
  45791. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45792. resolution?: number;
  45793. clickToPlay?: boolean;
  45794. autoPlay?: boolean;
  45795. loop?: boolean;
  45796. size?: number;
  45797. poster?: string;
  45798. useDirectMapping?: boolean;
  45799. }, scene: Scene);
  45800. private _changeVideoMode;
  45801. /**
  45802. * Releases resources associated with this node.
  45803. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45804. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45805. */
  45806. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45807. }
  45808. }
  45809. declare module "babylonjs/Helpers/index" {
  45810. export * from "babylonjs/Helpers/environmentHelper";
  45811. export * from "babylonjs/Helpers/photoDome";
  45812. export * from "babylonjs/Helpers/sceneHelpers";
  45813. export * from "babylonjs/Helpers/videoDome";
  45814. }
  45815. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  45816. import { PerfCounter } from "babylonjs/Misc/tools";
  45817. import { IDisposable } from "babylonjs/scene";
  45818. import { Engine } from "babylonjs/Engines/engine";
  45819. /**
  45820. * This class can be used to get instrumentation data from a Babylon engine
  45821. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45822. */
  45823. export class EngineInstrumentation implements IDisposable {
  45824. /**
  45825. * Define the instrumented engine.
  45826. */
  45827. engine: Engine;
  45828. private _captureGPUFrameTime;
  45829. private _gpuFrameTimeToken;
  45830. private _gpuFrameTime;
  45831. private _captureShaderCompilationTime;
  45832. private _shaderCompilationTime;
  45833. private _onBeginFrameObserver;
  45834. private _onEndFrameObserver;
  45835. private _onBeforeShaderCompilationObserver;
  45836. private _onAfterShaderCompilationObserver;
  45837. /**
  45838. * Gets the perf counter used for GPU frame time
  45839. */
  45840. readonly gpuFrameTimeCounter: PerfCounter;
  45841. /**
  45842. * Gets the GPU frame time capture status
  45843. */
  45844. /**
  45845. * Enable or disable the GPU frame time capture
  45846. */
  45847. captureGPUFrameTime: boolean;
  45848. /**
  45849. * Gets the perf counter used for shader compilation time
  45850. */
  45851. readonly shaderCompilationTimeCounter: PerfCounter;
  45852. /**
  45853. * Gets the shader compilation time capture status
  45854. */
  45855. /**
  45856. * Enable or disable the shader compilation time capture
  45857. */
  45858. captureShaderCompilationTime: boolean;
  45859. /**
  45860. * Instantiates a new engine instrumentation.
  45861. * This class can be used to get instrumentation data from a Babylon engine
  45862. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45863. * @param engine Defines the engine to instrument
  45864. */
  45865. constructor(
  45866. /**
  45867. * Define the instrumented engine.
  45868. */
  45869. engine: Engine);
  45870. /**
  45871. * Dispose and release associated resources.
  45872. */
  45873. dispose(): void;
  45874. }
  45875. }
  45876. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45877. import { PerfCounter } from "babylonjs/Misc/tools";
  45878. import { Scene, IDisposable } from "babylonjs/scene";
  45879. /**
  45880. * This class can be used to get instrumentation data from a Babylon engine
  45881. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45882. */
  45883. export class SceneInstrumentation implements IDisposable {
  45884. /**
  45885. * Defines the scene to instrument
  45886. */
  45887. scene: Scene;
  45888. private _captureActiveMeshesEvaluationTime;
  45889. private _activeMeshesEvaluationTime;
  45890. private _captureRenderTargetsRenderTime;
  45891. private _renderTargetsRenderTime;
  45892. private _captureFrameTime;
  45893. private _frameTime;
  45894. private _captureRenderTime;
  45895. private _renderTime;
  45896. private _captureInterFrameTime;
  45897. private _interFrameTime;
  45898. private _captureParticlesRenderTime;
  45899. private _particlesRenderTime;
  45900. private _captureSpritesRenderTime;
  45901. private _spritesRenderTime;
  45902. private _capturePhysicsTime;
  45903. private _physicsTime;
  45904. private _captureAnimationsTime;
  45905. private _animationsTime;
  45906. private _captureCameraRenderTime;
  45907. private _cameraRenderTime;
  45908. private _onBeforeActiveMeshesEvaluationObserver;
  45909. private _onAfterActiveMeshesEvaluationObserver;
  45910. private _onBeforeRenderTargetsRenderObserver;
  45911. private _onAfterRenderTargetsRenderObserver;
  45912. private _onAfterRenderObserver;
  45913. private _onBeforeDrawPhaseObserver;
  45914. private _onAfterDrawPhaseObserver;
  45915. private _onBeforeAnimationsObserver;
  45916. private _onBeforeParticlesRenderingObserver;
  45917. private _onAfterParticlesRenderingObserver;
  45918. private _onBeforeSpritesRenderingObserver;
  45919. private _onAfterSpritesRenderingObserver;
  45920. private _onBeforePhysicsObserver;
  45921. private _onAfterPhysicsObserver;
  45922. private _onAfterAnimationsObserver;
  45923. private _onBeforeCameraRenderObserver;
  45924. private _onAfterCameraRenderObserver;
  45925. /**
  45926. * Gets the perf counter used for active meshes evaluation time
  45927. */
  45928. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45929. /**
  45930. * Gets the active meshes evaluation time capture status
  45931. */
  45932. /**
  45933. * Enable or disable the active meshes evaluation time capture
  45934. */
  45935. captureActiveMeshesEvaluationTime: boolean;
  45936. /**
  45937. * Gets the perf counter used for render targets render time
  45938. */
  45939. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45940. /**
  45941. * Gets the render targets render time capture status
  45942. */
  45943. /**
  45944. * Enable or disable the render targets render time capture
  45945. */
  45946. captureRenderTargetsRenderTime: boolean;
  45947. /**
  45948. * Gets the perf counter used for particles render time
  45949. */
  45950. readonly particlesRenderTimeCounter: PerfCounter;
  45951. /**
  45952. * Gets the particles render time capture status
  45953. */
  45954. /**
  45955. * Enable or disable the particles render time capture
  45956. */
  45957. captureParticlesRenderTime: boolean;
  45958. /**
  45959. * Gets the perf counter used for sprites render time
  45960. */
  45961. readonly spritesRenderTimeCounter: PerfCounter;
  45962. /**
  45963. * Gets the sprites render time capture status
  45964. */
  45965. /**
  45966. * Enable or disable the sprites render time capture
  45967. */
  45968. captureSpritesRenderTime: boolean;
  45969. /**
  45970. * Gets the perf counter used for physics time
  45971. */
  45972. readonly physicsTimeCounter: PerfCounter;
  45973. /**
  45974. * Gets the physics time capture status
  45975. */
  45976. /**
  45977. * Enable or disable the physics time capture
  45978. */
  45979. capturePhysicsTime: boolean;
  45980. /**
  45981. * Gets the perf counter used for animations time
  45982. */
  45983. readonly animationsTimeCounter: PerfCounter;
  45984. /**
  45985. * Gets the animations time capture status
  45986. */
  45987. /**
  45988. * Enable or disable the animations time capture
  45989. */
  45990. captureAnimationsTime: boolean;
  45991. /**
  45992. * Gets the perf counter used for frame time capture
  45993. */
  45994. readonly frameTimeCounter: PerfCounter;
  45995. /**
  45996. * Gets the frame time capture status
  45997. */
  45998. /**
  45999. * Enable or disable the frame time capture
  46000. */
  46001. captureFrameTime: boolean;
  46002. /**
  46003. * Gets the perf counter used for inter-frames time capture
  46004. */
  46005. readonly interFrameTimeCounter: PerfCounter;
  46006. /**
  46007. * Gets the inter-frames time capture status
  46008. */
  46009. /**
  46010. * Enable or disable the inter-frames time capture
  46011. */
  46012. captureInterFrameTime: boolean;
  46013. /**
  46014. * Gets the perf counter used for render time capture
  46015. */
  46016. readonly renderTimeCounter: PerfCounter;
  46017. /**
  46018. * Gets the render time capture status
  46019. */
  46020. /**
  46021. * Enable or disable the render time capture
  46022. */
  46023. captureRenderTime: boolean;
  46024. /**
  46025. * Gets the perf counter used for camera render time capture
  46026. */
  46027. readonly cameraRenderTimeCounter: PerfCounter;
  46028. /**
  46029. * Gets the camera render time capture status
  46030. */
  46031. /**
  46032. * Enable or disable the camera render time capture
  46033. */
  46034. captureCameraRenderTime: boolean;
  46035. /**
  46036. * Gets the perf counter used for draw calls
  46037. */
  46038. readonly drawCallsCounter: PerfCounter;
  46039. /**
  46040. * Gets the perf counter used for texture collisions
  46041. */
  46042. readonly textureCollisionsCounter: PerfCounter;
  46043. /**
  46044. * Instantiates a new scene instrumentation.
  46045. * This class can be used to get instrumentation data from a Babylon engine
  46046. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46047. * @param scene Defines the scene to instrument
  46048. */
  46049. constructor(
  46050. /**
  46051. * Defines the scene to instrument
  46052. */
  46053. scene: Scene);
  46054. /**
  46055. * Dispose and release associated resources.
  46056. */
  46057. dispose(): void;
  46058. }
  46059. }
  46060. declare module "babylonjs/Instrumentation/index" {
  46061. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46062. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46063. export * from "babylonjs/Instrumentation/timeToken";
  46064. }
  46065. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46066. /** @hidden */
  46067. export var glowMapGenerationPixelShader: {
  46068. name: string;
  46069. shader: string;
  46070. };
  46071. }
  46072. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46073. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46074. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46075. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46076. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46077. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46078. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46079. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46080. /** @hidden */
  46081. export var glowMapGenerationVertexShader: {
  46082. name: string;
  46083. shader: string;
  46084. };
  46085. }
  46086. declare module "babylonjs/Layers/effectLayer" {
  46087. import { Observable } from "babylonjs/Misc/observable";
  46088. import { Nullable } from "babylonjs/types";
  46089. import { Camera } from "babylonjs/Cameras/camera";
  46090. import { Scene } from "babylonjs/scene";
  46091. import { Color4, ISize } from "babylonjs/Maths/math";
  46092. import { Engine } from "babylonjs/Engines/engine";
  46093. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46095. import { Mesh } from "babylonjs/Meshes/mesh";
  46096. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46097. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46098. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46099. import { Effect } from "babylonjs/Materials/effect";
  46100. import { Material } from "babylonjs/Materials/material";
  46101. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46102. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46103. /**
  46104. * Effect layer options. This helps customizing the behaviour
  46105. * of the effect layer.
  46106. */
  46107. export interface IEffectLayerOptions {
  46108. /**
  46109. * Multiplication factor apply to the canvas size to compute the render target size
  46110. * used to generated the objects (the smaller the faster).
  46111. */
  46112. mainTextureRatio: number;
  46113. /**
  46114. * Enforces a fixed size texture to ensure effect stability across devices.
  46115. */
  46116. mainTextureFixedSize?: number;
  46117. /**
  46118. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46119. */
  46120. alphaBlendingMode: number;
  46121. /**
  46122. * The camera attached to the layer.
  46123. */
  46124. camera: Nullable<Camera>;
  46125. /**
  46126. * The rendering group to draw the layer in.
  46127. */
  46128. renderingGroupId: number;
  46129. }
  46130. /**
  46131. * The effect layer Helps adding post process effect blended with the main pass.
  46132. *
  46133. * This can be for instance use to generate glow or higlight effects on the scene.
  46134. *
  46135. * The effect layer class can not be used directly and is intented to inherited from to be
  46136. * customized per effects.
  46137. */
  46138. export abstract class EffectLayer {
  46139. private _vertexBuffers;
  46140. private _indexBuffer;
  46141. private _cachedDefines;
  46142. private _effectLayerMapGenerationEffect;
  46143. private _effectLayerOptions;
  46144. private _mergeEffect;
  46145. protected _scene: Scene;
  46146. protected _engine: Engine;
  46147. protected _maxSize: number;
  46148. protected _mainTextureDesiredSize: ISize;
  46149. protected _mainTexture: RenderTargetTexture;
  46150. protected _shouldRender: boolean;
  46151. protected _postProcesses: PostProcess[];
  46152. protected _textures: BaseTexture[];
  46153. protected _emissiveTextureAndColor: {
  46154. texture: Nullable<BaseTexture>;
  46155. color: Color4;
  46156. };
  46157. /**
  46158. * The name of the layer
  46159. */
  46160. name: string;
  46161. /**
  46162. * The clear color of the texture used to generate the glow map.
  46163. */
  46164. neutralColor: Color4;
  46165. /**
  46166. * Specifies wether the highlight layer is enabled or not.
  46167. */
  46168. isEnabled: boolean;
  46169. /**
  46170. * Gets the camera attached to the layer.
  46171. */
  46172. readonly camera: Nullable<Camera>;
  46173. /**
  46174. * Gets the rendering group id the layer should render in.
  46175. */
  46176. readonly renderingGroupId: number;
  46177. /**
  46178. * An event triggered when the effect layer has been disposed.
  46179. */
  46180. onDisposeObservable: Observable<EffectLayer>;
  46181. /**
  46182. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46183. */
  46184. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46185. /**
  46186. * An event triggered when the generated texture is being merged in the scene.
  46187. */
  46188. onBeforeComposeObservable: Observable<EffectLayer>;
  46189. /**
  46190. * An event triggered when the generated texture has been merged in the scene.
  46191. */
  46192. onAfterComposeObservable: Observable<EffectLayer>;
  46193. /**
  46194. * An event triggered when the efffect layer changes its size.
  46195. */
  46196. onSizeChangedObservable: Observable<EffectLayer>;
  46197. /** @hidden */
  46198. static _SceneComponentInitialization: (scene: Scene) => void;
  46199. /**
  46200. * Instantiates a new effect Layer and references it in the scene.
  46201. * @param name The name of the layer
  46202. * @param scene The scene to use the layer in
  46203. */
  46204. constructor(
  46205. /** The Friendly of the effect in the scene */
  46206. name: string, scene: Scene);
  46207. /**
  46208. * Get the effect name of the layer.
  46209. * @return The effect name
  46210. */
  46211. abstract getEffectName(): string;
  46212. /**
  46213. * Checks for the readiness of the element composing the layer.
  46214. * @param subMesh the mesh to check for
  46215. * @param useInstances specify wether or not to use instances to render the mesh
  46216. * @return true if ready otherwise, false
  46217. */
  46218. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46219. /**
  46220. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46221. * @returns true if the effect requires stencil during the main canvas render pass.
  46222. */
  46223. abstract needStencil(): boolean;
  46224. /**
  46225. * Create the merge effect. This is the shader use to blit the information back
  46226. * to the main canvas at the end of the scene rendering.
  46227. * @returns The effect containing the shader used to merge the effect on the main canvas
  46228. */
  46229. protected abstract _createMergeEffect(): Effect;
  46230. /**
  46231. * Creates the render target textures and post processes used in the effect layer.
  46232. */
  46233. protected abstract _createTextureAndPostProcesses(): void;
  46234. /**
  46235. * Implementation specific of rendering the generating effect on the main canvas.
  46236. * @param effect The effect used to render through
  46237. */
  46238. protected abstract _internalRender(effect: Effect): void;
  46239. /**
  46240. * Sets the required values for both the emissive texture and and the main color.
  46241. */
  46242. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46243. /**
  46244. * Free any resources and references associated to a mesh.
  46245. * Internal use
  46246. * @param mesh The mesh to free.
  46247. */
  46248. abstract _disposeMesh(mesh: Mesh): void;
  46249. /**
  46250. * Serializes this layer (Glow or Highlight for example)
  46251. * @returns a serialized layer object
  46252. */
  46253. abstract serialize?(): any;
  46254. /**
  46255. * Initializes the effect layer with the required options.
  46256. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46257. */
  46258. protected _init(options: Partial<IEffectLayerOptions>): void;
  46259. /**
  46260. * Generates the index buffer of the full screen quad blending to the main canvas.
  46261. */
  46262. private _generateIndexBuffer;
  46263. /**
  46264. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46265. */
  46266. private _genrateVertexBuffer;
  46267. /**
  46268. * Sets the main texture desired size which is the closest power of two
  46269. * of the engine canvas size.
  46270. */
  46271. private _setMainTextureSize;
  46272. /**
  46273. * Creates the main texture for the effect layer.
  46274. */
  46275. protected _createMainTexture(): void;
  46276. /**
  46277. * Adds specific effects defines.
  46278. * @param defines The defines to add specifics to.
  46279. */
  46280. protected _addCustomEffectDefines(defines: string[]): void;
  46281. /**
  46282. * Checks for the readiness of the element composing the layer.
  46283. * @param subMesh the mesh to check for
  46284. * @param useInstances specify wether or not to use instances to render the mesh
  46285. * @param emissiveTexture the associated emissive texture used to generate the glow
  46286. * @return true if ready otherwise, false
  46287. */
  46288. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46289. /**
  46290. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46291. */
  46292. render(): void;
  46293. /**
  46294. * Determine if a given mesh will be used in the current effect.
  46295. * @param mesh mesh to test
  46296. * @returns true if the mesh will be used
  46297. */
  46298. hasMesh(mesh: AbstractMesh): boolean;
  46299. /**
  46300. * Returns true if the layer contains information to display, otherwise false.
  46301. * @returns true if the glow layer should be rendered
  46302. */
  46303. shouldRender(): boolean;
  46304. /**
  46305. * Returns true if the mesh should render, otherwise false.
  46306. * @param mesh The mesh to render
  46307. * @returns true if it should render otherwise false
  46308. */
  46309. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46310. /**
  46311. * Returns true if the mesh can be rendered, otherwise false.
  46312. * @param mesh The mesh to render
  46313. * @param material The material used on the mesh
  46314. * @returns true if it can be rendered otherwise false
  46315. */
  46316. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46317. /**
  46318. * Returns true if the mesh should render, otherwise false.
  46319. * @param mesh The mesh to render
  46320. * @returns true if it should render otherwise false
  46321. */
  46322. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46323. /**
  46324. * Renders the submesh passed in parameter to the generation map.
  46325. */
  46326. protected _renderSubMesh(subMesh: SubMesh): void;
  46327. /**
  46328. * Rebuild the required buffers.
  46329. * @hidden Internal use only.
  46330. */
  46331. _rebuild(): void;
  46332. /**
  46333. * Dispose only the render target textures and post process.
  46334. */
  46335. private _disposeTextureAndPostProcesses;
  46336. /**
  46337. * Dispose the highlight layer and free resources.
  46338. */
  46339. dispose(): void;
  46340. /**
  46341. * Gets the class name of the effect layer
  46342. * @returns the string with the class name of the effect layer
  46343. */
  46344. getClassName(): string;
  46345. /**
  46346. * Creates an effect layer from parsed effect layer data
  46347. * @param parsedEffectLayer defines effect layer data
  46348. * @param scene defines the current scene
  46349. * @param rootUrl defines the root URL containing the effect layer information
  46350. * @returns a parsed effect Layer
  46351. */
  46352. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46353. }
  46354. }
  46355. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  46356. import { Scene } from "babylonjs/scene";
  46357. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46358. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46359. import { AbstractScene } from "babylonjs/abstractScene";
  46360. module "babylonjs/abstractScene" {
  46361. interface AbstractScene {
  46362. /**
  46363. * The list of effect layers (highlights/glow) added to the scene
  46364. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46365. * @see http://doc.babylonjs.com/how_to/glow_layer
  46366. */
  46367. effectLayers: Array<EffectLayer>;
  46368. /**
  46369. * Removes the given effect layer from this scene.
  46370. * @param toRemove defines the effect layer to remove
  46371. * @returns the index of the removed effect layer
  46372. */
  46373. removeEffectLayer(toRemove: EffectLayer): number;
  46374. /**
  46375. * Adds the given effect layer to this scene
  46376. * @param newEffectLayer defines the effect layer to add
  46377. */
  46378. addEffectLayer(newEffectLayer: EffectLayer): void;
  46379. }
  46380. }
  46381. /**
  46382. * Defines the layer scene component responsible to manage any effect layers
  46383. * in a given scene.
  46384. */
  46385. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46386. /**
  46387. * The component name helpfull to identify the component in the list of scene components.
  46388. */
  46389. readonly name: string;
  46390. /**
  46391. * The scene the component belongs to.
  46392. */
  46393. scene: Scene;
  46394. private _engine;
  46395. private _renderEffects;
  46396. private _needStencil;
  46397. private _previousStencilState;
  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. * Disposes the component and the associated ressources.
  46429. */
  46430. dispose(): void;
  46431. private _isReadyForMesh;
  46432. private _renderMainTexture;
  46433. private _setStencil;
  46434. private _setStencilBack;
  46435. private _draw;
  46436. private _drawCamera;
  46437. private _drawRenderingGroup;
  46438. }
  46439. }
  46440. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  46441. /** @hidden */
  46442. export var glowMapMergePixelShader: {
  46443. name: string;
  46444. shader: string;
  46445. };
  46446. }
  46447. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  46448. /** @hidden */
  46449. export var glowMapMergeVertexShader: {
  46450. name: string;
  46451. shader: string;
  46452. };
  46453. }
  46454. declare module "babylonjs/Layers/glowLayer" {
  46455. import { Nullable } from "babylonjs/types";
  46456. import { Camera } from "babylonjs/Cameras/camera";
  46457. import { Scene } from "babylonjs/scene";
  46458. import { Color4 } from "babylonjs/Maths/math";
  46459. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46461. import { Mesh } from "babylonjs/Meshes/mesh";
  46462. import { Texture } from "babylonjs/Materials/Textures/texture";
  46463. import { Effect } from "babylonjs/Materials/effect";
  46464. import { Material } from "babylonjs/Materials/material";
  46465. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46466. import "babylonjs/Shaders/glowMapMerge.fragment";
  46467. import "babylonjs/Shaders/glowMapMerge.vertex";
  46468. module "babylonjs/abstractScene" {
  46469. interface AbstractScene {
  46470. /**
  46471. * Return a the first highlight layer of the scene with a given name.
  46472. * @param name The name of the highlight layer to look for.
  46473. * @return The highlight layer if found otherwise null.
  46474. */
  46475. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46476. }
  46477. }
  46478. /**
  46479. * Glow layer options. This helps customizing the behaviour
  46480. * of the glow layer.
  46481. */
  46482. export interface IGlowLayerOptions {
  46483. /**
  46484. * Multiplication factor apply to the canvas size to compute the render target size
  46485. * used to generated the glowing objects (the smaller the faster).
  46486. */
  46487. mainTextureRatio: number;
  46488. /**
  46489. * Enforces a fixed size texture to ensure resize independant blur.
  46490. */
  46491. mainTextureFixedSize?: number;
  46492. /**
  46493. * How big is the kernel of the blur texture.
  46494. */
  46495. blurKernelSize: number;
  46496. /**
  46497. * The camera attached to the layer.
  46498. */
  46499. camera: Nullable<Camera>;
  46500. /**
  46501. * Enable MSAA by chosing the number of samples.
  46502. */
  46503. mainTextureSamples?: number;
  46504. /**
  46505. * The rendering group to draw the layer in.
  46506. */
  46507. renderingGroupId: number;
  46508. }
  46509. /**
  46510. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46511. *
  46512. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46513. * glowy meshes to your scene.
  46514. *
  46515. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46516. */
  46517. export class GlowLayer extends EffectLayer {
  46518. /**
  46519. * Effect Name of the layer.
  46520. */
  46521. static readonly EffectName: string;
  46522. /**
  46523. * The default blur kernel size used for the glow.
  46524. */
  46525. static DefaultBlurKernelSize: number;
  46526. /**
  46527. * The default texture size ratio used for the glow.
  46528. */
  46529. static DefaultTextureRatio: number;
  46530. /**
  46531. * Sets the kernel size of the blur.
  46532. */
  46533. /**
  46534. * Gets the kernel size of the blur.
  46535. */
  46536. blurKernelSize: number;
  46537. /**
  46538. * Sets the glow intensity.
  46539. */
  46540. /**
  46541. * Gets the glow intensity.
  46542. */
  46543. intensity: number;
  46544. private _options;
  46545. private _intensity;
  46546. private _horizontalBlurPostprocess1;
  46547. private _verticalBlurPostprocess1;
  46548. private _horizontalBlurPostprocess2;
  46549. private _verticalBlurPostprocess2;
  46550. private _blurTexture1;
  46551. private _blurTexture2;
  46552. private _postProcesses1;
  46553. private _postProcesses2;
  46554. private _includedOnlyMeshes;
  46555. private _excludedMeshes;
  46556. /**
  46557. * Callback used to let the user override the color selection on a per mesh basis
  46558. */
  46559. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46560. /**
  46561. * Callback used to let the user override the texture selection on a per mesh basis
  46562. */
  46563. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46564. /**
  46565. * Instantiates a new glow Layer and references it to the scene.
  46566. * @param name The name of the layer
  46567. * @param scene The scene to use the layer in
  46568. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46569. */
  46570. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46571. /**
  46572. * Get the effect name of the layer.
  46573. * @return The effect name
  46574. */
  46575. getEffectName(): string;
  46576. /**
  46577. * Create the merge effect. This is the shader use to blit the information back
  46578. * to the main canvas at the end of the scene rendering.
  46579. */
  46580. protected _createMergeEffect(): Effect;
  46581. /**
  46582. * Creates the render target textures and post processes used in the glow layer.
  46583. */
  46584. protected _createTextureAndPostProcesses(): void;
  46585. /**
  46586. * Checks for the readiness of the element composing the layer.
  46587. * @param subMesh the mesh to check for
  46588. * @param useInstances specify wether or not to use instances to render the mesh
  46589. * @param emissiveTexture the associated emissive texture used to generate the glow
  46590. * @return true if ready otherwise, false
  46591. */
  46592. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46593. /**
  46594. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46595. */
  46596. needStencil(): boolean;
  46597. /**
  46598. * Returns true if the mesh can be rendered, otherwise false.
  46599. * @param mesh The mesh to render
  46600. * @param material The material used on the mesh
  46601. * @returns true if it can be rendered otherwise false
  46602. */
  46603. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46604. /**
  46605. * Implementation specific of rendering the generating effect on the main canvas.
  46606. * @param effect The effect used to render through
  46607. */
  46608. protected _internalRender(effect: Effect): void;
  46609. /**
  46610. * Sets the required values for both the emissive texture and and the main color.
  46611. */
  46612. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46613. /**
  46614. * Returns true if the mesh should render, otherwise false.
  46615. * @param mesh The mesh to render
  46616. * @returns true if it should render otherwise false
  46617. */
  46618. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46619. /**
  46620. * Adds specific effects defines.
  46621. * @param defines The defines to add specifics to.
  46622. */
  46623. protected _addCustomEffectDefines(defines: string[]): void;
  46624. /**
  46625. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46626. * @param mesh The mesh to exclude from the glow layer
  46627. */
  46628. addExcludedMesh(mesh: Mesh): void;
  46629. /**
  46630. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46631. * @param mesh The mesh to remove
  46632. */
  46633. removeExcludedMesh(mesh: Mesh): void;
  46634. /**
  46635. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46636. * @param mesh The mesh to include in the glow layer
  46637. */
  46638. addIncludedOnlyMesh(mesh: Mesh): void;
  46639. /**
  46640. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46641. * @param mesh The mesh to remove
  46642. */
  46643. removeIncludedOnlyMesh(mesh: Mesh): void;
  46644. /**
  46645. * Determine if a given mesh will be used in the glow layer
  46646. * @param mesh The mesh to test
  46647. * @returns true if the mesh will be highlighted by the current glow layer
  46648. */
  46649. hasMesh(mesh: AbstractMesh): boolean;
  46650. /**
  46651. * Free any resources and references associated to a mesh.
  46652. * Internal use
  46653. * @param mesh The mesh to free.
  46654. * @hidden
  46655. */
  46656. _disposeMesh(mesh: Mesh): void;
  46657. /**
  46658. * Gets the class name of the effect layer
  46659. * @returns the string with the class name of the effect layer
  46660. */
  46661. getClassName(): string;
  46662. /**
  46663. * Serializes this glow layer
  46664. * @returns a serialized glow layer object
  46665. */
  46666. serialize(): any;
  46667. /**
  46668. * Creates a Glow Layer from parsed glow layer data
  46669. * @param parsedGlowLayer defines glow layer data
  46670. * @param scene defines the current scene
  46671. * @param rootUrl defines the root URL containing the glow layer information
  46672. * @returns a parsed Glow Layer
  46673. */
  46674. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46675. }
  46676. }
  46677. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  46678. /** @hidden */
  46679. export var glowBlurPostProcessPixelShader: {
  46680. name: string;
  46681. shader: string;
  46682. };
  46683. }
  46684. declare module "babylonjs/Layers/highlightLayer" {
  46685. import { Observable } from "babylonjs/Misc/observable";
  46686. import { Nullable } from "babylonjs/types";
  46687. import { Camera } from "babylonjs/Cameras/camera";
  46688. import { Scene } from "babylonjs/scene";
  46689. import { Color3, Color4 } from "babylonjs/Maths/math";
  46690. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46692. import { Mesh } from "babylonjs/Meshes/mesh";
  46693. import { Effect } from "babylonjs/Materials/effect";
  46694. import { Material } from "babylonjs/Materials/material";
  46695. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46696. import "babylonjs/Shaders/glowMapMerge.fragment";
  46697. import "babylonjs/Shaders/glowMapMerge.vertex";
  46698. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  46699. module "babylonjs/abstractScene" {
  46700. interface AbstractScene {
  46701. /**
  46702. * Return a the first highlight layer of the scene with a given name.
  46703. * @param name The name of the highlight layer to look for.
  46704. * @return The highlight layer if found otherwise null.
  46705. */
  46706. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46707. }
  46708. }
  46709. /**
  46710. * Highlight layer options. This helps customizing the behaviour
  46711. * of the highlight layer.
  46712. */
  46713. export interface IHighlightLayerOptions {
  46714. /**
  46715. * Multiplication factor apply to the canvas size to compute the render target size
  46716. * used to generated the glowing objects (the smaller the faster).
  46717. */
  46718. mainTextureRatio: number;
  46719. /**
  46720. * Enforces a fixed size texture to ensure resize independant blur.
  46721. */
  46722. mainTextureFixedSize?: number;
  46723. /**
  46724. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46725. * of the picture to blur (the smaller the faster).
  46726. */
  46727. blurTextureSizeRatio: number;
  46728. /**
  46729. * How big in texel of the blur texture is the vertical blur.
  46730. */
  46731. blurVerticalSize: number;
  46732. /**
  46733. * How big in texel of the blur texture is the horizontal blur.
  46734. */
  46735. blurHorizontalSize: number;
  46736. /**
  46737. * Alpha blending mode used to apply the blur. Default is combine.
  46738. */
  46739. alphaBlendingMode: number;
  46740. /**
  46741. * The camera attached to the layer.
  46742. */
  46743. camera: Nullable<Camera>;
  46744. /**
  46745. * Should we display highlight as a solid stroke?
  46746. */
  46747. isStroke?: boolean;
  46748. /**
  46749. * The rendering group to draw the layer in.
  46750. */
  46751. renderingGroupId: number;
  46752. }
  46753. /**
  46754. * The highlight layer Helps adding a glow effect around a mesh.
  46755. *
  46756. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46757. * glowy meshes to your scene.
  46758. *
  46759. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46760. */
  46761. export class HighlightLayer extends EffectLayer {
  46762. name: string;
  46763. /**
  46764. * Effect Name of the highlight layer.
  46765. */
  46766. static readonly EffectName: string;
  46767. /**
  46768. * The neutral color used during the preparation of the glow effect.
  46769. * This is black by default as the blend operation is a blend operation.
  46770. */
  46771. static NeutralColor: Color4;
  46772. /**
  46773. * Stencil value used for glowing meshes.
  46774. */
  46775. static GlowingMeshStencilReference: number;
  46776. /**
  46777. * Stencil value used for the other meshes in the scene.
  46778. */
  46779. static NormalMeshStencilReference: number;
  46780. /**
  46781. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46782. */
  46783. innerGlow: boolean;
  46784. /**
  46785. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46786. */
  46787. outerGlow: boolean;
  46788. /**
  46789. * Specifies the horizontal size of the blur.
  46790. */
  46791. /**
  46792. * Gets the horizontal size of the blur.
  46793. */
  46794. blurHorizontalSize: number;
  46795. /**
  46796. * Specifies the vertical size of the blur.
  46797. */
  46798. /**
  46799. * Gets the vertical size of the blur.
  46800. */
  46801. blurVerticalSize: number;
  46802. /**
  46803. * An event triggered when the highlight layer is being blurred.
  46804. */
  46805. onBeforeBlurObservable: Observable<HighlightLayer>;
  46806. /**
  46807. * An event triggered when the highlight layer has been blurred.
  46808. */
  46809. onAfterBlurObservable: Observable<HighlightLayer>;
  46810. private _instanceGlowingMeshStencilReference;
  46811. private _options;
  46812. private _downSamplePostprocess;
  46813. private _horizontalBlurPostprocess;
  46814. private _verticalBlurPostprocess;
  46815. private _blurTexture;
  46816. private _meshes;
  46817. private _excludedMeshes;
  46818. /**
  46819. * Instantiates a new highlight Layer and references it to the scene..
  46820. * @param name The name of the layer
  46821. * @param scene The scene to use the layer in
  46822. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46823. */
  46824. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46825. /**
  46826. * Get the effect name of the layer.
  46827. * @return The effect name
  46828. */
  46829. getEffectName(): string;
  46830. /**
  46831. * Create the merge effect. This is the shader use to blit the information back
  46832. * to the main canvas at the end of the scene rendering.
  46833. */
  46834. protected _createMergeEffect(): Effect;
  46835. /**
  46836. * Creates the render target textures and post processes used in the highlight layer.
  46837. */
  46838. protected _createTextureAndPostProcesses(): void;
  46839. /**
  46840. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46841. */
  46842. needStencil(): boolean;
  46843. /**
  46844. * Checks for the readiness of the element composing the layer.
  46845. * @param subMesh the mesh to check for
  46846. * @param useInstances specify wether or not to use instances to render the mesh
  46847. * @param emissiveTexture the associated emissive texture used to generate the glow
  46848. * @return true if ready otherwise, false
  46849. */
  46850. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46851. /**
  46852. * Implementation specific of rendering the generating effect on the main canvas.
  46853. * @param effect The effect used to render through
  46854. */
  46855. protected _internalRender(effect: Effect): void;
  46856. /**
  46857. * Returns true if the layer contains information to display, otherwise false.
  46858. */
  46859. shouldRender(): boolean;
  46860. /**
  46861. * Returns true if the mesh should render, otherwise false.
  46862. * @param mesh The mesh to render
  46863. * @returns true if it should render otherwise false
  46864. */
  46865. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46866. /**
  46867. * Sets the required values for both the emissive texture and and the main color.
  46868. */
  46869. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46870. /**
  46871. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46872. * @param mesh The mesh to exclude from the highlight layer
  46873. */
  46874. addExcludedMesh(mesh: Mesh): void;
  46875. /**
  46876. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46877. * @param mesh The mesh to highlight
  46878. */
  46879. removeExcludedMesh(mesh: Mesh): void;
  46880. /**
  46881. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46882. * @param mesh mesh to test
  46883. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46884. */
  46885. hasMesh(mesh: AbstractMesh): boolean;
  46886. /**
  46887. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46888. * @param mesh The mesh to highlight
  46889. * @param color The color of the highlight
  46890. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46891. */
  46892. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46893. /**
  46894. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46895. * @param mesh The mesh to highlight
  46896. */
  46897. removeMesh(mesh: Mesh): void;
  46898. /**
  46899. * Force the stencil to the normal expected value for none glowing parts
  46900. */
  46901. private _defaultStencilReference;
  46902. /**
  46903. * Free any resources and references associated to a mesh.
  46904. * Internal use
  46905. * @param mesh The mesh to free.
  46906. * @hidden
  46907. */
  46908. _disposeMesh(mesh: Mesh): void;
  46909. /**
  46910. * Dispose the highlight layer and free resources.
  46911. */
  46912. dispose(): void;
  46913. /**
  46914. * Gets the class name of the effect layer
  46915. * @returns the string with the class name of the effect layer
  46916. */
  46917. getClassName(): string;
  46918. /**
  46919. * Serializes this Highlight layer
  46920. * @returns a serialized Highlight layer object
  46921. */
  46922. serialize(): any;
  46923. /**
  46924. * Creates a Highlight layer from parsed Highlight layer data
  46925. * @param parsedHightlightLayer defines the Highlight layer data
  46926. * @param scene defines the current scene
  46927. * @param rootUrl defines the root URL containing the Highlight layer information
  46928. * @returns a parsed Highlight layer
  46929. */
  46930. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46931. }
  46932. }
  46933. declare module "babylonjs/Layers/index" {
  46934. export * from "babylonjs/Layers/effectLayer";
  46935. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46936. export * from "babylonjs/Layers/glowLayer";
  46937. export * from "babylonjs/Layers/highlightLayer";
  46938. export * from "babylonjs/Layers/layer";
  46939. export * from "babylonjs/Layers/layerSceneComponent";
  46940. }
  46941. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46942. /** @hidden */
  46943. export var lensFlarePixelShader: {
  46944. name: string;
  46945. shader: string;
  46946. };
  46947. }
  46948. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46949. /** @hidden */
  46950. export var lensFlareVertexShader: {
  46951. name: string;
  46952. shader: string;
  46953. };
  46954. }
  46955. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46956. import { Scene } from "babylonjs/scene";
  46957. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46959. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46960. import "babylonjs/Shaders/lensFlare.fragment";
  46961. import "babylonjs/Shaders/lensFlare.vertex";
  46962. /**
  46963. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46964. * It is usually composed of several `lensFlare`.
  46965. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46966. */
  46967. export class LensFlareSystem {
  46968. /**
  46969. * Define the name of the lens flare system
  46970. */
  46971. name: string;
  46972. /**
  46973. * List of lens flares used in this system.
  46974. */
  46975. lensFlares: LensFlare[];
  46976. /**
  46977. * Define a limit from the border the lens flare can be visible.
  46978. */
  46979. borderLimit: number;
  46980. /**
  46981. * Define a viewport border we do not want to see the lens flare in.
  46982. */
  46983. viewportBorder: number;
  46984. /**
  46985. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46986. */
  46987. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46988. /**
  46989. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46990. */
  46991. layerMask: number;
  46992. /**
  46993. * Define the id of the lens flare system in the scene.
  46994. * (equal to name by default)
  46995. */
  46996. id: string;
  46997. private _scene;
  46998. private _emitter;
  46999. private _vertexBuffers;
  47000. private _indexBuffer;
  47001. private _effect;
  47002. private _positionX;
  47003. private _positionY;
  47004. private _isEnabled;
  47005. /** @hidden */
  47006. static _SceneComponentInitialization: (scene: Scene) => void;
  47007. /**
  47008. * Instantiates a lens flare system.
  47009. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47010. * It is usually composed of several `lensFlare`.
  47011. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47012. * @param name Define the name of the lens flare system in the scene
  47013. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47014. * @param scene Define the scene the lens flare system belongs to
  47015. */
  47016. constructor(
  47017. /**
  47018. * Define the name of the lens flare system
  47019. */
  47020. name: string, emitter: any, scene: Scene);
  47021. /**
  47022. * Define if the lens flare system is enabled.
  47023. */
  47024. isEnabled: boolean;
  47025. /**
  47026. * Get the scene the effects belongs to.
  47027. * @returns the scene holding the lens flare system
  47028. */
  47029. getScene(): Scene;
  47030. /**
  47031. * Get the emitter of the lens flare system.
  47032. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47033. * @returns the emitter of the lens flare system
  47034. */
  47035. getEmitter(): any;
  47036. /**
  47037. * Set the emitter of the lens flare system.
  47038. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47039. * @param newEmitter Define the new emitter of the system
  47040. */
  47041. setEmitter(newEmitter: any): void;
  47042. /**
  47043. * Get the lens flare system emitter position.
  47044. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47045. * @returns the position
  47046. */
  47047. getEmitterPosition(): Vector3;
  47048. /**
  47049. * @hidden
  47050. */
  47051. computeEffectivePosition(globalViewport: Viewport): boolean;
  47052. /** @hidden */
  47053. _isVisible(): boolean;
  47054. /**
  47055. * @hidden
  47056. */
  47057. render(): boolean;
  47058. /**
  47059. * Dispose and release the lens flare with its associated resources.
  47060. */
  47061. dispose(): void;
  47062. /**
  47063. * Parse a lens flare system from a JSON repressentation
  47064. * @param parsedLensFlareSystem Define the JSON to parse
  47065. * @param scene Define the scene the parsed system should be instantiated in
  47066. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47067. * @returns the parsed system
  47068. */
  47069. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47070. /**
  47071. * Serialize the current Lens Flare System into a JSON representation.
  47072. * @returns the serialized JSON
  47073. */
  47074. serialize(): any;
  47075. }
  47076. }
  47077. declare module "babylonjs/LensFlares/lensFlare" {
  47078. import { Nullable } from "babylonjs/types";
  47079. import { Color3 } from "babylonjs/Maths/math";
  47080. import { Texture } from "babylonjs/Materials/Textures/texture";
  47081. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47082. /**
  47083. * This represents one of the lens effect in a `lensFlareSystem`.
  47084. * It controls one of the indiviual texture used in the effect.
  47085. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47086. */
  47087. export class LensFlare {
  47088. /**
  47089. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47090. */
  47091. size: number;
  47092. /**
  47093. * 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.
  47094. */
  47095. position: number;
  47096. /**
  47097. * Define the lens color.
  47098. */
  47099. color: Color3;
  47100. /**
  47101. * Define the lens texture.
  47102. */
  47103. texture: Nullable<Texture>;
  47104. /**
  47105. * Define the alpha mode to render this particular lens.
  47106. */
  47107. alphaMode: number;
  47108. private _system;
  47109. /**
  47110. * Creates a new Lens Flare.
  47111. * This represents one of the lens effect in a `lensFlareSystem`.
  47112. * It controls one of the indiviual texture used in the effect.
  47113. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47114. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47115. * @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.
  47116. * @param color Define the lens color
  47117. * @param imgUrl Define the lens texture url
  47118. * @param system Define the `lensFlareSystem` this flare is part of
  47119. * @returns The newly created Lens Flare
  47120. */
  47121. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47122. /**
  47123. * Instantiates a new Lens Flare.
  47124. * This represents one of the lens effect in a `lensFlareSystem`.
  47125. * It controls one of the indiviual texture used in the effect.
  47126. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47127. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47128. * @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.
  47129. * @param color Define the lens color
  47130. * @param imgUrl Define the lens texture url
  47131. * @param system Define the `lensFlareSystem` this flare is part of
  47132. */
  47133. constructor(
  47134. /**
  47135. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47136. */
  47137. size: number,
  47138. /**
  47139. * 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.
  47140. */
  47141. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47142. /**
  47143. * Dispose and release the lens flare with its associated resources.
  47144. */
  47145. dispose(): void;
  47146. }
  47147. }
  47148. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47149. import { Nullable } from "babylonjs/types";
  47150. import { Scene } from "babylonjs/scene";
  47151. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47152. import { AbstractScene } from "babylonjs/abstractScene";
  47153. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47154. module "babylonjs/abstractScene" {
  47155. interface AbstractScene {
  47156. /**
  47157. * The list of lens flare system added to the scene
  47158. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47159. */
  47160. lensFlareSystems: Array<LensFlareSystem>;
  47161. /**
  47162. * Removes the given lens flare system from this scene.
  47163. * @param toRemove The lens flare system to remove
  47164. * @returns The index of the removed lens flare system
  47165. */
  47166. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47167. /**
  47168. * Adds the given lens flare system to this scene
  47169. * @param newLensFlareSystem The lens flare system to add
  47170. */
  47171. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47172. /**
  47173. * Gets a lens flare system using its name
  47174. * @param name defines the name to look for
  47175. * @returns the lens flare system or null if not found
  47176. */
  47177. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47178. /**
  47179. * Gets a lens flare system using its id
  47180. * @param id defines the id to look for
  47181. * @returns the lens flare system or null if not found
  47182. */
  47183. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47184. }
  47185. }
  47186. /**
  47187. * Defines the lens flare scene component responsible to manage any lens flares
  47188. * in a given scene.
  47189. */
  47190. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47191. /**
  47192. * The component name helpfull to identify the component in the list of scene components.
  47193. */
  47194. readonly name: string;
  47195. /**
  47196. * The scene the component belongs to.
  47197. */
  47198. scene: Scene;
  47199. /**
  47200. * Creates a new instance of the component for the given scene
  47201. * @param scene Defines the scene to register the component in
  47202. */
  47203. constructor(scene: Scene);
  47204. /**
  47205. * Registers the component in a given scene
  47206. */
  47207. register(): void;
  47208. /**
  47209. * Rebuilds the elements related to this component in case of
  47210. * context lost for instance.
  47211. */
  47212. rebuild(): void;
  47213. /**
  47214. * Adds all the element from the container to the scene
  47215. * @param container the container holding the elements
  47216. */
  47217. addFromContainer(container: AbstractScene): void;
  47218. /**
  47219. * Removes all the elements in the container from the scene
  47220. * @param container contains the elements to remove
  47221. */
  47222. removeFromContainer(container: AbstractScene): void;
  47223. /**
  47224. * Serializes the component data to the specified json object
  47225. * @param serializationObject The object to serialize to
  47226. */
  47227. serialize(serializationObject: any): void;
  47228. /**
  47229. * Disposes the component and the associated ressources.
  47230. */
  47231. dispose(): void;
  47232. private _draw;
  47233. }
  47234. }
  47235. declare module "babylonjs/LensFlares/index" {
  47236. export * from "babylonjs/LensFlares/lensFlare";
  47237. export * from "babylonjs/LensFlares/lensFlareSystem";
  47238. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  47239. }
  47240. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  47241. import { Scene } from "babylonjs/scene";
  47242. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47243. import { AbstractScene } from "babylonjs/abstractScene";
  47244. /**
  47245. * Defines the shadow generator component responsible to manage any shadow generators
  47246. * in a given scene.
  47247. */
  47248. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47249. /**
  47250. * The component name helpfull to identify the component in the list of scene components.
  47251. */
  47252. readonly name: string;
  47253. /**
  47254. * The scene the component belongs to.
  47255. */
  47256. scene: Scene;
  47257. /**
  47258. * Creates a new instance of the component for the given scene
  47259. * @param scene Defines the scene to register the component in
  47260. */
  47261. constructor(scene: Scene);
  47262. /**
  47263. * Registers the component in a given scene
  47264. */
  47265. register(): void;
  47266. /**
  47267. * Rebuilds the elements related to this component in case of
  47268. * context lost for instance.
  47269. */
  47270. rebuild(): void;
  47271. /**
  47272. * Serializes the component data to the specified json object
  47273. * @param serializationObject The object to serialize to
  47274. */
  47275. serialize(serializationObject: any): void;
  47276. /**
  47277. * Adds all the element from the container to the scene
  47278. * @param container the container holding the elements
  47279. */
  47280. addFromContainer(container: AbstractScene): void;
  47281. /**
  47282. * Removes all the elements in the container from the scene
  47283. * @param container contains the elements to remove
  47284. */
  47285. removeFromContainer(container: AbstractScene): void;
  47286. /**
  47287. * Rebuilds the elements related to this component in case of
  47288. * context lost for instance.
  47289. */
  47290. dispose(): void;
  47291. private _gatherRenderTargets;
  47292. }
  47293. }
  47294. declare module "babylonjs/Lights/Shadows/index" {
  47295. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  47296. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  47297. }
  47298. declare module "babylonjs/Lights/directionalLight" {
  47299. import { Camera } from "babylonjs/Cameras/camera";
  47300. import { Scene } from "babylonjs/scene";
  47301. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47303. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47304. import { Effect } from "babylonjs/Materials/effect";
  47305. /**
  47306. * A directional light is defined by a direction (what a surprise!).
  47307. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47308. * 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.
  47309. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47310. */
  47311. export class DirectionalLight extends ShadowLight {
  47312. private _shadowFrustumSize;
  47313. /**
  47314. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47315. */
  47316. /**
  47317. * Specifies a fix frustum size for the shadow generation.
  47318. */
  47319. shadowFrustumSize: number;
  47320. private _shadowOrthoScale;
  47321. /**
  47322. * Gets the shadow projection scale against the optimal computed one.
  47323. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47324. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47325. */
  47326. /**
  47327. * Sets the shadow projection scale against the optimal computed one.
  47328. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47329. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47330. */
  47331. shadowOrthoScale: number;
  47332. /**
  47333. * Automatically compute the projection matrix to best fit (including all the casters)
  47334. * on each frame.
  47335. */
  47336. autoUpdateExtends: boolean;
  47337. private _orthoLeft;
  47338. private _orthoRight;
  47339. private _orthoTop;
  47340. private _orthoBottom;
  47341. /**
  47342. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47343. * The directional light is emitted from everywhere in the given direction.
  47344. * It can cast shadows.
  47345. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47346. * @param name The friendly name of the light
  47347. * @param direction The direction of the light
  47348. * @param scene The scene the light belongs to
  47349. */
  47350. constructor(name: string, direction: Vector3, scene: Scene);
  47351. /**
  47352. * Returns the string "DirectionalLight".
  47353. * @return The class name
  47354. */
  47355. getClassName(): string;
  47356. /**
  47357. * Returns the integer 1.
  47358. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47359. */
  47360. getTypeID(): number;
  47361. /**
  47362. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47363. * Returns the DirectionalLight Shadow projection matrix.
  47364. */
  47365. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47366. /**
  47367. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47368. * Returns the DirectionalLight Shadow projection matrix.
  47369. */
  47370. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47371. /**
  47372. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47373. * Returns the DirectionalLight Shadow projection matrix.
  47374. */
  47375. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47376. protected _buildUniformLayout(): void;
  47377. /**
  47378. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47379. * @param effect The effect to update
  47380. * @param lightIndex The index of the light in the effect to update
  47381. * @returns The directional light
  47382. */
  47383. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47384. /**
  47385. * Gets the minZ used for shadow according to both the scene and the light.
  47386. *
  47387. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47388. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47389. * @param activeCamera The camera we are returning the min for
  47390. * @returns the depth min z
  47391. */
  47392. getDepthMinZ(activeCamera: Camera): number;
  47393. /**
  47394. * Gets the maxZ used for shadow according to both the scene and the light.
  47395. *
  47396. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47397. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47398. * @param activeCamera The camera we are returning the max for
  47399. * @returns the depth max z
  47400. */
  47401. getDepthMaxZ(activeCamera: Camera): number;
  47402. /**
  47403. * Prepares the list of defines specific to the light type.
  47404. * @param defines the list of defines
  47405. * @param lightIndex defines the index of the light for the effect
  47406. */
  47407. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47408. }
  47409. }
  47410. declare module "babylonjs/Lights/pointLight" {
  47411. import { Scene } from "babylonjs/scene";
  47412. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47414. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47415. import { Effect } from "babylonjs/Materials/effect";
  47416. /**
  47417. * A point light is a light defined by an unique point in world space.
  47418. * The light is emitted in every direction from this point.
  47419. * A good example of a point light is a standard light bulb.
  47420. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47421. */
  47422. export class PointLight extends ShadowLight {
  47423. private _shadowAngle;
  47424. /**
  47425. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47426. * This specifies what angle the shadow will use to be created.
  47427. *
  47428. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47429. */
  47430. /**
  47431. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47432. * This specifies what angle the shadow will use to be created.
  47433. *
  47434. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47435. */
  47436. shadowAngle: number;
  47437. /**
  47438. * Gets the direction if it has been set.
  47439. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47440. */
  47441. /**
  47442. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47443. */
  47444. direction: Vector3;
  47445. /**
  47446. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47447. * A PointLight emits the light in every direction.
  47448. * It can cast shadows.
  47449. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47450. * ```javascript
  47451. * var pointLight = new PointLight("pl", camera.position, scene);
  47452. * ```
  47453. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47454. * @param name The light friendly name
  47455. * @param position The position of the point light in the scene
  47456. * @param scene The scene the lights belongs to
  47457. */
  47458. constructor(name: string, position: Vector3, scene: Scene);
  47459. /**
  47460. * Returns the string "PointLight"
  47461. * @returns the class name
  47462. */
  47463. getClassName(): string;
  47464. /**
  47465. * Returns the integer 0.
  47466. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47467. */
  47468. getTypeID(): number;
  47469. /**
  47470. * Specifies wether or not the shadowmap should be a cube texture.
  47471. * @returns true if the shadowmap needs to be a cube texture.
  47472. */
  47473. needCube(): boolean;
  47474. /**
  47475. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47476. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47477. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47478. */
  47479. getShadowDirection(faceIndex?: number): Vector3;
  47480. /**
  47481. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47482. * - fov = PI / 2
  47483. * - aspect ratio : 1.0
  47484. * - z-near and far equal to the active camera minZ and maxZ.
  47485. * Returns the PointLight.
  47486. */
  47487. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47488. protected _buildUniformLayout(): void;
  47489. /**
  47490. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47491. * @param effect The effect to update
  47492. * @param lightIndex The index of the light in the effect to update
  47493. * @returns The point light
  47494. */
  47495. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47496. /**
  47497. * Prepares the list of defines specific to the light type.
  47498. * @param defines the list of defines
  47499. * @param lightIndex defines the index of the light for the effect
  47500. */
  47501. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47502. }
  47503. }
  47504. declare module "babylonjs/Lights/spotLight" {
  47505. import { Nullable } from "babylonjs/types";
  47506. import { Scene } from "babylonjs/scene";
  47507. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47509. import { Effect } from "babylonjs/Materials/effect";
  47510. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47511. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47512. /**
  47513. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47514. * These values define a cone of light starting from the position, emitting toward the direction.
  47515. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47516. * and the exponent defines the speed of the decay of the light with distance (reach).
  47517. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47518. */
  47519. export class SpotLight extends ShadowLight {
  47520. private _angle;
  47521. private _innerAngle;
  47522. private _cosHalfAngle;
  47523. private _lightAngleScale;
  47524. private _lightAngleOffset;
  47525. /**
  47526. * Gets the cone angle of the spot light in Radians.
  47527. */
  47528. /**
  47529. * Sets the cone angle of the spot light in Radians.
  47530. */
  47531. angle: number;
  47532. /**
  47533. * Only used in gltf falloff mode, this defines the angle where
  47534. * the directional falloff will start before cutting at angle which could be seen
  47535. * as outer angle.
  47536. */
  47537. /**
  47538. * Only used in gltf falloff mode, this defines the angle where
  47539. * the directional falloff will start before cutting at angle which could be seen
  47540. * as outer angle.
  47541. */
  47542. innerAngle: number;
  47543. private _shadowAngleScale;
  47544. /**
  47545. * Allows scaling the angle of the light for shadow generation only.
  47546. */
  47547. /**
  47548. * Allows scaling the angle of the light for shadow generation only.
  47549. */
  47550. shadowAngleScale: number;
  47551. /**
  47552. * The light decay speed with the distance from the emission spot.
  47553. */
  47554. exponent: number;
  47555. private _projectionTextureMatrix;
  47556. /**
  47557. * Allows reading the projecton texture
  47558. */
  47559. readonly projectionTextureMatrix: Matrix;
  47560. protected _projectionTextureLightNear: number;
  47561. /**
  47562. * Gets the near clip of the Spotlight for texture projection.
  47563. */
  47564. /**
  47565. * Sets the near clip of the Spotlight for texture projection.
  47566. */
  47567. projectionTextureLightNear: number;
  47568. protected _projectionTextureLightFar: number;
  47569. /**
  47570. * Gets the far clip of the Spotlight for texture projection.
  47571. */
  47572. /**
  47573. * Sets the far clip of the Spotlight for texture projection.
  47574. */
  47575. projectionTextureLightFar: number;
  47576. protected _projectionTextureUpDirection: Vector3;
  47577. /**
  47578. * Gets the Up vector of the Spotlight for texture projection.
  47579. */
  47580. /**
  47581. * Sets the Up vector of the Spotlight for texture projection.
  47582. */
  47583. projectionTextureUpDirection: Vector3;
  47584. private _projectionTexture;
  47585. /**
  47586. * Gets the projection texture of the light.
  47587. */
  47588. /**
  47589. * Sets the projection texture of the light.
  47590. */
  47591. projectionTexture: Nullable<BaseTexture>;
  47592. private _projectionTextureViewLightDirty;
  47593. private _projectionTextureProjectionLightDirty;
  47594. private _projectionTextureDirty;
  47595. private _projectionTextureViewTargetVector;
  47596. private _projectionTextureViewLightMatrix;
  47597. private _projectionTextureProjectionLightMatrix;
  47598. private _projectionTextureScalingMatrix;
  47599. /**
  47600. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47601. * It can cast shadows.
  47602. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47603. * @param name The light friendly name
  47604. * @param position The position of the spot light in the scene
  47605. * @param direction The direction of the light in the scene
  47606. * @param angle The cone angle of the light in Radians
  47607. * @param exponent The light decay speed with the distance from the emission spot
  47608. * @param scene The scene the lights belongs to
  47609. */
  47610. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47611. /**
  47612. * Returns the string "SpotLight".
  47613. * @returns the class name
  47614. */
  47615. getClassName(): string;
  47616. /**
  47617. * Returns the integer 2.
  47618. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47619. */
  47620. getTypeID(): number;
  47621. /**
  47622. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47623. */
  47624. protected _setDirection(value: Vector3): void;
  47625. /**
  47626. * Overrides the position setter to recompute the projection texture view light Matrix.
  47627. */
  47628. protected _setPosition(value: Vector3): void;
  47629. /**
  47630. * 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.
  47631. * Returns the SpotLight.
  47632. */
  47633. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47634. protected _computeProjectionTextureViewLightMatrix(): void;
  47635. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47636. /**
  47637. * Main function for light texture projection matrix computing.
  47638. */
  47639. protected _computeProjectionTextureMatrix(): void;
  47640. protected _buildUniformLayout(): void;
  47641. private _computeAngleValues;
  47642. /**
  47643. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47644. * @param effect The effect to update
  47645. * @param lightIndex The index of the light in the effect to update
  47646. * @returns The spot light
  47647. */
  47648. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47649. /**
  47650. * Disposes the light and the associated resources.
  47651. */
  47652. dispose(): void;
  47653. /**
  47654. * Prepares the list of defines specific to the light type.
  47655. * @param defines the list of defines
  47656. * @param lightIndex defines the index of the light for the effect
  47657. */
  47658. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47659. }
  47660. }
  47661. declare module "babylonjs/Lights/index" {
  47662. export * from "babylonjs/Lights/light";
  47663. export * from "babylonjs/Lights/shadowLight";
  47664. export * from "babylonjs/Lights/Shadows/index";
  47665. export * from "babylonjs/Lights/directionalLight";
  47666. export * from "babylonjs/Lights/hemisphericLight";
  47667. export * from "babylonjs/Lights/pointLight";
  47668. export * from "babylonjs/Lights/spotLight";
  47669. }
  47670. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  47671. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47672. /**
  47673. * Header information of HDR texture files.
  47674. */
  47675. export interface HDRInfo {
  47676. /**
  47677. * The height of the texture in pixels.
  47678. */
  47679. height: number;
  47680. /**
  47681. * The width of the texture in pixels.
  47682. */
  47683. width: number;
  47684. /**
  47685. * The index of the beginning of the data in the binary file.
  47686. */
  47687. dataPosition: number;
  47688. }
  47689. /**
  47690. * This groups tools to convert HDR texture to native colors array.
  47691. */
  47692. export class HDRTools {
  47693. private static Ldexp;
  47694. private static Rgbe2float;
  47695. private static readStringLine;
  47696. /**
  47697. * Reads header information from an RGBE texture stored in a native array.
  47698. * More information on this format are available here:
  47699. * https://en.wikipedia.org/wiki/RGBE_image_format
  47700. *
  47701. * @param uint8array The binary file stored in native array.
  47702. * @return The header information.
  47703. */
  47704. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47705. /**
  47706. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47707. * This RGBE texture needs to store the information as a panorama.
  47708. *
  47709. * More information on this format are available here:
  47710. * https://en.wikipedia.org/wiki/RGBE_image_format
  47711. *
  47712. * @param buffer The binary file stored in an array buffer.
  47713. * @param size The expected size of the extracted cubemap.
  47714. * @return The Cube Map information.
  47715. */
  47716. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47717. /**
  47718. * Returns the pixels data extracted from an RGBE texture.
  47719. * This pixels will be stored left to right up to down in the R G B order in one array.
  47720. *
  47721. * More information on this format are available here:
  47722. * https://en.wikipedia.org/wiki/RGBE_image_format
  47723. *
  47724. * @param uint8array The binary file stored in an array buffer.
  47725. * @param hdrInfo The header information of the file.
  47726. * @return The pixels data in RGB right to left up to down order.
  47727. */
  47728. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47729. private static RGBE_ReadPixels_RLE;
  47730. }
  47731. }
  47732. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  47733. import { Nullable } from "babylonjs/types";
  47734. import { Scene } from "babylonjs/scene";
  47735. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47736. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47737. /**
  47738. * This represents a texture coming from an HDR input.
  47739. *
  47740. * The only supported format is currently panorama picture stored in RGBE format.
  47741. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47742. */
  47743. export class HDRCubeTexture extends BaseTexture {
  47744. private static _facesMapping;
  47745. private _generateHarmonics;
  47746. private _noMipmap;
  47747. private _textureMatrix;
  47748. private _size;
  47749. private _onLoad;
  47750. private _onError;
  47751. /**
  47752. * The texture URL.
  47753. */
  47754. url: string;
  47755. /**
  47756. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47757. */
  47758. coordinatesMode: number;
  47759. protected _isBlocking: boolean;
  47760. /**
  47761. * Sets wether or not the texture is blocking during loading.
  47762. */
  47763. /**
  47764. * Gets wether or not the texture is blocking during loading.
  47765. */
  47766. isBlocking: boolean;
  47767. protected _rotationY: number;
  47768. /**
  47769. * Sets texture matrix rotation angle around Y axis in radians.
  47770. */
  47771. /**
  47772. * Gets texture matrix rotation angle around Y axis radians.
  47773. */
  47774. rotationY: number;
  47775. /**
  47776. * Gets or sets the center of the bounding box associated with the cube texture
  47777. * It must define where the camera used to render the texture was set
  47778. */
  47779. boundingBoxPosition: Vector3;
  47780. private _boundingBoxSize;
  47781. /**
  47782. * Gets or sets the size of the bounding box associated with the cube texture
  47783. * When defined, the cubemap will switch to local mode
  47784. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47785. * @example https://www.babylonjs-playground.com/#RNASML
  47786. */
  47787. boundingBoxSize: Vector3;
  47788. /**
  47789. * Instantiates an HDRTexture from the following parameters.
  47790. *
  47791. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47792. * @param scene The scene the texture will be used in
  47793. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47794. * @param noMipmap Forces to not generate the mipmap if true
  47795. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47796. * @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)
  47797. * @param reserved Reserved flag for internal use.
  47798. */
  47799. 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>);
  47800. /**
  47801. * Get the current class name of the texture useful for serialization or dynamic coding.
  47802. * @returns "HDRCubeTexture"
  47803. */
  47804. getClassName(): string;
  47805. /**
  47806. * Occurs when the file is raw .hdr file.
  47807. */
  47808. private loadTexture;
  47809. clone(): HDRCubeTexture;
  47810. delayLoad(): void;
  47811. /**
  47812. * Get the texture reflection matrix used to rotate/transform the reflection.
  47813. * @returns the reflection matrix
  47814. */
  47815. getReflectionTextureMatrix(): Matrix;
  47816. /**
  47817. * Set the texture reflection matrix used to rotate/transform the reflection.
  47818. * @param value Define the reflection matrix to set
  47819. */
  47820. setReflectionTextureMatrix(value: Matrix): void;
  47821. /**
  47822. * Parses a JSON representation of an HDR Texture in order to create the texture
  47823. * @param parsedTexture Define the JSON representation
  47824. * @param scene Define the scene the texture should be created in
  47825. * @param rootUrl Define the root url in case we need to load relative dependencies
  47826. * @returns the newly created texture after parsing
  47827. */
  47828. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47829. serialize(): any;
  47830. }
  47831. }
  47832. declare module "babylonjs/Physics/physicsEngine" {
  47833. import { Nullable } from "babylonjs/types";
  47834. import { Vector3 } from "babylonjs/Maths/math";
  47835. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47836. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47837. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47838. /**
  47839. * Class used to control physics engine
  47840. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47841. */
  47842. export class PhysicsEngine implements IPhysicsEngine {
  47843. private _physicsPlugin;
  47844. /**
  47845. * Global value used to control the smallest number supported by the simulation
  47846. */
  47847. static Epsilon: number;
  47848. private _impostors;
  47849. private _joints;
  47850. /**
  47851. * Gets the gravity vector used by the simulation
  47852. */
  47853. gravity: Vector3;
  47854. /**
  47855. * Factory used to create the default physics plugin.
  47856. * @returns The default physics plugin
  47857. */
  47858. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47859. /**
  47860. * Creates a new Physics Engine
  47861. * @param gravity defines the gravity vector used by the simulation
  47862. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47863. */
  47864. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47865. /**
  47866. * Sets the gravity vector used by the simulation
  47867. * @param gravity defines the gravity vector to use
  47868. */
  47869. setGravity(gravity: Vector3): void;
  47870. /**
  47871. * Set the time step of the physics engine.
  47872. * Default is 1/60.
  47873. * To slow it down, enter 1/600 for example.
  47874. * To speed it up, 1/30
  47875. * @param newTimeStep defines the new timestep to apply to this world.
  47876. */
  47877. setTimeStep(newTimeStep?: number): void;
  47878. /**
  47879. * Get the time step of the physics engine.
  47880. * @returns the current time step
  47881. */
  47882. getTimeStep(): number;
  47883. /**
  47884. * Release all resources
  47885. */
  47886. dispose(): void;
  47887. /**
  47888. * Gets the name of the current physics plugin
  47889. * @returns the name of the plugin
  47890. */
  47891. getPhysicsPluginName(): string;
  47892. /**
  47893. * Adding a new impostor for the impostor tracking.
  47894. * This will be done by the impostor itself.
  47895. * @param impostor the impostor to add
  47896. */
  47897. addImpostor(impostor: PhysicsImpostor): void;
  47898. /**
  47899. * Remove an impostor from the engine.
  47900. * This impostor and its mesh will not longer be updated by the physics engine.
  47901. * @param impostor the impostor to remove
  47902. */
  47903. removeImpostor(impostor: PhysicsImpostor): void;
  47904. /**
  47905. * Add a joint to the physics engine
  47906. * @param mainImpostor defines the main impostor to which the joint is added.
  47907. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47908. * @param joint defines the joint that will connect both impostors.
  47909. */
  47910. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47911. /**
  47912. * Removes a joint from the simulation
  47913. * @param mainImpostor defines the impostor used with the joint
  47914. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47915. * @param joint defines the joint to remove
  47916. */
  47917. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47918. /**
  47919. * Called by the scene. No need to call it.
  47920. * @param delta defines the timespam between frames
  47921. */
  47922. _step(delta: number): void;
  47923. /**
  47924. * Gets the current plugin used to run the simulation
  47925. * @returns current plugin
  47926. */
  47927. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47928. /**
  47929. * Gets the list of physic impostors
  47930. * @returns an array of PhysicsImpostor
  47931. */
  47932. getImpostors(): Array<PhysicsImpostor>;
  47933. /**
  47934. * Gets the impostor for a physics enabled object
  47935. * @param object defines the object impersonated by the impostor
  47936. * @returns the PhysicsImpostor or null if not found
  47937. */
  47938. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47939. /**
  47940. * Gets the impostor for a physics body object
  47941. * @param body defines physics body used by the impostor
  47942. * @returns the PhysicsImpostor or null if not found
  47943. */
  47944. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47945. }
  47946. }
  47947. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47948. import { Nullable } from "babylonjs/types";
  47949. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47951. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47952. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47953. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47954. /** @hidden */
  47955. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47956. private _useDeltaForWorldStep;
  47957. world: any;
  47958. name: string;
  47959. private _physicsMaterials;
  47960. private _fixedTimeStep;
  47961. BJSCANNON: any;
  47962. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47963. setGravity(gravity: Vector3): void;
  47964. setTimeStep(timeStep: number): void;
  47965. getTimeStep(): number;
  47966. executeStep(delta: number): void;
  47967. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47968. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47969. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47970. private _processChildMeshes;
  47971. removePhysicsBody(impostor: PhysicsImpostor): void;
  47972. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47973. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47974. private _addMaterial;
  47975. private _checkWithEpsilon;
  47976. private _createShape;
  47977. private _createHeightmap;
  47978. private _minus90X;
  47979. private _plus90X;
  47980. private _tmpPosition;
  47981. private _tmpDeltaPosition;
  47982. private _tmpUnityRotation;
  47983. private _updatePhysicsBodyTransformation;
  47984. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47985. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47986. isSupported(): boolean;
  47987. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47988. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47989. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47990. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47991. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47992. getBodyMass(impostor: PhysicsImpostor): number;
  47993. getBodyFriction(impostor: PhysicsImpostor): number;
  47994. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47995. getBodyRestitution(impostor: PhysicsImpostor): number;
  47996. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47997. sleepBody(impostor: PhysicsImpostor): void;
  47998. wakeUpBody(impostor: PhysicsImpostor): void;
  47999. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48000. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48001. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48002. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48003. getRadius(impostor: PhysicsImpostor): number;
  48004. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48005. dispose(): void;
  48006. private _extendNamespace;
  48007. }
  48008. }
  48009. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  48010. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48011. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48012. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48014. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48015. import { Nullable } from "babylonjs/types";
  48016. /** @hidden */
  48017. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48018. world: any;
  48019. name: string;
  48020. BJSOIMO: any;
  48021. constructor(iterations?: number, oimoInjection?: any);
  48022. setGravity(gravity: Vector3): void;
  48023. setTimeStep(timeStep: number): void;
  48024. getTimeStep(): number;
  48025. private _tmpImpostorsArray;
  48026. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48027. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48028. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48029. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48030. private _tmpPositionVector;
  48031. removePhysicsBody(impostor: PhysicsImpostor): void;
  48032. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48033. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48034. isSupported(): boolean;
  48035. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48036. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48037. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48038. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48039. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48040. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48041. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48042. getBodyMass(impostor: PhysicsImpostor): number;
  48043. getBodyFriction(impostor: PhysicsImpostor): number;
  48044. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48045. getBodyRestitution(impostor: PhysicsImpostor): number;
  48046. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48047. sleepBody(impostor: PhysicsImpostor): void;
  48048. wakeUpBody(impostor: PhysicsImpostor): void;
  48049. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48050. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48051. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48052. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48053. getRadius(impostor: PhysicsImpostor): number;
  48054. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48055. dispose(): void;
  48056. }
  48057. }
  48058. declare module "babylonjs/Probes/reflectionProbe" {
  48059. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48060. import { Vector3 } from "babylonjs/Maths/math";
  48061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48062. import { Nullable } from "babylonjs/types";
  48063. import { Scene } from "babylonjs/scene";
  48064. module "babylonjs/abstractScene" {
  48065. interface AbstractScene {
  48066. /**
  48067. * The list of reflection probes added to the scene
  48068. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48069. */
  48070. reflectionProbes: Array<ReflectionProbe>;
  48071. /**
  48072. * Removes the given reflection probe from this scene.
  48073. * @param toRemove The reflection probe to remove
  48074. * @returns The index of the removed reflection probe
  48075. */
  48076. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48077. /**
  48078. * Adds the given reflection probe to this scene.
  48079. * @param newReflectionProbe The reflection probe to add
  48080. */
  48081. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48082. }
  48083. }
  48084. /**
  48085. * Class used to generate realtime reflection / refraction cube textures
  48086. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48087. */
  48088. export class ReflectionProbe {
  48089. /** defines the name of the probe */
  48090. name: string;
  48091. private _scene;
  48092. private _renderTargetTexture;
  48093. private _projectionMatrix;
  48094. private _viewMatrix;
  48095. private _target;
  48096. private _add;
  48097. private _attachedMesh;
  48098. private _invertYAxis;
  48099. /** Gets or sets probe position (center of the cube map) */
  48100. position: Vector3;
  48101. /**
  48102. * Creates a new reflection probe
  48103. * @param name defines the name of the probe
  48104. * @param size defines the texture resolution (for each face)
  48105. * @param scene defines the hosting scene
  48106. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48107. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48108. */
  48109. constructor(
  48110. /** defines the name of the probe */
  48111. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48112. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48113. samples: number;
  48114. /** Gets or sets the refresh rate to use (on every frame by default) */
  48115. refreshRate: number;
  48116. /**
  48117. * Gets the hosting scene
  48118. * @returns a Scene
  48119. */
  48120. getScene(): Scene;
  48121. /** Gets the internal CubeTexture used to render to */
  48122. readonly cubeTexture: RenderTargetTexture;
  48123. /** Gets the list of meshes to render */
  48124. readonly renderList: Nullable<AbstractMesh[]>;
  48125. /**
  48126. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48127. * @param mesh defines the mesh to attach to
  48128. */
  48129. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48130. /**
  48131. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48132. * @param renderingGroupId The rendering group id corresponding to its index
  48133. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48134. */
  48135. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48136. /**
  48137. * Clean all associated resources
  48138. */
  48139. dispose(): void;
  48140. /**
  48141. * Converts the reflection probe information to a readable string for debug purpose.
  48142. * @param fullDetails Supports for multiple levels of logging within scene loading
  48143. * @returns the human readable reflection probe info
  48144. */
  48145. toString(fullDetails?: boolean): string;
  48146. /**
  48147. * Get the class name of the relfection probe.
  48148. * @returns "ReflectionProbe"
  48149. */
  48150. getClassName(): string;
  48151. /**
  48152. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48153. * @returns The JSON representation of the texture
  48154. */
  48155. serialize(): any;
  48156. /**
  48157. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48158. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48159. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48160. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48161. * @returns The parsed reflection probe if successful
  48162. */
  48163. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48164. }
  48165. }
  48166. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48167. /** @hidden */
  48168. export var _BabylonLoaderRegistered: boolean;
  48169. }
  48170. declare module "babylonjs/Loading/Plugins/index" {
  48171. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48172. }
  48173. declare module "babylonjs/Loading/index" {
  48174. export * from "babylonjs/Loading/loadingScreen";
  48175. export * from "babylonjs/Loading/Plugins/index";
  48176. export * from "babylonjs/Loading/sceneLoader";
  48177. export * from "babylonjs/Loading/sceneLoaderFlags";
  48178. }
  48179. declare module "babylonjs/Materials/Background/index" {
  48180. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48181. }
  48182. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48183. import { Scene } from "babylonjs/scene";
  48184. import { Color3 } from "babylonjs/Maths/math";
  48185. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48187. /**
  48188. * The Physically based simple base material of BJS.
  48189. *
  48190. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48191. * It is used as the base class for both the specGloss and metalRough conventions.
  48192. */
  48193. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48194. /**
  48195. * Number of Simultaneous lights allowed on the material.
  48196. */
  48197. maxSimultaneousLights: number;
  48198. /**
  48199. * If sets to true, disables all the lights affecting the material.
  48200. */
  48201. disableLighting: boolean;
  48202. /**
  48203. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48204. */
  48205. environmentTexture: BaseTexture;
  48206. /**
  48207. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48208. */
  48209. invertNormalMapX: boolean;
  48210. /**
  48211. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48212. */
  48213. invertNormalMapY: boolean;
  48214. /**
  48215. * Normal map used in the model.
  48216. */
  48217. normalTexture: BaseTexture;
  48218. /**
  48219. * Emissivie color used to self-illuminate the model.
  48220. */
  48221. emissiveColor: Color3;
  48222. /**
  48223. * Emissivie texture used to self-illuminate the model.
  48224. */
  48225. emissiveTexture: BaseTexture;
  48226. /**
  48227. * Occlusion Channel Strenght.
  48228. */
  48229. occlusionStrength: number;
  48230. /**
  48231. * Occlusion Texture of the material (adding extra occlusion effects).
  48232. */
  48233. occlusionTexture: BaseTexture;
  48234. /**
  48235. * Defines the alpha limits in alpha test mode.
  48236. */
  48237. alphaCutOff: number;
  48238. /**
  48239. * Gets the current double sided mode.
  48240. */
  48241. /**
  48242. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48243. */
  48244. doubleSided: boolean;
  48245. /**
  48246. * Stores the pre-calculated light information of a mesh in a texture.
  48247. */
  48248. lightmapTexture: BaseTexture;
  48249. /**
  48250. * If true, the light map contains occlusion information instead of lighting info.
  48251. */
  48252. useLightmapAsShadowmap: boolean;
  48253. /**
  48254. * Instantiates a new PBRMaterial instance.
  48255. *
  48256. * @param name The material name
  48257. * @param scene The scene the material will be use in.
  48258. */
  48259. constructor(name: string, scene: Scene);
  48260. getClassName(): string;
  48261. }
  48262. }
  48263. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  48264. import { Scene } from "babylonjs/scene";
  48265. import { Color3 } from "babylonjs/Maths/math";
  48266. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48267. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48268. /**
  48269. * The PBR material of BJS following the metal roughness convention.
  48270. *
  48271. * This fits to the PBR convention in the GLTF definition:
  48272. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48273. */
  48274. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48275. /**
  48276. * The base color has two different interpretations depending on the value of metalness.
  48277. * When the material is a metal, the base color is the specific measured reflectance value
  48278. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48279. * of the material.
  48280. */
  48281. baseColor: Color3;
  48282. /**
  48283. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48284. * well as opacity information in the alpha channel.
  48285. */
  48286. baseTexture: BaseTexture;
  48287. /**
  48288. * Specifies the metallic scalar value of the material.
  48289. * Can also be used to scale the metalness values of the metallic texture.
  48290. */
  48291. metallic: number;
  48292. /**
  48293. * Specifies the roughness scalar value of the material.
  48294. * Can also be used to scale the roughness values of the metallic texture.
  48295. */
  48296. roughness: number;
  48297. /**
  48298. * Texture containing both the metallic value in the B channel and the
  48299. * roughness value in the G channel to keep better precision.
  48300. */
  48301. metallicRoughnessTexture: BaseTexture;
  48302. /**
  48303. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48304. *
  48305. * @param name The material name
  48306. * @param scene The scene the material will be use in.
  48307. */
  48308. constructor(name: string, scene: Scene);
  48309. /**
  48310. * Return the currrent class name of the material.
  48311. */
  48312. getClassName(): string;
  48313. /**
  48314. * Makes a duplicate of the current material.
  48315. * @param name - name to use for the new material.
  48316. */
  48317. clone(name: string): PBRMetallicRoughnessMaterial;
  48318. /**
  48319. * Serialize the material to a parsable JSON object.
  48320. */
  48321. serialize(): any;
  48322. /**
  48323. * Parses a JSON object correponding to the serialize function.
  48324. */
  48325. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48326. }
  48327. }
  48328. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  48329. import { Scene } from "babylonjs/scene";
  48330. import { Color3 } from "babylonjs/Maths/math";
  48331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48332. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48333. /**
  48334. * The PBR material of BJS following the specular glossiness convention.
  48335. *
  48336. * This fits to the PBR convention in the GLTF definition:
  48337. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48338. */
  48339. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48340. /**
  48341. * Specifies the diffuse color of the material.
  48342. */
  48343. diffuseColor: Color3;
  48344. /**
  48345. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48346. * channel.
  48347. */
  48348. diffuseTexture: BaseTexture;
  48349. /**
  48350. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48351. */
  48352. specularColor: Color3;
  48353. /**
  48354. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48355. */
  48356. glossiness: number;
  48357. /**
  48358. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48359. */
  48360. specularGlossinessTexture: BaseTexture;
  48361. /**
  48362. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48363. *
  48364. * @param name The material name
  48365. * @param scene The scene the material will be use in.
  48366. */
  48367. constructor(name: string, scene: Scene);
  48368. /**
  48369. * Return the currrent class name of the material.
  48370. */
  48371. getClassName(): string;
  48372. /**
  48373. * Makes a duplicate of the current material.
  48374. * @param name - name to use for the new material.
  48375. */
  48376. clone(name: string): PBRSpecularGlossinessMaterial;
  48377. /**
  48378. * Serialize the material to a parsable JSON object.
  48379. */
  48380. serialize(): any;
  48381. /**
  48382. * Parses a JSON object correponding to the serialize function.
  48383. */
  48384. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48385. }
  48386. }
  48387. declare module "babylonjs/Materials/PBR/index" {
  48388. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48389. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48390. export * from "babylonjs/Materials/PBR/pbrMaterial";
  48391. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  48392. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  48393. }
  48394. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  48395. import { Nullable } from "babylonjs/types";
  48396. import { Scene } from "babylonjs/scene";
  48397. import { Matrix } from "babylonjs/Maths/math";
  48398. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48399. /**
  48400. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48401. * It can help converting any input color in a desired output one. This can then be used to create effects
  48402. * from sepia, black and white to sixties or futuristic rendering...
  48403. *
  48404. * The only supported format is currently 3dl.
  48405. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48406. */
  48407. export class ColorGradingTexture extends BaseTexture {
  48408. /**
  48409. * The current texture matrix. (will always be identity in color grading texture)
  48410. */
  48411. private _textureMatrix;
  48412. /**
  48413. * The texture URL.
  48414. */
  48415. url: string;
  48416. /**
  48417. * Empty line regex stored for GC.
  48418. */
  48419. private static _noneEmptyLineRegex;
  48420. private _engine;
  48421. /**
  48422. * Instantiates a ColorGradingTexture from the following parameters.
  48423. *
  48424. * @param url The location of the color gradind data (currently only supporting 3dl)
  48425. * @param scene The scene the texture will be used in
  48426. */
  48427. constructor(url: string, scene: Scene);
  48428. /**
  48429. * Returns the texture matrix used in most of the material.
  48430. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48431. */
  48432. getTextureMatrix(): Matrix;
  48433. /**
  48434. * Occurs when the file being loaded is a .3dl LUT file.
  48435. */
  48436. private load3dlTexture;
  48437. /**
  48438. * Starts the loading process of the texture.
  48439. */
  48440. private loadTexture;
  48441. /**
  48442. * Clones the color gradind texture.
  48443. */
  48444. clone(): ColorGradingTexture;
  48445. /**
  48446. * Called during delayed load for textures.
  48447. */
  48448. delayLoad(): void;
  48449. /**
  48450. * Parses a color grading texture serialized by Babylon.
  48451. * @param parsedTexture The texture information being parsedTexture
  48452. * @param scene The scene to load the texture in
  48453. * @param rootUrl The root url of the data assets to load
  48454. * @return A color gradind texture
  48455. */
  48456. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48457. /**
  48458. * Serializes the LUT texture to json format.
  48459. */
  48460. serialize(): any;
  48461. }
  48462. }
  48463. declare module "babylonjs/Misc/dds" {
  48464. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48465. import { Engine } from "babylonjs/Engines/engine";
  48466. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48467. import { Nullable } from "babylonjs/types";
  48468. import { Scene } from "babylonjs/scene";
  48469. /**
  48470. * Direct draw surface info
  48471. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48472. */
  48473. export interface DDSInfo {
  48474. /**
  48475. * Width of the texture
  48476. */
  48477. width: number;
  48478. /**
  48479. * Width of the texture
  48480. */
  48481. height: number;
  48482. /**
  48483. * Number of Mipmaps for the texture
  48484. * @see https://en.wikipedia.org/wiki/Mipmap
  48485. */
  48486. mipmapCount: number;
  48487. /**
  48488. * If the textures format is a known fourCC format
  48489. * @see https://www.fourcc.org/
  48490. */
  48491. isFourCC: boolean;
  48492. /**
  48493. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48494. */
  48495. isRGB: boolean;
  48496. /**
  48497. * If the texture is a lumincance format
  48498. */
  48499. isLuminance: boolean;
  48500. /**
  48501. * If this is a cube texture
  48502. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48503. */
  48504. isCube: boolean;
  48505. /**
  48506. * If the texture is a compressed format eg. FOURCC_DXT1
  48507. */
  48508. isCompressed: boolean;
  48509. /**
  48510. * The dxgiFormat of the texture
  48511. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48512. */
  48513. dxgiFormat: number;
  48514. /**
  48515. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48516. */
  48517. textureType: number;
  48518. /**
  48519. * Sphericle polynomial created for the dds texture
  48520. */
  48521. sphericalPolynomial?: SphericalPolynomial;
  48522. }
  48523. /**
  48524. * Class used to provide DDS decompression tools
  48525. */
  48526. export class DDSTools {
  48527. /**
  48528. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48529. */
  48530. static StoreLODInAlphaChannel: boolean;
  48531. /**
  48532. * Gets DDS information from an array buffer
  48533. * @param arrayBuffer defines the array buffer to read data from
  48534. * @returns the DDS information
  48535. */
  48536. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48537. private static _FloatView;
  48538. private static _Int32View;
  48539. private static _ToHalfFloat;
  48540. private static _FromHalfFloat;
  48541. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48542. private static _GetHalfFloatRGBAArrayBuffer;
  48543. private static _GetFloatRGBAArrayBuffer;
  48544. private static _GetFloatAsUIntRGBAArrayBuffer;
  48545. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48546. private static _GetRGBAArrayBuffer;
  48547. private static _ExtractLongWordOrder;
  48548. private static _GetRGBArrayBuffer;
  48549. private static _GetLuminanceArrayBuffer;
  48550. /**
  48551. * Uploads DDS Levels to a Babylon Texture
  48552. * @hidden
  48553. */
  48554. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48555. }
  48556. module "babylonjs/Engines/engine" {
  48557. interface Engine {
  48558. /**
  48559. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48560. * @param rootUrl defines the url where the file to load is located
  48561. * @param scene defines the current scene
  48562. * @param lodScale defines scale to apply to the mip map selection
  48563. * @param lodOffset defines offset to apply to the mip map selection
  48564. * @param onLoad defines an optional callback raised when the texture is loaded
  48565. * @param onError defines an optional callback raised if there is an issue to load the texture
  48566. * @param format defines the format of the data
  48567. * @param forcedExtension defines the extension to use to pick the right loader
  48568. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48569. * @returns the cube texture as an InternalTexture
  48570. */
  48571. 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;
  48572. }
  48573. }
  48574. }
  48575. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48576. import { Nullable } from "babylonjs/types";
  48577. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48578. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48579. /**
  48580. * Implementation of the DDS Texture Loader.
  48581. * @hidden
  48582. */
  48583. export class _DDSTextureLoader implements IInternalTextureLoader {
  48584. /**
  48585. * Defines wether the loader supports cascade loading the different faces.
  48586. */
  48587. readonly supportCascades: boolean;
  48588. /**
  48589. * This returns if the loader support the current file information.
  48590. * @param extension defines the file extension of the file being loaded
  48591. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48592. * @param fallback defines the fallback internal texture if any
  48593. * @param isBase64 defines whether the texture is encoded as a base64
  48594. * @param isBuffer defines whether the texture data are stored as a buffer
  48595. * @returns true if the loader can load the specified file
  48596. */
  48597. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48598. /**
  48599. * Transform the url before loading if required.
  48600. * @param rootUrl the url of the texture
  48601. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48602. * @returns the transformed texture
  48603. */
  48604. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48605. /**
  48606. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48607. * @param rootUrl the url of the texture
  48608. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48609. * @returns the fallback texture
  48610. */
  48611. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48612. /**
  48613. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48614. * @param data contains the texture data
  48615. * @param texture defines the BabylonJS internal texture
  48616. * @param createPolynomials will be true if polynomials have been requested
  48617. * @param onLoad defines the callback to trigger once the texture is ready
  48618. * @param onError defines the callback to trigger in case of error
  48619. */
  48620. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48621. /**
  48622. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48623. * @param data contains the texture data
  48624. * @param texture defines the BabylonJS internal texture
  48625. * @param callback defines the method to call once ready to upload
  48626. */
  48627. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48628. }
  48629. }
  48630. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48631. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48632. /** @hidden */
  48633. export var rgbdEncodePixelShader: {
  48634. name: string;
  48635. shader: string;
  48636. };
  48637. }
  48638. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48639. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48640. /** @hidden */
  48641. export var rgbdDecodePixelShader: {
  48642. name: string;
  48643. shader: string;
  48644. };
  48645. }
  48646. declare module "babylonjs/Misc/environmentTextureTools" {
  48647. import { Nullable } from "babylonjs/types";
  48648. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48649. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48650. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48651. import "babylonjs/Shaders/rgbdEncode.fragment";
  48652. import "babylonjs/Shaders/rgbdDecode.fragment";
  48653. /**
  48654. * Raw texture data and descriptor sufficient for WebGL texture upload
  48655. */
  48656. export interface EnvironmentTextureInfo {
  48657. /**
  48658. * Version of the environment map
  48659. */
  48660. version: number;
  48661. /**
  48662. * Width of image
  48663. */
  48664. width: number;
  48665. /**
  48666. * Irradiance information stored in the file.
  48667. */
  48668. irradiance: any;
  48669. /**
  48670. * Specular information stored in the file.
  48671. */
  48672. specular: any;
  48673. }
  48674. /**
  48675. * Sets of helpers addressing the serialization and deserialization of environment texture
  48676. * stored in a BabylonJS env file.
  48677. * Those files are usually stored as .env files.
  48678. */
  48679. export class EnvironmentTextureTools {
  48680. /**
  48681. * Magic number identifying the env file.
  48682. */
  48683. private static _MagicBytes;
  48684. /**
  48685. * Gets the environment info from an env file.
  48686. * @param data The array buffer containing the .env bytes.
  48687. * @returns the environment file info (the json header) if successfully parsed.
  48688. */
  48689. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48690. /**
  48691. * Creates an environment texture from a loaded cube texture.
  48692. * @param texture defines the cube texture to convert in env file
  48693. * @return a promise containing the environment data if succesfull.
  48694. */
  48695. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48696. /**
  48697. * Creates a JSON representation of the spherical data.
  48698. * @param texture defines the texture containing the polynomials
  48699. * @return the JSON representation of the spherical info
  48700. */
  48701. private static _CreateEnvTextureIrradiance;
  48702. /**
  48703. * Uploads the texture info contained in the env file to the GPU.
  48704. * @param texture defines the internal texture to upload to
  48705. * @param arrayBuffer defines the buffer cotaining the data to load
  48706. * @param info defines the texture info retrieved through the GetEnvInfo method
  48707. * @returns a promise
  48708. */
  48709. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48710. /**
  48711. * Uploads the levels of image data to the GPU.
  48712. * @param texture defines the internal texture to upload to
  48713. * @param imageData defines the array buffer views of image data [mipmap][face]
  48714. * @returns a promise
  48715. */
  48716. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48717. /**
  48718. * Uploads spherical polynomials information to the texture.
  48719. * @param texture defines the texture we are trying to upload the information to
  48720. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48721. */
  48722. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48723. /** @hidden */
  48724. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48725. }
  48726. }
  48727. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48728. import { Nullable } from "babylonjs/types";
  48729. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48730. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48731. /**
  48732. * Implementation of the ENV Texture Loader.
  48733. * @hidden
  48734. */
  48735. export class _ENVTextureLoader implements IInternalTextureLoader {
  48736. /**
  48737. * Defines wether the loader supports cascade loading the different faces.
  48738. */
  48739. readonly supportCascades: boolean;
  48740. /**
  48741. * This returns if the loader support the current file information.
  48742. * @param extension defines the file extension of the file being loaded
  48743. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48744. * @param fallback defines the fallback internal texture if any
  48745. * @param isBase64 defines whether the texture is encoded as a base64
  48746. * @param isBuffer defines whether the texture data are stored as a buffer
  48747. * @returns true if the loader can load the specified file
  48748. */
  48749. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48750. /**
  48751. * Transform the url before loading if required.
  48752. * @param rootUrl the url of the texture
  48753. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48754. * @returns the transformed texture
  48755. */
  48756. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48757. /**
  48758. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48759. * @param rootUrl the url of the texture
  48760. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48761. * @returns the fallback texture
  48762. */
  48763. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48764. /**
  48765. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48766. * @param data contains the texture data
  48767. * @param texture defines the BabylonJS internal texture
  48768. * @param createPolynomials will be true if polynomials have been requested
  48769. * @param onLoad defines the callback to trigger once the texture is ready
  48770. * @param onError defines the callback to trigger in case of error
  48771. */
  48772. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48773. /**
  48774. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48775. * @param data contains the texture data
  48776. * @param texture defines the BabylonJS internal texture
  48777. * @param callback defines the method to call once ready to upload
  48778. */
  48779. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48780. }
  48781. }
  48782. declare module "babylonjs/Misc/khronosTextureContainer" {
  48783. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48784. /**
  48785. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48786. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48787. */
  48788. export class KhronosTextureContainer {
  48789. /** contents of the KTX container file */
  48790. arrayBuffer: any;
  48791. private static HEADER_LEN;
  48792. private static COMPRESSED_2D;
  48793. private static COMPRESSED_3D;
  48794. private static TEX_2D;
  48795. private static TEX_3D;
  48796. /**
  48797. * Gets the openGL type
  48798. */
  48799. glType: number;
  48800. /**
  48801. * Gets the openGL type size
  48802. */
  48803. glTypeSize: number;
  48804. /**
  48805. * Gets the openGL format
  48806. */
  48807. glFormat: number;
  48808. /**
  48809. * Gets the openGL internal format
  48810. */
  48811. glInternalFormat: number;
  48812. /**
  48813. * Gets the base internal format
  48814. */
  48815. glBaseInternalFormat: number;
  48816. /**
  48817. * Gets image width in pixel
  48818. */
  48819. pixelWidth: number;
  48820. /**
  48821. * Gets image height in pixel
  48822. */
  48823. pixelHeight: number;
  48824. /**
  48825. * Gets image depth in pixels
  48826. */
  48827. pixelDepth: number;
  48828. /**
  48829. * Gets the number of array elements
  48830. */
  48831. numberOfArrayElements: number;
  48832. /**
  48833. * Gets the number of faces
  48834. */
  48835. numberOfFaces: number;
  48836. /**
  48837. * Gets the number of mipmap levels
  48838. */
  48839. numberOfMipmapLevels: number;
  48840. /**
  48841. * Gets the bytes of key value data
  48842. */
  48843. bytesOfKeyValueData: number;
  48844. /**
  48845. * Gets the load type
  48846. */
  48847. loadType: number;
  48848. /**
  48849. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48850. */
  48851. isInvalid: boolean;
  48852. /**
  48853. * Creates a new KhronosTextureContainer
  48854. * @param arrayBuffer contents of the KTX container file
  48855. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48856. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48857. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48858. */
  48859. constructor(
  48860. /** contents of the KTX container file */
  48861. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48862. /**
  48863. * Uploads KTX content to a Babylon Texture.
  48864. * It is assumed that the texture has already been created & is currently bound
  48865. * @hidden
  48866. */
  48867. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48868. private _upload2DCompressedLevels;
  48869. }
  48870. }
  48871. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48872. import { Nullable } from "babylonjs/types";
  48873. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48874. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48875. /**
  48876. * Implementation of the KTX Texture Loader.
  48877. * @hidden
  48878. */
  48879. export class _KTXTextureLoader implements IInternalTextureLoader {
  48880. /**
  48881. * Defines wether the loader supports cascade loading the different faces.
  48882. */
  48883. readonly supportCascades: boolean;
  48884. /**
  48885. * This returns if the loader support the current file information.
  48886. * @param extension defines the file extension of the file being loaded
  48887. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48888. * @param fallback defines the fallback internal texture if any
  48889. * @param isBase64 defines whether the texture is encoded as a base64
  48890. * @param isBuffer defines whether the texture data are stored as a buffer
  48891. * @returns true if the loader can load the specified file
  48892. */
  48893. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48894. /**
  48895. * Transform the url before loading if required.
  48896. * @param rootUrl the url of the texture
  48897. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48898. * @returns the transformed texture
  48899. */
  48900. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48901. /**
  48902. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48903. * @param rootUrl the url of the texture
  48904. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48905. * @returns the fallback texture
  48906. */
  48907. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48908. /**
  48909. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48910. * @param data contains the texture data
  48911. * @param texture defines the BabylonJS internal texture
  48912. * @param createPolynomials will be true if polynomials have been requested
  48913. * @param onLoad defines the callback to trigger once the texture is ready
  48914. * @param onError defines the callback to trigger in case of error
  48915. */
  48916. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48917. /**
  48918. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48919. * @param data contains the texture data
  48920. * @param texture defines the BabylonJS internal texture
  48921. * @param callback defines the method to call once ready to upload
  48922. */
  48923. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48924. }
  48925. }
  48926. declare module "babylonjs/Misc/tga" {
  48927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48928. /**
  48929. * Based on jsTGALoader - Javascript loader for TGA file
  48930. * By Vincent Thibault
  48931. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48932. */
  48933. export class TGATools {
  48934. private static _TYPE_INDEXED;
  48935. private static _TYPE_RGB;
  48936. private static _TYPE_GREY;
  48937. private static _TYPE_RLE_INDEXED;
  48938. private static _TYPE_RLE_RGB;
  48939. private static _TYPE_RLE_GREY;
  48940. private static _ORIGIN_MASK;
  48941. private static _ORIGIN_SHIFT;
  48942. private static _ORIGIN_BL;
  48943. private static _ORIGIN_BR;
  48944. private static _ORIGIN_UL;
  48945. private static _ORIGIN_UR;
  48946. /**
  48947. * Gets the header of a TGA file
  48948. * @param data defines the TGA data
  48949. * @returns the header
  48950. */
  48951. static GetTGAHeader(data: Uint8Array): any;
  48952. /**
  48953. * Uploads TGA content to a Babylon Texture
  48954. * @hidden
  48955. */
  48956. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48957. /** @hidden */
  48958. 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;
  48959. /** @hidden */
  48960. 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;
  48961. /** @hidden */
  48962. 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;
  48963. /** @hidden */
  48964. 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;
  48965. /** @hidden */
  48966. 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;
  48967. /** @hidden */
  48968. 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;
  48969. }
  48970. }
  48971. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48972. import { Nullable } from "babylonjs/types";
  48973. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48974. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48975. /**
  48976. * Implementation of the TGA Texture Loader.
  48977. * @hidden
  48978. */
  48979. export class _TGATextureLoader implements IInternalTextureLoader {
  48980. /**
  48981. * Defines wether the loader supports cascade loading the different faces.
  48982. */
  48983. readonly supportCascades: boolean;
  48984. /**
  48985. * This returns if the loader support the current file information.
  48986. * @param extension defines the file extension of the file being loaded
  48987. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48988. * @param fallback defines the fallback internal texture if any
  48989. * @param isBase64 defines whether the texture is encoded as a base64
  48990. * @param isBuffer defines whether the texture data are stored as a buffer
  48991. * @returns true if the loader can load the specified file
  48992. */
  48993. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48994. /**
  48995. * Transform the url before loading if required.
  48996. * @param rootUrl the url of the texture
  48997. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48998. * @returns the transformed texture
  48999. */
  49000. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49001. /**
  49002. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49003. * @param rootUrl the url of the texture
  49004. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49005. * @returns the fallback texture
  49006. */
  49007. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49008. /**
  49009. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49010. * @param data contains the texture data
  49011. * @param texture defines the BabylonJS internal texture
  49012. * @param createPolynomials will be true if polynomials have been requested
  49013. * @param onLoad defines the callback to trigger once the texture is ready
  49014. * @param onError defines the callback to trigger in case of error
  49015. */
  49016. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49017. /**
  49018. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49019. * @param data contains the texture data
  49020. * @param texture defines the BabylonJS internal texture
  49021. * @param callback defines the method to call once ready to upload
  49022. */
  49023. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49024. }
  49025. }
  49026. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49027. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49028. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49029. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49030. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49031. }
  49032. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49033. import { Scene } from "babylonjs/scene";
  49034. import { Texture } from "babylonjs/Materials/Textures/texture";
  49035. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49036. /**
  49037. * 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.
  49038. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49039. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49040. */
  49041. export class CustomProceduralTexture extends ProceduralTexture {
  49042. private _animate;
  49043. private _time;
  49044. private _config;
  49045. private _texturePath;
  49046. /**
  49047. * Instantiates a new Custom Procedural Texture.
  49048. * 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.
  49049. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49050. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49051. * @param name Define the name of the texture
  49052. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49053. * @param size Define the size of the texture to create
  49054. * @param scene Define the scene the texture belongs to
  49055. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49056. * @param generateMipMaps Define if the texture should creates mip maps or not
  49057. */
  49058. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49059. private _loadJson;
  49060. /**
  49061. * Is the texture ready to be used ? (rendered at least once)
  49062. * @returns true if ready, otherwise, false.
  49063. */
  49064. isReady(): boolean;
  49065. /**
  49066. * Render the texture to its associated render target.
  49067. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49068. */
  49069. render(useCameraPostProcess?: boolean): void;
  49070. /**
  49071. * Update the list of dependant textures samplers in the shader.
  49072. */
  49073. updateTextures(): void;
  49074. /**
  49075. * Update the uniform values of the procedural texture in the shader.
  49076. */
  49077. updateShaderUniforms(): void;
  49078. /**
  49079. * Define if the texture animates or not.
  49080. */
  49081. animate: boolean;
  49082. }
  49083. }
  49084. declare module "babylonjs/Shaders/noise.fragment" {
  49085. /** @hidden */
  49086. export var noisePixelShader: {
  49087. name: string;
  49088. shader: string;
  49089. };
  49090. }
  49091. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49092. import { Nullable } from "babylonjs/types";
  49093. import { Scene } from "babylonjs/scene";
  49094. import { Texture } from "babylonjs/Materials/Textures/texture";
  49095. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49096. import "babylonjs/Shaders/noise.fragment";
  49097. /**
  49098. * Class used to generate noise procedural textures
  49099. */
  49100. export class NoiseProceduralTexture extends ProceduralTexture {
  49101. private _time;
  49102. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49103. brightness: number;
  49104. /** Defines the number of octaves to process */
  49105. octaves: number;
  49106. /** Defines the level of persistence (0.8 by default) */
  49107. persistence: number;
  49108. /** Gets or sets animation speed factor (default is 1) */
  49109. animationSpeedFactor: number;
  49110. /**
  49111. * Creates a new NoiseProceduralTexture
  49112. * @param name defines the name fo the texture
  49113. * @param size defines the size of the texture (default is 256)
  49114. * @param scene defines the hosting scene
  49115. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49116. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49117. */
  49118. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49119. private _updateShaderUniforms;
  49120. protected _getDefines(): string;
  49121. /** Generate the current state of the procedural texture */
  49122. render(useCameraPostProcess?: boolean): void;
  49123. /**
  49124. * Serializes this noise procedural texture
  49125. * @returns a serialized noise procedural texture object
  49126. */
  49127. serialize(): any;
  49128. /**
  49129. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49130. * @param parsedTexture defines parsed texture data
  49131. * @param scene defines the current scene
  49132. * @param rootUrl defines the root URL containing noise procedural texture information
  49133. * @returns a parsed NoiseProceduralTexture
  49134. */
  49135. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49136. }
  49137. }
  49138. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49139. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49140. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49141. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49142. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49143. }
  49144. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49145. import { Nullable } from "babylonjs/types";
  49146. import { Scene } from "babylonjs/scene";
  49147. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49148. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49149. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49150. /**
  49151. * Raw cube texture where the raw buffers are passed in
  49152. */
  49153. export class RawCubeTexture extends CubeTexture {
  49154. /**
  49155. * Creates a cube texture where the raw buffers are passed in.
  49156. * @param scene defines the scene the texture is attached to
  49157. * @param data defines the array of data to use to create each face
  49158. * @param size defines the size of the textures
  49159. * @param format defines the format of the data
  49160. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49161. * @param generateMipMaps defines if the engine should generate the mip levels
  49162. * @param invertY defines if data must be stored with Y axis inverted
  49163. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49164. * @param compression defines the compression used (null by default)
  49165. */
  49166. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49167. /**
  49168. * Updates the raw cube texture.
  49169. * @param data defines the data to store
  49170. * @param format defines the data format
  49171. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49172. * @param invertY defines if data must be stored with Y axis inverted
  49173. * @param compression defines the compression used (null by default)
  49174. * @param level defines which level of the texture to update
  49175. */
  49176. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49177. /**
  49178. * Updates a raw cube texture with RGBD encoded data.
  49179. * @param data defines the array of data [mipmap][face] to use to create each face
  49180. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49181. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49182. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49183. * @returns a promsie that resolves when the operation is complete
  49184. */
  49185. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49186. /**
  49187. * Clones the raw cube texture.
  49188. * @return a new cube texture
  49189. */
  49190. clone(): CubeTexture;
  49191. /** @hidden */
  49192. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49193. }
  49194. }
  49195. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49196. import { Scene } from "babylonjs/scene";
  49197. import { Texture } from "babylonjs/Materials/Textures/texture";
  49198. /**
  49199. * Class used to store 3D textures containing user data
  49200. */
  49201. export class RawTexture3D extends Texture {
  49202. /** Gets or sets the texture format to use */
  49203. format: number;
  49204. private _engine;
  49205. /**
  49206. * Create a new RawTexture3D
  49207. * @param data defines the data of the texture
  49208. * @param width defines the width of the texture
  49209. * @param height defines the height of the texture
  49210. * @param depth defines the depth of the texture
  49211. * @param format defines the texture format to use
  49212. * @param scene defines the hosting scene
  49213. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49214. * @param invertY defines if texture must be stored with Y axis inverted
  49215. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49216. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49217. */
  49218. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49219. /** Gets or sets the texture format to use */
  49220. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49221. /**
  49222. * Update the texture with new data
  49223. * @param data defines the data to store in the texture
  49224. */
  49225. update(data: ArrayBufferView): void;
  49226. }
  49227. }
  49228. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49229. import { Scene } from "babylonjs/scene";
  49230. import { Plane } from "babylonjs/Maths/math";
  49231. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49232. /**
  49233. * Creates a refraction texture used by refraction channel of the standard material.
  49234. * It is like a mirror but to see through a material.
  49235. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49236. */
  49237. export class RefractionTexture extends RenderTargetTexture {
  49238. /**
  49239. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49240. * 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.
  49241. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49242. */
  49243. refractionPlane: Plane;
  49244. /**
  49245. * Define how deep under the surface we should see.
  49246. */
  49247. depth: number;
  49248. /**
  49249. * Creates a refraction texture used by refraction channel of the standard material.
  49250. * It is like a mirror but to see through a material.
  49251. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49252. * @param name Define the texture name
  49253. * @param size Define the size of the underlying texture
  49254. * @param scene Define the scene the refraction belongs to
  49255. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49256. */
  49257. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49258. /**
  49259. * Clone the refraction texture.
  49260. * @returns the cloned texture
  49261. */
  49262. clone(): RefractionTexture;
  49263. /**
  49264. * Serialize the texture to a JSON representation you could use in Parse later on
  49265. * @returns the serialized JSON representation
  49266. */
  49267. serialize(): any;
  49268. }
  49269. }
  49270. declare module "babylonjs/Materials/Textures/index" {
  49271. export * from "babylonjs/Materials/Textures/baseTexture";
  49272. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49273. export * from "babylonjs/Materials/Textures/cubeTexture";
  49274. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49275. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49276. export * from "babylonjs/Materials/Textures/internalTexture";
  49277. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49278. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49279. export * from "babylonjs/Materials/Textures/Loaders/index";
  49280. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49281. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49282. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49283. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49284. export * from "babylonjs/Materials/Textures/rawTexture";
  49285. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49286. export * from "babylonjs/Materials/Textures/refractionTexture";
  49287. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49288. export * from "babylonjs/Materials/Textures/texture";
  49289. export * from "babylonjs/Materials/Textures/videoTexture";
  49290. }
  49291. declare module "babylonjs/Materials/index" {
  49292. export * from "babylonjs/Materials/Background/index";
  49293. export * from "babylonjs/Materials/colorCurves";
  49294. export * from "babylonjs/Materials/effect";
  49295. export * from "babylonjs/Materials/fresnelParameters";
  49296. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49297. export * from "babylonjs/Materials/material";
  49298. export * from "babylonjs/Materials/materialDefines";
  49299. export * from "babylonjs/Materials/materialHelper";
  49300. export * from "babylonjs/Materials/multiMaterial";
  49301. export * from "babylonjs/Materials/PBR/index";
  49302. export * from "babylonjs/Materials/pushMaterial";
  49303. export * from "babylonjs/Materials/shaderMaterial";
  49304. export * from "babylonjs/Materials/standardMaterial";
  49305. export * from "babylonjs/Materials/Textures/index";
  49306. export * from "babylonjs/Materials/uniformBuffer";
  49307. export * from "babylonjs/Materials/materialFlags";
  49308. }
  49309. declare module "babylonjs/Maths/index" {
  49310. export * from "babylonjs/Maths/math.scalar";
  49311. export * from "babylonjs/Maths/math";
  49312. export * from "babylonjs/Maths/sphericalPolynomial";
  49313. }
  49314. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49315. import { IDisposable } from "babylonjs/scene";
  49316. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49317. /**
  49318. * Configuration for Draco compression
  49319. */
  49320. export interface IDracoCompressionConfiguration {
  49321. /**
  49322. * Configuration for the decoder.
  49323. */
  49324. decoder?: {
  49325. /**
  49326. * The url to the WebAssembly module.
  49327. */
  49328. wasmUrl?: string;
  49329. /**
  49330. * The url to the WebAssembly binary.
  49331. */
  49332. wasmBinaryUrl?: string;
  49333. /**
  49334. * The url to the fallback JavaScript module.
  49335. */
  49336. fallbackUrl?: string;
  49337. };
  49338. }
  49339. /**
  49340. * Draco compression (https://google.github.io/draco/)
  49341. *
  49342. * This class wraps the Draco module.
  49343. *
  49344. * **Encoder**
  49345. *
  49346. * The encoder is not currently implemented.
  49347. *
  49348. * **Decoder**
  49349. *
  49350. * 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.
  49351. *
  49352. * To update the configuration, use the following code:
  49353. * ```javascript
  49354. * DracoCompression.Configuration = {
  49355. * decoder: {
  49356. * wasmUrl: "<url to the WebAssembly library>",
  49357. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49358. * fallbackUrl: "<url to the fallback JavaScript library>",
  49359. * }
  49360. * };
  49361. * ```
  49362. *
  49363. * 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.
  49364. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49365. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49366. *
  49367. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49368. * ```javascript
  49369. * var dracoCompression = new DracoCompression();
  49370. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49371. * [VertexBuffer.PositionKind]: 0
  49372. * });
  49373. * ```
  49374. *
  49375. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49376. */
  49377. export class DracoCompression implements IDisposable {
  49378. private static _DecoderModulePromise;
  49379. /**
  49380. * The configuration. Defaults to the following urls:
  49381. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49382. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49383. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49384. */
  49385. static Configuration: IDracoCompressionConfiguration;
  49386. /**
  49387. * Returns true if the decoder is available.
  49388. */
  49389. static readonly DecoderAvailable: boolean;
  49390. /**
  49391. * Constructor
  49392. */
  49393. constructor();
  49394. /**
  49395. * Stop all async operations and release resources.
  49396. */
  49397. dispose(): void;
  49398. /**
  49399. * Decode Draco compressed mesh data to vertex data.
  49400. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49401. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49402. * @returns A promise that resolves with the decoded vertex data
  49403. */
  49404. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49405. [kind: string]: number;
  49406. }): Promise<VertexData>;
  49407. private static _GetDecoderModule;
  49408. private static _LoadScriptAsync;
  49409. private static _LoadFileAsync;
  49410. }
  49411. }
  49412. declare module "babylonjs/Meshes/Compression/index" {
  49413. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49414. }
  49415. declare module "babylonjs/Meshes/csg" {
  49416. import { Nullable } from "babylonjs/types";
  49417. import { Scene } from "babylonjs/scene";
  49418. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49419. import { Mesh } from "babylonjs/Meshes/mesh";
  49420. import { Material } from "babylonjs/Materials/material";
  49421. /**
  49422. * Class for building Constructive Solid Geometry
  49423. */
  49424. export class CSG {
  49425. private polygons;
  49426. /**
  49427. * The world matrix
  49428. */
  49429. matrix: Matrix;
  49430. /**
  49431. * Stores the position
  49432. */
  49433. position: Vector3;
  49434. /**
  49435. * Stores the rotation
  49436. */
  49437. rotation: Vector3;
  49438. /**
  49439. * Stores the rotation quaternion
  49440. */
  49441. rotationQuaternion: Nullable<Quaternion>;
  49442. /**
  49443. * Stores the scaling vector
  49444. */
  49445. scaling: Vector3;
  49446. /**
  49447. * Convert the Mesh to CSG
  49448. * @param mesh The Mesh to convert to CSG
  49449. * @returns A new CSG from the Mesh
  49450. */
  49451. static FromMesh(mesh: Mesh): CSG;
  49452. /**
  49453. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49454. * @param polygons Polygons used to construct a CSG solid
  49455. */
  49456. private static FromPolygons;
  49457. /**
  49458. * Clones, or makes a deep copy, of the CSG
  49459. * @returns A new CSG
  49460. */
  49461. clone(): CSG;
  49462. /**
  49463. * Unions this CSG with another CSG
  49464. * @param csg The CSG to union against this CSG
  49465. * @returns The unioned CSG
  49466. */
  49467. union(csg: CSG): CSG;
  49468. /**
  49469. * Unions this CSG with another CSG in place
  49470. * @param csg The CSG to union against this CSG
  49471. */
  49472. unionInPlace(csg: CSG): void;
  49473. /**
  49474. * Subtracts this CSG with another CSG
  49475. * @param csg The CSG to subtract against this CSG
  49476. * @returns A new CSG
  49477. */
  49478. subtract(csg: CSG): CSG;
  49479. /**
  49480. * Subtracts this CSG with another CSG in place
  49481. * @param csg The CSG to subtact against this CSG
  49482. */
  49483. subtractInPlace(csg: CSG): void;
  49484. /**
  49485. * Intersect this CSG with another CSG
  49486. * @param csg The CSG to intersect against this CSG
  49487. * @returns A new CSG
  49488. */
  49489. intersect(csg: CSG): CSG;
  49490. /**
  49491. * Intersects this CSG with another CSG in place
  49492. * @param csg The CSG to intersect against this CSG
  49493. */
  49494. intersectInPlace(csg: CSG): void;
  49495. /**
  49496. * Return a new CSG solid with solid and empty space switched. This solid is
  49497. * not modified.
  49498. * @returns A new CSG solid with solid and empty space switched
  49499. */
  49500. inverse(): CSG;
  49501. /**
  49502. * Inverses the CSG in place
  49503. */
  49504. inverseInPlace(): void;
  49505. /**
  49506. * This is used to keep meshes transformations so they can be restored
  49507. * when we build back a Babylon Mesh
  49508. * NB : All CSG operations are performed in world coordinates
  49509. * @param csg The CSG to copy the transform attributes from
  49510. * @returns This CSG
  49511. */
  49512. copyTransformAttributes(csg: CSG): CSG;
  49513. /**
  49514. * Build Raw mesh from CSG
  49515. * Coordinates here are in world space
  49516. * @param name The name of the mesh geometry
  49517. * @param scene The Scene
  49518. * @param keepSubMeshes Specifies if the submeshes should be kept
  49519. * @returns A new Mesh
  49520. */
  49521. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49522. /**
  49523. * Build Mesh from CSG taking material and transforms into account
  49524. * @param name The name of the Mesh
  49525. * @param material The material of the Mesh
  49526. * @param scene The Scene
  49527. * @param keepSubMeshes Specifies if submeshes should be kept
  49528. * @returns The new Mesh
  49529. */
  49530. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49531. }
  49532. }
  49533. declare module "babylonjs/Meshes/trailMesh" {
  49534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49535. import { Mesh } from "babylonjs/Meshes/mesh";
  49536. import { Scene } from "babylonjs/scene";
  49537. /**
  49538. * Class used to create a trail following a mesh
  49539. */
  49540. export class TrailMesh extends Mesh {
  49541. private _generator;
  49542. private _autoStart;
  49543. private _running;
  49544. private _diameter;
  49545. private _length;
  49546. private _sectionPolygonPointsCount;
  49547. private _sectionVectors;
  49548. private _sectionNormalVectors;
  49549. private _beforeRenderObserver;
  49550. /**
  49551. * @constructor
  49552. * @param name The value used by scene.getMeshByName() to do a lookup.
  49553. * @param generator The mesh to generate a trail.
  49554. * @param scene The scene to add this mesh to.
  49555. * @param diameter Diameter of trailing mesh. Default is 1.
  49556. * @param length Length of trailing mesh. Default is 60.
  49557. * @param autoStart Automatically start trailing mesh. Default true.
  49558. */
  49559. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49560. /**
  49561. * "TrailMesh"
  49562. * @returns "TrailMesh"
  49563. */
  49564. getClassName(): string;
  49565. private _createMesh;
  49566. /**
  49567. * Start trailing mesh.
  49568. */
  49569. start(): void;
  49570. /**
  49571. * Stop trailing mesh.
  49572. */
  49573. stop(): void;
  49574. /**
  49575. * Update trailing mesh geometry.
  49576. */
  49577. update(): void;
  49578. /**
  49579. * Returns a new TrailMesh object.
  49580. * @param name is a string, the name given to the new mesh
  49581. * @param newGenerator use new generator object for cloned trail mesh
  49582. * @returns a new mesh
  49583. */
  49584. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49585. /**
  49586. * Serializes this trail mesh
  49587. * @param serializationObject object to write serialization to
  49588. */
  49589. serialize(serializationObject: any): void;
  49590. /**
  49591. * Parses a serialized trail mesh
  49592. * @param parsedMesh the serialized mesh
  49593. * @param scene the scene to create the trail mesh in
  49594. * @returns the created trail mesh
  49595. */
  49596. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49597. }
  49598. }
  49599. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49600. import { Nullable } from "babylonjs/types";
  49601. import { Scene } from "babylonjs/scene";
  49602. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49603. import { Mesh } from "babylonjs/Meshes/mesh";
  49604. /**
  49605. * Class containing static functions to help procedurally build meshes
  49606. */
  49607. export class RibbonBuilder {
  49608. /**
  49609. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49610. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49611. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49612. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49613. * * 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
  49614. * * 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
  49615. * * 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
  49616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49618. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49619. * * 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
  49620. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49621. * * 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
  49622. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49624. * @param name defines the name of the mesh
  49625. * @param options defines the options used to create the mesh
  49626. * @param scene defines the hosting scene
  49627. * @returns the ribbon mesh
  49628. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49629. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49630. */
  49631. static CreateRibbon(name: string, options: {
  49632. pathArray: Vector3[][];
  49633. closeArray?: boolean;
  49634. closePath?: boolean;
  49635. offset?: number;
  49636. updatable?: boolean;
  49637. sideOrientation?: number;
  49638. frontUVs?: Vector4;
  49639. backUVs?: Vector4;
  49640. instance?: Mesh;
  49641. invertUV?: boolean;
  49642. uvs?: Vector2[];
  49643. colors?: Color4[];
  49644. }, scene?: Nullable<Scene>): Mesh;
  49645. }
  49646. }
  49647. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49648. import { Vector4 } from "babylonjs/Maths/math";
  49649. import { Mesh } from "babylonjs/Meshes/mesh";
  49650. /**
  49651. * Class containing static functions to help procedurally build meshes
  49652. */
  49653. export class TorusKnotBuilder {
  49654. /**
  49655. * Creates a torus knot mesh
  49656. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49657. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49658. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49659. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49663. * @param name defines the name of the mesh
  49664. * @param options defines the options used to create the mesh
  49665. * @param scene defines the hosting scene
  49666. * @returns the torus knot mesh
  49667. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49668. */
  49669. static CreateTorusKnot(name: string, options: {
  49670. radius?: number;
  49671. tube?: number;
  49672. radialSegments?: number;
  49673. tubularSegments?: number;
  49674. p?: number;
  49675. q?: number;
  49676. updatable?: boolean;
  49677. sideOrientation?: number;
  49678. frontUVs?: Vector4;
  49679. backUVs?: Vector4;
  49680. }, scene: any): Mesh;
  49681. }
  49682. }
  49683. declare module "babylonjs/Meshes/polygonMesh" {
  49684. import { Scene } from "babylonjs/scene";
  49685. import { Vector2, Path2 } from "babylonjs/Maths/math";
  49686. import { Mesh } from "babylonjs/Meshes/mesh";
  49687. /**
  49688. * Polygon
  49689. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49690. */
  49691. export class Polygon {
  49692. /**
  49693. * Creates a rectangle
  49694. * @param xmin bottom X coord
  49695. * @param ymin bottom Y coord
  49696. * @param xmax top X coord
  49697. * @param ymax top Y coord
  49698. * @returns points that make the resulting rectation
  49699. */
  49700. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49701. /**
  49702. * Creates a circle
  49703. * @param radius radius of circle
  49704. * @param cx scale in x
  49705. * @param cy scale in y
  49706. * @param numberOfSides number of sides that make up the circle
  49707. * @returns points that make the resulting circle
  49708. */
  49709. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49710. /**
  49711. * Creates a polygon from input string
  49712. * @param input Input polygon data
  49713. * @returns the parsed points
  49714. */
  49715. static Parse(input: string): Vector2[];
  49716. /**
  49717. * Starts building a polygon from x and y coordinates
  49718. * @param x x coordinate
  49719. * @param y y coordinate
  49720. * @returns the started path2
  49721. */
  49722. static StartingAt(x: number, y: number): Path2;
  49723. }
  49724. /**
  49725. * Builds a polygon
  49726. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49727. */
  49728. export class PolygonMeshBuilder {
  49729. private _points;
  49730. private _outlinepoints;
  49731. private _holes;
  49732. private _name;
  49733. private _scene;
  49734. private _epoints;
  49735. private _eholes;
  49736. private _addToepoint;
  49737. /**
  49738. * Babylon reference to the earcut plugin.
  49739. */
  49740. bjsEarcut: any;
  49741. /**
  49742. * Creates a PolygonMeshBuilder
  49743. * @param name name of the builder
  49744. * @param contours Path of the polygon
  49745. * @param scene scene to add to
  49746. * @param earcutInjection can be used to inject your own earcut reference
  49747. */
  49748. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  49749. /**
  49750. * Adds a whole within the polygon
  49751. * @param hole Array of points defining the hole
  49752. * @returns this
  49753. */
  49754. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49755. /**
  49756. * Creates the polygon
  49757. * @param updatable If the mesh should be updatable
  49758. * @param depth The depth of the mesh created
  49759. * @returns the created mesh
  49760. */
  49761. build(updatable?: boolean, depth?: number): Mesh;
  49762. /**
  49763. * Adds a side to the polygon
  49764. * @param positions points that make the polygon
  49765. * @param normals normals of the polygon
  49766. * @param uvs uvs of the polygon
  49767. * @param indices indices of the polygon
  49768. * @param bounds bounds of the polygon
  49769. * @param points points of the polygon
  49770. * @param depth depth of the polygon
  49771. * @param flip flip of the polygon
  49772. */
  49773. private addSide;
  49774. }
  49775. }
  49776. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  49777. import { Scene } from "babylonjs/scene";
  49778. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  49779. import { Mesh } from "babylonjs/Meshes/mesh";
  49780. /**
  49781. * Class containing static functions to help procedurally build meshes
  49782. */
  49783. export class PolygonBuilder {
  49784. /**
  49785. * Creates a polygon mesh
  49786. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49787. * * 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
  49788. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49791. * * Remember you can only change the shape positions, not their number when updating a polygon
  49792. * @param name defines the name of the mesh
  49793. * @param options defines the options used to create the mesh
  49794. * @param scene defines the hosting scene
  49795. * @param earcutInjection can be used to inject your own earcut reference
  49796. * @returns the polygon mesh
  49797. */
  49798. static CreatePolygon(name: string, options: {
  49799. shape: Vector3[];
  49800. holes?: Vector3[][];
  49801. depth?: number;
  49802. faceUV?: Vector4[];
  49803. faceColors?: Color4[];
  49804. updatable?: boolean;
  49805. sideOrientation?: number;
  49806. frontUVs?: Vector4;
  49807. backUVs?: Vector4;
  49808. }, scene: Scene, earcutInjection?: any): Mesh;
  49809. /**
  49810. * Creates an extruded polygon mesh, with depth in the Y direction.
  49811. * * 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)
  49812. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49813. * @param name defines the name of the mesh
  49814. * @param options defines the options used to create the mesh
  49815. * @param scene defines the hosting scene
  49816. * @param earcutInjection can be used to inject your own earcut reference
  49817. * @returns the polygon mesh
  49818. */
  49819. static ExtrudePolygon(name: string, options: {
  49820. shape: Vector3[];
  49821. holes?: Vector3[][];
  49822. depth?: number;
  49823. faceUV?: Vector4[];
  49824. faceColors?: Color4[];
  49825. updatable?: boolean;
  49826. sideOrientation?: number;
  49827. frontUVs?: Vector4;
  49828. backUVs?: Vector4;
  49829. }, scene: Scene, earcutInjection?: any): Mesh;
  49830. }
  49831. }
  49832. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  49833. import { Nullable } from "babylonjs/types";
  49834. import { Scene } from "babylonjs/scene";
  49835. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49836. import { Mesh } from "babylonjs/Meshes/mesh";
  49837. /**
  49838. * Class containing static functions to help procedurally build meshes
  49839. */
  49840. export class ShapeBuilder {
  49841. /**
  49842. * 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.
  49843. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  49844. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49845. * * The parameter `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.
  49846. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49847. * * 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
  49848. * * 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
  49849. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49852. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49854. * @param name defines the name of the mesh
  49855. * @param options defines the options used to create the mesh
  49856. * @param scene defines the hosting scene
  49857. * @returns the extruded shape mesh
  49858. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49860. */
  49861. static ExtrudeShape(name: string, options: {
  49862. shape: Vector3[];
  49863. path: Vector3[];
  49864. scale?: number;
  49865. rotation?: number;
  49866. cap?: number;
  49867. updatable?: boolean;
  49868. sideOrientation?: number;
  49869. frontUVs?: Vector4;
  49870. backUVs?: Vector4;
  49871. instance?: Mesh;
  49872. invertUV?: boolean;
  49873. }, scene?: Nullable<Scene>): Mesh;
  49874. /**
  49875. * Creates an custom extruded shape mesh.
  49876. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49877. * * 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.
  49878. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49879. * * 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
  49880. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49881. * * 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
  49882. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49883. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49884. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49885. * * 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
  49886. * * 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
  49887. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49890. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49892. * @param name defines the name of the mesh
  49893. * @param options defines the options used to create the mesh
  49894. * @param scene defines the hosting scene
  49895. * @returns the custom extruded shape mesh
  49896. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49897. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49898. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49899. */
  49900. static ExtrudeShapeCustom(name: string, options: {
  49901. shape: Vector3[];
  49902. path: Vector3[];
  49903. scaleFunction?: any;
  49904. rotationFunction?: any;
  49905. ribbonCloseArray?: boolean;
  49906. ribbonClosePath?: boolean;
  49907. cap?: number;
  49908. updatable?: boolean;
  49909. sideOrientation?: number;
  49910. frontUVs?: Vector4;
  49911. backUVs?: Vector4;
  49912. instance?: Mesh;
  49913. invertUV?: boolean;
  49914. }, scene: Scene): Mesh;
  49915. private static _ExtrudeShapeGeneric;
  49916. }
  49917. }
  49918. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  49919. import { Scene } from "babylonjs/scene";
  49920. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49921. import { Mesh } from "babylonjs/Meshes/mesh";
  49922. /**
  49923. * Class containing static functions to help procedurally build meshes
  49924. */
  49925. export class LatheBuilder {
  49926. /**
  49927. * Creates lathe mesh.
  49928. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49929. * * 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
  49930. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49931. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49932. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49933. * * 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
  49934. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49935. * * 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
  49936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49938. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49940. * @param name defines the name of the mesh
  49941. * @param options defines the options used to create the mesh
  49942. * @param scene defines the hosting scene
  49943. * @returns the lathe mesh
  49944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49945. */
  49946. static CreateLathe(name: string, options: {
  49947. shape: Vector3[];
  49948. radius?: number;
  49949. tessellation?: number;
  49950. clip?: number;
  49951. arc?: number;
  49952. closed?: boolean;
  49953. updatable?: boolean;
  49954. sideOrientation?: number;
  49955. frontUVs?: Vector4;
  49956. backUVs?: Vector4;
  49957. cap?: number;
  49958. invertUV?: boolean;
  49959. }, scene: Scene): Mesh;
  49960. }
  49961. }
  49962. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  49963. import { Scene } from "babylonjs/scene";
  49964. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49965. import { Mesh } from "babylonjs/Meshes/mesh";
  49966. /**
  49967. * Class containing static functions to help procedurally build meshes
  49968. */
  49969. export class TubeBuilder {
  49970. /**
  49971. * Creates a tube mesh.
  49972. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49973. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49974. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49975. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49976. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49977. * * 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)
  49978. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49979. * * 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
  49980. * * 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
  49981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49983. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49985. * @param name defines the name of the mesh
  49986. * @param options defines the options used to create the mesh
  49987. * @param scene defines the hosting scene
  49988. * @returns the tube mesh
  49989. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49990. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49991. */
  49992. static CreateTube(name: string, options: {
  49993. path: Vector3[];
  49994. radius?: number;
  49995. tessellation?: number;
  49996. radiusFunction?: {
  49997. (i: number, distance: number): number;
  49998. };
  49999. cap?: number;
  50000. arc?: number;
  50001. updatable?: boolean;
  50002. sideOrientation?: number;
  50003. frontUVs?: Vector4;
  50004. backUVs?: Vector4;
  50005. instance?: Mesh;
  50006. invertUV?: boolean;
  50007. }, scene: Scene): Mesh;
  50008. }
  50009. }
  50010. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50011. import { Scene } from "babylonjs/scene";
  50012. import { Vector4 } from "babylonjs/Maths/math";
  50013. import { Mesh } from "babylonjs/Meshes/mesh";
  50014. /**
  50015. * Class containing static functions to help procedurally build meshes
  50016. */
  50017. export class IcoSphereBuilder {
  50018. /**
  50019. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50020. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50021. * * 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`)
  50022. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50023. * * 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
  50024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50025. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50027. * @param name defines the name of the mesh
  50028. * @param options defines the options used to create the mesh
  50029. * @param scene defines the hosting scene
  50030. * @returns the icosahedron mesh
  50031. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50032. */
  50033. static CreateIcoSphere(name: string, options: {
  50034. radius?: number;
  50035. radiusX?: number;
  50036. radiusY?: number;
  50037. radiusZ?: number;
  50038. flat?: boolean;
  50039. subdivisions?: number;
  50040. sideOrientation?: number;
  50041. frontUVs?: Vector4;
  50042. backUVs?: Vector4;
  50043. updatable?: boolean;
  50044. }, scene: Scene): Mesh;
  50045. }
  50046. }
  50047. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50048. import { Vector3 } from "babylonjs/Maths/math";
  50049. import { Mesh } from "babylonjs/Meshes/mesh";
  50050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50051. /**
  50052. * Class containing static functions to help procedurally build meshes
  50053. */
  50054. export class DecalBuilder {
  50055. /**
  50056. * Creates a decal mesh.
  50057. * 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
  50058. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50059. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50060. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50061. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50062. * @param name defines the name of the mesh
  50063. * @param sourceMesh defines the mesh where the decal must be applied
  50064. * @param options defines the options used to create the mesh
  50065. * @param scene defines the hosting scene
  50066. * @returns the decal mesh
  50067. * @see https://doc.babylonjs.com/how_to/decals
  50068. */
  50069. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50070. position?: Vector3;
  50071. normal?: Vector3;
  50072. size?: Vector3;
  50073. angle?: number;
  50074. }): Mesh;
  50075. }
  50076. }
  50077. declare module "babylonjs/Meshes/meshBuilder" {
  50078. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50079. import { Nullable } from "babylonjs/types";
  50080. import { Scene } from "babylonjs/scene";
  50081. import { Mesh } from "babylonjs/Meshes/mesh";
  50082. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50083. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50085. /**
  50086. * Class containing static functions to help procedurally build meshes
  50087. */
  50088. export class MeshBuilder {
  50089. /**
  50090. * Creates a box mesh
  50091. * * The parameter `size` sets the size (float) of each box side (default 1)
  50092. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50093. * * 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)
  50094. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50098. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50099. * @param name defines the name of the mesh
  50100. * @param options defines the options used to create the mesh
  50101. * @param scene defines the hosting scene
  50102. * @returns the box mesh
  50103. */
  50104. static CreateBox(name: string, options: {
  50105. size?: number;
  50106. width?: number;
  50107. height?: number;
  50108. depth?: number;
  50109. faceUV?: Vector4[];
  50110. faceColors?: Color4[];
  50111. sideOrientation?: number;
  50112. frontUVs?: Vector4;
  50113. backUVs?: Vector4;
  50114. updatable?: boolean;
  50115. }, scene?: Nullable<Scene>): Mesh;
  50116. /**
  50117. * Creates a sphere mesh
  50118. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50119. * * 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`)
  50120. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50121. * * 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
  50122. * * 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)
  50123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50126. * @param name defines the name of the mesh
  50127. * @param options defines the options used to create the mesh
  50128. * @param scene defines the hosting scene
  50129. * @returns the sphere mesh
  50130. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50131. */
  50132. static CreateSphere(name: string, options: {
  50133. segments?: number;
  50134. diameter?: number;
  50135. diameterX?: number;
  50136. diameterY?: number;
  50137. diameterZ?: number;
  50138. arc?: number;
  50139. slice?: number;
  50140. sideOrientation?: number;
  50141. frontUVs?: Vector4;
  50142. backUVs?: Vector4;
  50143. updatable?: boolean;
  50144. }, scene: any): Mesh;
  50145. /**
  50146. * Creates a plane polygonal mesh. By default, this is a disc
  50147. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50148. * * 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
  50149. * * 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
  50150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50151. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50153. * @param name defines the name of the mesh
  50154. * @param options defines the options used to create the mesh
  50155. * @param scene defines the hosting scene
  50156. * @returns the plane polygonal mesh
  50157. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50158. */
  50159. static CreateDisc(name: string, options: {
  50160. radius?: number;
  50161. tessellation?: number;
  50162. arc?: number;
  50163. updatable?: boolean;
  50164. sideOrientation?: number;
  50165. frontUVs?: Vector4;
  50166. backUVs?: Vector4;
  50167. }, scene?: Nullable<Scene>): Mesh;
  50168. /**
  50169. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50170. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50171. * * 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`)
  50172. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50173. * * 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
  50174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50175. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50177. * @param name defines the name of the mesh
  50178. * @param options defines the options used to create the mesh
  50179. * @param scene defines the hosting scene
  50180. * @returns the icosahedron mesh
  50181. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50182. */
  50183. static CreateIcoSphere(name: string, options: {
  50184. radius?: number;
  50185. radiusX?: number;
  50186. radiusY?: number;
  50187. radiusZ?: number;
  50188. flat?: boolean;
  50189. subdivisions?: number;
  50190. sideOrientation?: number;
  50191. frontUVs?: Vector4;
  50192. backUVs?: Vector4;
  50193. updatable?: boolean;
  50194. }, scene: Scene): Mesh;
  50195. /**
  50196. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50197. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50198. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50199. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50200. * * 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
  50201. * * 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
  50202. * * 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
  50203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50205. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50206. * * 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
  50207. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50208. * * 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
  50209. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50211. * @param name defines the name of the mesh
  50212. * @param options defines the options used to create the mesh
  50213. * @param scene defines the hosting scene
  50214. * @returns the ribbon mesh
  50215. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50216. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50217. */
  50218. static CreateRibbon(name: string, options: {
  50219. pathArray: Vector3[][];
  50220. closeArray?: boolean;
  50221. closePath?: boolean;
  50222. offset?: number;
  50223. updatable?: boolean;
  50224. sideOrientation?: number;
  50225. frontUVs?: Vector4;
  50226. backUVs?: Vector4;
  50227. instance?: Mesh;
  50228. invertUV?: boolean;
  50229. uvs?: Vector2[];
  50230. colors?: Color4[];
  50231. }, scene?: Nullable<Scene>): Mesh;
  50232. /**
  50233. * Creates a cylinder or a cone mesh
  50234. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50235. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50236. * * 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.
  50237. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50238. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50239. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50240. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50241. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50242. * * 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).
  50243. * * 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
  50244. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50245. * * 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
  50246. * * 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.
  50247. * * If `enclose` is false, a ring surface is one element.
  50248. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50249. * * 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
  50250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50253. * @param name defines the name of the mesh
  50254. * @param options defines the options used to create the mesh
  50255. * @param scene defines the hosting scene
  50256. * @returns the cylinder mesh
  50257. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50258. */
  50259. static CreateCylinder(name: string, options: {
  50260. height?: number;
  50261. diameterTop?: number;
  50262. diameterBottom?: number;
  50263. diameter?: number;
  50264. tessellation?: number;
  50265. subdivisions?: number;
  50266. arc?: number;
  50267. faceColors?: Color4[];
  50268. faceUV?: Vector4[];
  50269. updatable?: boolean;
  50270. hasRings?: boolean;
  50271. enclose?: boolean;
  50272. sideOrientation?: number;
  50273. frontUVs?: Vector4;
  50274. backUVs?: Vector4;
  50275. }, scene: any): Mesh;
  50276. /**
  50277. * Creates a torus mesh
  50278. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50279. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50280. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50284. * @param name defines the name of the mesh
  50285. * @param options defines the options used to create the mesh
  50286. * @param scene defines the hosting scene
  50287. * @returns the torus mesh
  50288. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50289. */
  50290. static CreateTorus(name: string, options: {
  50291. diameter?: number;
  50292. thickness?: number;
  50293. tessellation?: number;
  50294. updatable?: boolean;
  50295. sideOrientation?: number;
  50296. frontUVs?: Vector4;
  50297. backUVs?: Vector4;
  50298. }, scene: any): Mesh;
  50299. /**
  50300. * Creates a torus knot mesh
  50301. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50302. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50303. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50304. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50306. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50308. * @param name defines the name of the mesh
  50309. * @param options defines the options used to create the mesh
  50310. * @param scene defines the hosting scene
  50311. * @returns the torus knot mesh
  50312. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50313. */
  50314. static CreateTorusKnot(name: string, options: {
  50315. radius?: number;
  50316. tube?: number;
  50317. radialSegments?: number;
  50318. tubularSegments?: number;
  50319. p?: number;
  50320. q?: number;
  50321. updatable?: boolean;
  50322. sideOrientation?: number;
  50323. frontUVs?: Vector4;
  50324. backUVs?: Vector4;
  50325. }, scene: any): Mesh;
  50326. /**
  50327. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50328. * * 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
  50329. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50330. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50331. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50332. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50333. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50334. * * 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
  50335. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50338. * @param name defines the name of the new line system
  50339. * @param options defines the options used to create the line system
  50340. * @param scene defines the hosting scene
  50341. * @returns a new line system mesh
  50342. */
  50343. static CreateLineSystem(name: string, options: {
  50344. lines: Vector3[][];
  50345. updatable?: boolean;
  50346. instance?: Nullable<LinesMesh>;
  50347. colors?: Nullable<Color4[][]>;
  50348. useVertexAlpha?: boolean;
  50349. }, scene: Nullable<Scene>): LinesMesh;
  50350. /**
  50351. * Creates a line mesh
  50352. * 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
  50353. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50354. * * The parameter `points` is an array successive Vector3
  50355. * * 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
  50356. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50357. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50358. * * When updating an instance, remember that only point positions can change, not the number of points
  50359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50361. * @param name defines the name of the new line system
  50362. * @param options defines the options used to create the line system
  50363. * @param scene defines the hosting scene
  50364. * @returns a new line mesh
  50365. */
  50366. static CreateLines(name: string, options: {
  50367. points: Vector3[];
  50368. updatable?: boolean;
  50369. instance?: Nullable<LinesMesh>;
  50370. colors?: Color4[];
  50371. useVertexAlpha?: boolean;
  50372. }, scene?: Nullable<Scene>): LinesMesh;
  50373. /**
  50374. * Creates a dashed line mesh
  50375. * * 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
  50376. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50377. * * The parameter `points` is an array successive Vector3
  50378. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50379. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50380. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50381. * * 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
  50382. * * When updating an instance, remember that only point positions can change, not the number of points
  50383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50384. * @param name defines the name of the mesh
  50385. * @param options defines the options used to create the mesh
  50386. * @param scene defines the hosting scene
  50387. * @returns the dashed line mesh
  50388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50389. */
  50390. static CreateDashedLines(name: string, options: {
  50391. points: Vector3[];
  50392. dashSize?: number;
  50393. gapSize?: number;
  50394. dashNb?: number;
  50395. updatable?: boolean;
  50396. instance?: LinesMesh;
  50397. }, scene?: Nullable<Scene>): LinesMesh;
  50398. /**
  50399. * 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.
  50400. * * 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.
  50401. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50402. * * 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.
  50403. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50404. * * 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
  50405. * * 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
  50406. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50409. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50411. * @param name defines the name of the mesh
  50412. * @param options defines the options used to create the mesh
  50413. * @param scene defines the hosting scene
  50414. * @returns the extruded shape mesh
  50415. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50417. */
  50418. static ExtrudeShape(name: string, options: {
  50419. shape: Vector3[];
  50420. path: Vector3[];
  50421. scale?: number;
  50422. rotation?: number;
  50423. cap?: number;
  50424. updatable?: boolean;
  50425. sideOrientation?: number;
  50426. frontUVs?: Vector4;
  50427. backUVs?: Vector4;
  50428. instance?: Mesh;
  50429. invertUV?: boolean;
  50430. }, scene?: Nullable<Scene>): Mesh;
  50431. /**
  50432. * Creates an custom extruded shape mesh.
  50433. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50434. * * 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.
  50435. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50436. * * 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
  50437. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50438. * * 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
  50439. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50440. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50441. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50442. * * 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
  50443. * * 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
  50444. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50447. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50449. * @param name defines the name of the mesh
  50450. * @param options defines the options used to create the mesh
  50451. * @param scene defines the hosting scene
  50452. * @returns the custom extruded shape mesh
  50453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50454. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50456. */
  50457. static ExtrudeShapeCustom(name: string, options: {
  50458. shape: Vector3[];
  50459. path: Vector3[];
  50460. scaleFunction?: any;
  50461. rotationFunction?: any;
  50462. ribbonCloseArray?: boolean;
  50463. ribbonClosePath?: boolean;
  50464. cap?: number;
  50465. updatable?: boolean;
  50466. sideOrientation?: number;
  50467. frontUVs?: Vector4;
  50468. backUVs?: Vector4;
  50469. instance?: Mesh;
  50470. invertUV?: boolean;
  50471. }, scene: Scene): Mesh;
  50472. /**
  50473. * Creates lathe mesh.
  50474. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50475. * * 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
  50476. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50477. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50478. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50479. * * 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
  50480. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50481. * * 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
  50482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50484. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50486. * @param name defines the name of the mesh
  50487. * @param options defines the options used to create the mesh
  50488. * @param scene defines the hosting scene
  50489. * @returns the lathe mesh
  50490. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50491. */
  50492. static CreateLathe(name: string, options: {
  50493. shape: Vector3[];
  50494. radius?: number;
  50495. tessellation?: number;
  50496. clip?: number;
  50497. arc?: number;
  50498. closed?: boolean;
  50499. updatable?: boolean;
  50500. sideOrientation?: number;
  50501. frontUVs?: Vector4;
  50502. backUVs?: Vector4;
  50503. cap?: number;
  50504. invertUV?: boolean;
  50505. }, scene: Scene): Mesh;
  50506. /**
  50507. * Creates a plane mesh
  50508. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50509. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50510. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50514. * @param name defines the name of the mesh
  50515. * @param options defines the options used to create the mesh
  50516. * @param scene defines the hosting scene
  50517. * @returns the plane mesh
  50518. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50519. */
  50520. static CreatePlane(name: string, options: {
  50521. size?: number;
  50522. width?: number;
  50523. height?: number;
  50524. sideOrientation?: number;
  50525. frontUVs?: Vector4;
  50526. backUVs?: Vector4;
  50527. updatable?: boolean;
  50528. sourcePlane?: Plane;
  50529. }, scene: Scene): Mesh;
  50530. /**
  50531. * Creates a ground mesh
  50532. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50533. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50535. * @param name defines the name of the mesh
  50536. * @param options defines the options used to create the mesh
  50537. * @param scene defines the hosting scene
  50538. * @returns the ground mesh
  50539. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50540. */
  50541. static CreateGround(name: string, options: {
  50542. width?: number;
  50543. height?: number;
  50544. subdivisions?: number;
  50545. subdivisionsX?: number;
  50546. subdivisionsY?: number;
  50547. updatable?: boolean;
  50548. }, scene: any): Mesh;
  50549. /**
  50550. * Creates a tiled ground mesh
  50551. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50552. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50553. * * 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
  50554. * * 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
  50555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50556. * @param name defines the name of the mesh
  50557. * @param options defines the options used to create the mesh
  50558. * @param scene defines the hosting scene
  50559. * @returns the tiled ground mesh
  50560. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50561. */
  50562. static CreateTiledGround(name: string, options: {
  50563. xmin: number;
  50564. zmin: number;
  50565. xmax: number;
  50566. zmax: number;
  50567. subdivisions?: {
  50568. w: number;
  50569. h: number;
  50570. };
  50571. precision?: {
  50572. w: number;
  50573. h: number;
  50574. };
  50575. updatable?: boolean;
  50576. }, scene: Scene): Mesh;
  50577. /**
  50578. * Creates a ground mesh from a height map
  50579. * * The parameter `url` sets the URL of the height map image resource.
  50580. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50581. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50582. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50583. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50584. * * 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.
  50585. * * 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).
  50586. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50588. * @param name defines the name of the mesh
  50589. * @param url defines the url to the height map
  50590. * @param options defines the options used to create the mesh
  50591. * @param scene defines the hosting scene
  50592. * @returns the ground mesh
  50593. * @see https://doc.babylonjs.com/babylon101/height_map
  50594. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50595. */
  50596. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50597. width?: number;
  50598. height?: number;
  50599. subdivisions?: number;
  50600. minHeight?: number;
  50601. maxHeight?: number;
  50602. colorFilter?: Color3;
  50603. alphaFilter?: number;
  50604. updatable?: boolean;
  50605. onReady?: (mesh: GroundMesh) => void;
  50606. }, scene: Scene): GroundMesh;
  50607. /**
  50608. * Creates a polygon mesh
  50609. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50610. * * 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
  50611. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50614. * * Remember you can only change the shape positions, not their number when updating a polygon
  50615. * @param name defines the name of the mesh
  50616. * @param options defines the options used to create the mesh
  50617. * @param scene defines the hosting scene
  50618. * @param earcutInjection can be used to inject your own earcut reference
  50619. * @returns the polygon mesh
  50620. */
  50621. static CreatePolygon(name: string, options: {
  50622. shape: Vector3[];
  50623. holes?: Vector3[][];
  50624. depth?: number;
  50625. faceUV?: Vector4[];
  50626. faceColors?: Color4[];
  50627. updatable?: boolean;
  50628. sideOrientation?: number;
  50629. frontUVs?: Vector4;
  50630. backUVs?: Vector4;
  50631. }, scene: Scene, earcutInjection?: any): Mesh;
  50632. /**
  50633. * Creates an extruded polygon mesh, with depth in the Y direction.
  50634. * * 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)
  50635. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50636. * @param name defines the name of the mesh
  50637. * @param options defines the options used to create the mesh
  50638. * @param scene defines the hosting scene
  50639. * @param earcutInjection can be used to inject your own earcut reference
  50640. * @returns the polygon mesh
  50641. */
  50642. static ExtrudePolygon(name: string, options: {
  50643. shape: Vector3[];
  50644. holes?: Vector3[][];
  50645. depth?: number;
  50646. faceUV?: Vector4[];
  50647. faceColors?: Color4[];
  50648. updatable?: boolean;
  50649. sideOrientation?: number;
  50650. frontUVs?: Vector4;
  50651. backUVs?: Vector4;
  50652. }, scene: Scene, earcutInjection?: any): Mesh;
  50653. /**
  50654. * Creates a tube mesh.
  50655. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50656. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50657. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50658. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50659. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50660. * * 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)
  50661. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50662. * * 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
  50663. * * 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
  50664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50666. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50668. * @param name defines the name of the mesh
  50669. * @param options defines the options used to create the mesh
  50670. * @param scene defines the hosting scene
  50671. * @returns the tube mesh
  50672. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50673. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50674. */
  50675. static CreateTube(name: string, options: {
  50676. path: Vector3[];
  50677. radius?: number;
  50678. tessellation?: number;
  50679. radiusFunction?: {
  50680. (i: number, distance: number): number;
  50681. };
  50682. cap?: number;
  50683. arc?: number;
  50684. updatable?: boolean;
  50685. sideOrientation?: number;
  50686. frontUVs?: Vector4;
  50687. backUVs?: Vector4;
  50688. instance?: Mesh;
  50689. invertUV?: boolean;
  50690. }, scene: Scene): Mesh;
  50691. /**
  50692. * Creates a polyhedron mesh
  50693. * * 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
  50694. * * The parameter `size` (positive float, default 1) sets the polygon size
  50695. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50696. * * 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`
  50697. * * 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
  50698. * * 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)`)
  50699. * * 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
  50700. * * 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
  50701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50704. * @param name defines the name of the mesh
  50705. * @param options defines the options used to create the mesh
  50706. * @param scene defines the hosting scene
  50707. * @returns the polyhedron mesh
  50708. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50709. */
  50710. static CreatePolyhedron(name: string, options: {
  50711. type?: number;
  50712. size?: number;
  50713. sizeX?: number;
  50714. sizeY?: number;
  50715. sizeZ?: number;
  50716. custom?: any;
  50717. faceUV?: Vector4[];
  50718. faceColors?: Color4[];
  50719. flat?: boolean;
  50720. updatable?: boolean;
  50721. sideOrientation?: number;
  50722. frontUVs?: Vector4;
  50723. backUVs?: Vector4;
  50724. }, scene: Scene): Mesh;
  50725. /**
  50726. * Creates a decal mesh.
  50727. * 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
  50728. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50729. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50730. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50731. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50732. * @param name defines the name of the mesh
  50733. * @param sourceMesh defines the mesh where the decal must be applied
  50734. * @param options defines the options used to create the mesh
  50735. * @param scene defines the hosting scene
  50736. * @returns the decal mesh
  50737. * @see https://doc.babylonjs.com/how_to/decals
  50738. */
  50739. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50740. position?: Vector3;
  50741. normal?: Vector3;
  50742. size?: Vector3;
  50743. angle?: number;
  50744. }): Mesh;
  50745. }
  50746. }
  50747. declare module "babylonjs/Meshes/meshSimplification" {
  50748. import { Mesh } from "babylonjs/Meshes/mesh";
  50749. /**
  50750. * A simplifier interface for future simplification implementations
  50751. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50752. */
  50753. export interface ISimplifier {
  50754. /**
  50755. * Simplification of a given mesh according to the given settings.
  50756. * Since this requires computation, it is assumed that the function runs async.
  50757. * @param settings The settings of the simplification, including quality and distance
  50758. * @param successCallback A callback that will be called after the mesh was simplified.
  50759. * @param errorCallback in case of an error, this callback will be called. optional.
  50760. */
  50761. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50762. }
  50763. /**
  50764. * Expected simplification settings.
  50765. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50766. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50767. */
  50768. export interface ISimplificationSettings {
  50769. /**
  50770. * Gets or sets the expected quality
  50771. */
  50772. quality: number;
  50773. /**
  50774. * Gets or sets the distance when this optimized version should be used
  50775. */
  50776. distance: number;
  50777. /**
  50778. * Gets an already optimized mesh
  50779. */
  50780. optimizeMesh?: boolean;
  50781. }
  50782. /**
  50783. * Class used to specify simplification options
  50784. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50785. */
  50786. export class SimplificationSettings implements ISimplificationSettings {
  50787. /** expected quality */
  50788. quality: number;
  50789. /** distance when this optimized version should be used */
  50790. distance: number;
  50791. /** already optimized mesh */
  50792. optimizeMesh?: boolean | undefined;
  50793. /**
  50794. * Creates a SimplificationSettings
  50795. * @param quality expected quality
  50796. * @param distance distance when this optimized version should be used
  50797. * @param optimizeMesh already optimized mesh
  50798. */
  50799. constructor(
  50800. /** expected quality */
  50801. quality: number,
  50802. /** distance when this optimized version should be used */
  50803. distance: number,
  50804. /** already optimized mesh */
  50805. optimizeMesh?: boolean | undefined);
  50806. }
  50807. /**
  50808. * Interface used to define a simplification task
  50809. */
  50810. export interface ISimplificationTask {
  50811. /**
  50812. * Array of settings
  50813. */
  50814. settings: Array<ISimplificationSettings>;
  50815. /**
  50816. * Simplification type
  50817. */
  50818. simplificationType: SimplificationType;
  50819. /**
  50820. * Mesh to simplify
  50821. */
  50822. mesh: Mesh;
  50823. /**
  50824. * Callback called on success
  50825. */
  50826. successCallback?: () => void;
  50827. /**
  50828. * Defines if parallel processing can be used
  50829. */
  50830. parallelProcessing: boolean;
  50831. }
  50832. /**
  50833. * Queue used to order the simplification tasks
  50834. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50835. */
  50836. export class SimplificationQueue {
  50837. private _simplificationArray;
  50838. /**
  50839. * Gets a boolean indicating that the process is still running
  50840. */
  50841. running: boolean;
  50842. /**
  50843. * Creates a new queue
  50844. */
  50845. constructor();
  50846. /**
  50847. * Adds a new simplification task
  50848. * @param task defines a task to add
  50849. */
  50850. addTask(task: ISimplificationTask): void;
  50851. /**
  50852. * Execute next task
  50853. */
  50854. executeNext(): void;
  50855. /**
  50856. * Execute a simplification task
  50857. * @param task defines the task to run
  50858. */
  50859. runSimplification(task: ISimplificationTask): void;
  50860. private getSimplifier;
  50861. }
  50862. /**
  50863. * The implemented types of simplification
  50864. * At the moment only Quadratic Error Decimation is implemented
  50865. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50866. */
  50867. export enum SimplificationType {
  50868. /** Quadratic error decimation */
  50869. QUADRATIC = 0
  50870. }
  50871. }
  50872. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  50873. import { Scene } from "babylonjs/scene";
  50874. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  50875. import { ISceneComponent } from "babylonjs/sceneComponent";
  50876. module "babylonjs/scene" {
  50877. interface Scene {
  50878. /** @hidden (Backing field) */
  50879. _simplificationQueue: SimplificationQueue;
  50880. /**
  50881. * Gets or sets the simplification queue attached to the scene
  50882. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50883. */
  50884. simplificationQueue: SimplificationQueue;
  50885. }
  50886. }
  50887. module "babylonjs/Meshes/mesh" {
  50888. interface Mesh {
  50889. /**
  50890. * Simplify the mesh according to the given array of settings.
  50891. * Function will return immediately and will simplify async
  50892. * @param settings a collection of simplification settings
  50893. * @param parallelProcessing should all levels calculate parallel or one after the other
  50894. * @param simplificationType the type of simplification to run
  50895. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50896. * @returns the current mesh
  50897. */
  50898. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50899. }
  50900. }
  50901. /**
  50902. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50903. * created in a scene
  50904. */
  50905. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50906. /**
  50907. * The component name helpfull to identify the component in the list of scene components.
  50908. */
  50909. readonly name: string;
  50910. /**
  50911. * The scene the component belongs to.
  50912. */
  50913. scene: Scene;
  50914. /**
  50915. * Creates a new instance of the component for the given scene
  50916. * @param scene Defines the scene to register the component in
  50917. */
  50918. constructor(scene: Scene);
  50919. /**
  50920. * Registers the component in a given scene
  50921. */
  50922. register(): void;
  50923. /**
  50924. * Rebuilds the elements related to this component in case of
  50925. * context lost for instance.
  50926. */
  50927. rebuild(): void;
  50928. /**
  50929. * Disposes the component and the associated ressources
  50930. */
  50931. dispose(): void;
  50932. private _beforeCameraUpdate;
  50933. }
  50934. }
  50935. declare module "babylonjs/Meshes/Builders/index" {
  50936. export * from "babylonjs/Meshes/Builders/boxBuilder";
  50937. export * from "babylonjs/Meshes/Builders/discBuilder";
  50938. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  50939. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  50940. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  50941. export * from "babylonjs/Meshes/Builders/torusBuilder";
  50942. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50943. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50944. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50945. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50946. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50947. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50948. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50949. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50950. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50951. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50952. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50953. }
  50954. declare module "babylonjs/Meshes/index" {
  50955. export * from "babylonjs/Meshes/abstractMesh";
  50956. export * from "babylonjs/Meshes/buffer";
  50957. export * from "babylonjs/Meshes/Compression/index";
  50958. export * from "babylonjs/Meshes/csg";
  50959. export * from "babylonjs/Meshes/geometry";
  50960. export * from "babylonjs/Meshes/groundMesh";
  50961. export * from "babylonjs/Meshes/trailMesh";
  50962. export * from "babylonjs/Meshes/instancedMesh";
  50963. export * from "babylonjs/Meshes/linesMesh";
  50964. export * from "babylonjs/Meshes/mesh";
  50965. export * from "babylonjs/Meshes/mesh.vertexData";
  50966. export * from "babylonjs/Meshes/meshBuilder";
  50967. export * from "babylonjs/Meshes/meshSimplification";
  50968. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  50969. export * from "babylonjs/Meshes/polygonMesh";
  50970. export * from "babylonjs/Meshes/subMesh";
  50971. export * from "babylonjs/Meshes/transformNode";
  50972. export * from "babylonjs/Meshes/Builders/index";
  50973. }
  50974. declare module "babylonjs/Morph/index" {
  50975. export * from "babylonjs/Morph/morphTarget";
  50976. export * from "babylonjs/Morph/morphTargetManager";
  50977. }
  50978. declare module "babylonjs/Offline/database" {
  50979. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  50980. /**
  50981. * Class used to enable access to IndexedDB
  50982. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50983. */
  50984. export class Database implements IOfflineProvider {
  50985. private _callbackManifestChecked;
  50986. private _currentSceneUrl;
  50987. private _db;
  50988. private _enableSceneOffline;
  50989. private _enableTexturesOffline;
  50990. private _manifestVersionFound;
  50991. private _mustUpdateRessources;
  50992. private _hasReachedQuota;
  50993. private _isSupported;
  50994. private _idbFactory;
  50995. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50996. private static IsUASupportingBlobStorage;
  50997. /**
  50998. * Gets a boolean indicating if Database storate is enabled (off by default)
  50999. */
  51000. static IDBStorageEnabled: boolean;
  51001. /**
  51002. * Gets a boolean indicating if scene must be saved in the database
  51003. */
  51004. readonly enableSceneOffline: boolean;
  51005. /**
  51006. * Gets a boolean indicating if textures must be saved in the database
  51007. */
  51008. readonly enableTexturesOffline: boolean;
  51009. /**
  51010. * Creates a new Database
  51011. * @param urlToScene defines the url to load the scene
  51012. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51013. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51014. */
  51015. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51016. private static _ParseURL;
  51017. private static _ReturnFullUrlLocation;
  51018. private _checkManifestFile;
  51019. /**
  51020. * Open the database and make it available
  51021. * @param successCallback defines the callback to call on success
  51022. * @param errorCallback defines the callback to call on error
  51023. */
  51024. open(successCallback: () => void, errorCallback: () => void): void;
  51025. /**
  51026. * Loads an image from the database
  51027. * @param url defines the url to load from
  51028. * @param image defines the target DOM image
  51029. */
  51030. loadImage(url: string, image: HTMLImageElement): void;
  51031. private _loadImageFromDBAsync;
  51032. private _saveImageIntoDBAsync;
  51033. private _checkVersionFromDB;
  51034. private _loadVersionFromDBAsync;
  51035. private _saveVersionIntoDBAsync;
  51036. /**
  51037. * Loads a file from database
  51038. * @param url defines the URL to load from
  51039. * @param sceneLoaded defines a callback to call on success
  51040. * @param progressCallBack defines a callback to call when progress changed
  51041. * @param errorCallback defines a callback to call on error
  51042. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51043. */
  51044. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51045. private _loadFileAsync;
  51046. private _saveFileAsync;
  51047. /**
  51048. * Validates if xhr data is correct
  51049. * @param xhr defines the request to validate
  51050. * @param dataType defines the expected data type
  51051. * @returns true if data is correct
  51052. */
  51053. private static _ValidateXHRData;
  51054. }
  51055. }
  51056. declare module "babylonjs/Offline/index" {
  51057. export * from "babylonjs/Offline/database";
  51058. export * from "babylonjs/Offline/IOfflineProvider";
  51059. }
  51060. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51061. /** @hidden */
  51062. export var gpuUpdateParticlesPixelShader: {
  51063. name: string;
  51064. shader: string;
  51065. };
  51066. }
  51067. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51068. /** @hidden */
  51069. export var gpuUpdateParticlesVertexShader: {
  51070. name: string;
  51071. shader: string;
  51072. };
  51073. }
  51074. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51075. /** @hidden */
  51076. export var clipPlaneFragmentDeclaration2: {
  51077. name: string;
  51078. shader: string;
  51079. };
  51080. }
  51081. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51082. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51083. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51084. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51085. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51086. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51087. /** @hidden */
  51088. export var gpuRenderParticlesPixelShader: {
  51089. name: string;
  51090. shader: string;
  51091. };
  51092. }
  51093. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51094. /** @hidden */
  51095. export var clipPlaneVertexDeclaration2: {
  51096. name: string;
  51097. shader: string;
  51098. };
  51099. }
  51100. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51101. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51102. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51103. /** @hidden */
  51104. export var gpuRenderParticlesVertexShader: {
  51105. name: string;
  51106. shader: string;
  51107. };
  51108. }
  51109. declare module "babylonjs/Particles/gpuParticleSystem" {
  51110. import { Nullable } from "babylonjs/types";
  51111. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51112. import { Observable } from "babylonjs/Misc/observable";
  51113. import { Color4, Color3 } from "babylonjs/Maths/math";
  51114. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51115. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51116. import { Scene, IDisposable } from "babylonjs/scene";
  51117. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51118. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51119. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51120. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51121. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51122. /**
  51123. * This represents a GPU particle system in Babylon
  51124. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51125. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51126. */
  51127. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51128. /**
  51129. * The layer mask we are rendering the particles through.
  51130. */
  51131. layerMask: number;
  51132. private _capacity;
  51133. private _activeCount;
  51134. private _currentActiveCount;
  51135. private _accumulatedCount;
  51136. private _renderEffect;
  51137. private _updateEffect;
  51138. private _buffer0;
  51139. private _buffer1;
  51140. private _spriteBuffer;
  51141. private _updateVAO;
  51142. private _renderVAO;
  51143. private _targetIndex;
  51144. private _sourceBuffer;
  51145. private _targetBuffer;
  51146. private _engine;
  51147. private _currentRenderId;
  51148. private _started;
  51149. private _stopped;
  51150. private _timeDelta;
  51151. private _randomTexture;
  51152. private _randomTexture2;
  51153. private _attributesStrideSize;
  51154. private _updateEffectOptions;
  51155. private _randomTextureSize;
  51156. private _actualFrame;
  51157. private readonly _rawTextureWidth;
  51158. /**
  51159. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51160. */
  51161. static readonly IsSupported: boolean;
  51162. /**
  51163. * An event triggered when the system is disposed.
  51164. */
  51165. onDisposeObservable: Observable<GPUParticleSystem>;
  51166. /**
  51167. * Gets the maximum number of particles active at the same time.
  51168. * @returns The max number of active particles.
  51169. */
  51170. getCapacity(): number;
  51171. /**
  51172. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51173. * to override the particles.
  51174. */
  51175. forceDepthWrite: boolean;
  51176. /**
  51177. * Gets or set the number of active particles
  51178. */
  51179. activeParticleCount: number;
  51180. private _preWarmDone;
  51181. /**
  51182. * Is this system ready to be used/rendered
  51183. * @return true if the system is ready
  51184. */
  51185. isReady(): boolean;
  51186. /**
  51187. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51188. * @returns True if it has been started, otherwise false.
  51189. */
  51190. isStarted(): boolean;
  51191. /**
  51192. * Starts the particle system and begins to emit
  51193. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51194. */
  51195. start(delay?: number): void;
  51196. /**
  51197. * Stops the particle system.
  51198. */
  51199. stop(): void;
  51200. /**
  51201. * Remove all active particles
  51202. */
  51203. reset(): void;
  51204. /**
  51205. * Returns the string "GPUParticleSystem"
  51206. * @returns a string containing the class name
  51207. */
  51208. getClassName(): string;
  51209. private _colorGradientsTexture;
  51210. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51211. /**
  51212. * Adds a new color gradient
  51213. * @param gradient defines the gradient to use (between 0 and 1)
  51214. * @param color1 defines the color to affect to the specified gradient
  51215. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51216. * @returns the current particle system
  51217. */
  51218. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51219. /**
  51220. * Remove a specific color gradient
  51221. * @param gradient defines the gradient to remove
  51222. * @returns the current particle system
  51223. */
  51224. removeColorGradient(gradient: number): GPUParticleSystem;
  51225. private _angularSpeedGradientsTexture;
  51226. private _sizeGradientsTexture;
  51227. private _velocityGradientsTexture;
  51228. private _limitVelocityGradientsTexture;
  51229. private _dragGradientsTexture;
  51230. private _addFactorGradient;
  51231. /**
  51232. * Adds a new size gradient
  51233. * @param gradient defines the gradient to use (between 0 and 1)
  51234. * @param factor defines the size factor to affect to the specified gradient
  51235. * @returns the current particle system
  51236. */
  51237. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51238. /**
  51239. * Remove a specific size gradient
  51240. * @param gradient defines the gradient to remove
  51241. * @returns the current particle system
  51242. */
  51243. removeSizeGradient(gradient: number): GPUParticleSystem;
  51244. /**
  51245. * Adds a new angular speed gradient
  51246. * @param gradient defines the gradient to use (between 0 and 1)
  51247. * @param factor defines the angular speed to affect to the specified gradient
  51248. * @returns the current particle system
  51249. */
  51250. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51251. /**
  51252. * Remove a specific angular speed gradient
  51253. * @param gradient defines the gradient to remove
  51254. * @returns the current particle system
  51255. */
  51256. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51257. /**
  51258. * Adds a new velocity gradient
  51259. * @param gradient defines the gradient to use (between 0 and 1)
  51260. * @param factor defines the velocity to affect to the specified gradient
  51261. * @returns the current particle system
  51262. */
  51263. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51264. /**
  51265. * Remove a specific velocity gradient
  51266. * @param gradient defines the gradient to remove
  51267. * @returns the current particle system
  51268. */
  51269. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51270. /**
  51271. * Adds a new limit velocity gradient
  51272. * @param gradient defines the gradient to use (between 0 and 1)
  51273. * @param factor defines the limit velocity value to affect to the specified gradient
  51274. * @returns the current particle system
  51275. */
  51276. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51277. /**
  51278. * Remove a specific limit velocity gradient
  51279. * @param gradient defines the gradient to remove
  51280. * @returns the current particle system
  51281. */
  51282. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51283. /**
  51284. * Adds a new drag gradient
  51285. * @param gradient defines the gradient to use (between 0 and 1)
  51286. * @param factor defines the drag value to affect to the specified gradient
  51287. * @returns the current particle system
  51288. */
  51289. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51290. /**
  51291. * Remove a specific drag gradient
  51292. * @param gradient defines the gradient to remove
  51293. * @returns the current particle system
  51294. */
  51295. removeDragGradient(gradient: number): GPUParticleSystem;
  51296. /**
  51297. * Not supported by GPUParticleSystem
  51298. * @param gradient defines the gradient to use (between 0 and 1)
  51299. * @param factor defines the emit rate value to affect to the specified gradient
  51300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51301. * @returns the current particle system
  51302. */
  51303. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51304. /**
  51305. * Not supported by GPUParticleSystem
  51306. * @param gradient defines the gradient to remove
  51307. * @returns the current particle system
  51308. */
  51309. removeEmitRateGradient(gradient: number): IParticleSystem;
  51310. /**
  51311. * Not supported by GPUParticleSystem
  51312. * @param gradient defines the gradient to use (between 0 and 1)
  51313. * @param factor defines the start size value to affect to the specified gradient
  51314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51315. * @returns the current particle system
  51316. */
  51317. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51318. /**
  51319. * Not supported by GPUParticleSystem
  51320. * @param gradient defines the gradient to remove
  51321. * @returns the current particle system
  51322. */
  51323. removeStartSizeGradient(gradient: number): IParticleSystem;
  51324. /**
  51325. * Not supported by GPUParticleSystem
  51326. * @param gradient defines the gradient to use (between 0 and 1)
  51327. * @param min defines the color remap minimal range
  51328. * @param max defines the color remap maximal range
  51329. * @returns the current particle system
  51330. */
  51331. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51332. /**
  51333. * Not supported by GPUParticleSystem
  51334. * @param gradient defines the gradient to remove
  51335. * @returns the current particle system
  51336. */
  51337. removeColorRemapGradient(): IParticleSystem;
  51338. /**
  51339. * Not supported by GPUParticleSystem
  51340. * @param gradient defines the gradient to use (between 0 and 1)
  51341. * @param min defines the alpha remap minimal range
  51342. * @param max defines the alpha remap maximal range
  51343. * @returns the current particle system
  51344. */
  51345. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51346. /**
  51347. * Not supported by GPUParticleSystem
  51348. * @param gradient defines the gradient to remove
  51349. * @returns the current particle system
  51350. */
  51351. removeAlphaRemapGradient(): IParticleSystem;
  51352. /**
  51353. * Not supported by GPUParticleSystem
  51354. * @param gradient defines the gradient to use (between 0 and 1)
  51355. * @param color defines the color to affect to the specified gradient
  51356. * @returns the current particle system
  51357. */
  51358. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51359. /**
  51360. * Not supported by GPUParticleSystem
  51361. * @param gradient defines the gradient to remove
  51362. * @returns the current particle system
  51363. */
  51364. removeRampGradient(): IParticleSystem;
  51365. /**
  51366. * Not supported by GPUParticleSystem
  51367. * @returns the list of ramp gradients
  51368. */
  51369. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51370. /**
  51371. * Not supported by GPUParticleSystem
  51372. * Gets or sets a boolean indicating that ramp gradients must be used
  51373. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51374. */
  51375. useRampGradients: boolean;
  51376. /**
  51377. * Not supported by GPUParticleSystem
  51378. * @param gradient defines the gradient to use (between 0 and 1)
  51379. * @param factor defines the life time factor to affect to the specified gradient
  51380. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51381. * @returns the current particle system
  51382. */
  51383. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51384. /**
  51385. * Not supported by GPUParticleSystem
  51386. * @param gradient defines the gradient to remove
  51387. * @returns the current particle system
  51388. */
  51389. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51390. /**
  51391. * Instantiates a GPU particle system.
  51392. * 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.
  51393. * @param name The name of the particle system
  51394. * @param options The options used to create the system
  51395. * @param scene The scene the particle system belongs to
  51396. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51397. */
  51398. constructor(name: string, options: Partial<{
  51399. capacity: number;
  51400. randomTextureSize: number;
  51401. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51402. protected _reset(): void;
  51403. private _createUpdateVAO;
  51404. private _createRenderVAO;
  51405. private _initialize;
  51406. /** @hidden */
  51407. _recreateUpdateEffect(): void;
  51408. /** @hidden */
  51409. _recreateRenderEffect(): void;
  51410. /**
  51411. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51412. * @param preWarm defines if we are in the pre-warmimg phase
  51413. */
  51414. animate(preWarm?: boolean): void;
  51415. private _createFactorGradientTexture;
  51416. private _createSizeGradientTexture;
  51417. private _createAngularSpeedGradientTexture;
  51418. private _createVelocityGradientTexture;
  51419. private _createLimitVelocityGradientTexture;
  51420. private _createDragGradientTexture;
  51421. private _createColorGradientTexture;
  51422. /**
  51423. * Renders the particle system in its current state
  51424. * @param preWarm defines if the system should only update the particles but not render them
  51425. * @returns the current number of particles
  51426. */
  51427. render(preWarm?: boolean): number;
  51428. /**
  51429. * Rebuilds the particle system
  51430. */
  51431. rebuild(): void;
  51432. private _releaseBuffers;
  51433. private _releaseVAOs;
  51434. /**
  51435. * Disposes the particle system and free the associated resources
  51436. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51437. */
  51438. dispose(disposeTexture?: boolean): void;
  51439. /**
  51440. * Clones the particle system.
  51441. * @param name The name of the cloned object
  51442. * @param newEmitter The new emitter to use
  51443. * @returns the cloned particle system
  51444. */
  51445. clone(name: string, newEmitter: any): GPUParticleSystem;
  51446. /**
  51447. * Serializes the particle system to a JSON object.
  51448. * @returns the JSON object
  51449. */
  51450. serialize(): any;
  51451. /**
  51452. * Parses a JSON object to create a GPU particle system.
  51453. * @param parsedParticleSystem The JSON object to parse
  51454. * @param scene The scene to create the particle system in
  51455. * @param rootUrl The root url to use to load external dependencies like texture
  51456. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51457. * @returns the parsed GPU particle system
  51458. */
  51459. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51460. }
  51461. }
  51462. declare module "babylonjs/Particles/particleSystemSet" {
  51463. import { Nullable } from "babylonjs/types";
  51464. import { Color3 } from "babylonjs/Maths/math";
  51465. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51467. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51468. import { Scene, IDisposable } from "babylonjs/scene";
  51469. /**
  51470. * Represents a set of particle systems working together to create a specific effect
  51471. */
  51472. export class ParticleSystemSet implements IDisposable {
  51473. private _emitterCreationOptions;
  51474. private _emitterNode;
  51475. /**
  51476. * Gets the particle system list
  51477. */
  51478. systems: IParticleSystem[];
  51479. /**
  51480. * Gets the emitter node used with this set
  51481. */
  51482. readonly emitterNode: Nullable<TransformNode>;
  51483. /**
  51484. * Creates a new emitter mesh as a sphere
  51485. * @param options defines the options used to create the sphere
  51486. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51487. * @param scene defines the hosting scene
  51488. */
  51489. setEmitterAsSphere(options: {
  51490. diameter: number;
  51491. segments: number;
  51492. color: Color3;
  51493. }, renderingGroupId: number, scene: Scene): void;
  51494. /**
  51495. * Starts all particle systems of the set
  51496. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51497. */
  51498. start(emitter?: AbstractMesh): void;
  51499. /**
  51500. * Release all associated resources
  51501. */
  51502. dispose(): void;
  51503. /**
  51504. * Serialize the set into a JSON compatible object
  51505. * @returns a JSON compatible representation of the set
  51506. */
  51507. serialize(): any;
  51508. /**
  51509. * Parse a new ParticleSystemSet from a serialized source
  51510. * @param data defines a JSON compatible representation of the set
  51511. * @param scene defines the hosting scene
  51512. * @param gpu defines if we want GPU particles or CPU particles
  51513. * @returns a new ParticleSystemSet
  51514. */
  51515. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51516. }
  51517. }
  51518. declare module "babylonjs/Particles/particleHelper" {
  51519. import { Nullable } from "babylonjs/types";
  51520. import { Scene } from "babylonjs/scene";
  51521. import { Vector3 } from "babylonjs/Maths/math";
  51522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51523. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51524. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51525. /**
  51526. * This class is made for on one-liner static method to help creating particle system set.
  51527. */
  51528. export class ParticleHelper {
  51529. /**
  51530. * Gets or sets base Assets URL
  51531. */
  51532. static BaseAssetsUrl: string;
  51533. /**
  51534. * Create a default particle system that you can tweak
  51535. * @param emitter defines the emitter to use
  51536. * @param capacity defines the system capacity (default is 500 particles)
  51537. * @param scene defines the hosting scene
  51538. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51539. * @returns the new Particle system
  51540. */
  51541. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51542. /**
  51543. * This is the main static method (one-liner) of this helper to create different particle systems
  51544. * @param type This string represents the type to the particle system to create
  51545. * @param scene The scene where the particle system should live
  51546. * @param gpu If the system will use gpu
  51547. * @returns the ParticleSystemSet created
  51548. */
  51549. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51550. /**
  51551. * Static function used to export a particle system to a ParticleSystemSet variable.
  51552. * Please note that the emitter shape is not exported
  51553. * @param systems defines the particle systems to export
  51554. * @returns the created particle system set
  51555. */
  51556. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51557. }
  51558. }
  51559. declare module "babylonjs/Particles/particleSystemComponent" {
  51560. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51561. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51562. import "babylonjs/Shaders/particles.vertex";
  51563. module "babylonjs/Engines/engine" {
  51564. interface Engine {
  51565. /**
  51566. * Create an effect to use with particle systems.
  51567. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51568. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51569. * @param uniformsNames defines a list of attribute names
  51570. * @param samplers defines an array of string used to represent textures
  51571. * @param defines defines the string containing the defines to use to compile the shaders
  51572. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51573. * @param onCompiled defines a function to call when the effect creation is successful
  51574. * @param onError defines a function to call when the effect creation has failed
  51575. * @returns the new Effect
  51576. */
  51577. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51578. }
  51579. }
  51580. module "babylonjs/Meshes/mesh" {
  51581. interface Mesh {
  51582. /**
  51583. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51584. * @returns an array of IParticleSystem
  51585. */
  51586. getEmittedParticleSystems(): IParticleSystem[];
  51587. /**
  51588. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51589. * @returns an array of IParticleSystem
  51590. */
  51591. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51592. }
  51593. }
  51594. /**
  51595. * @hidden
  51596. */
  51597. export var _IDoNeedToBeInTheBuild: number;
  51598. }
  51599. declare module "babylonjs/Particles/index" {
  51600. export * from "babylonjs/Particles/baseParticleSystem";
  51601. export * from "babylonjs/Particles/EmitterTypes/index";
  51602. export * from "babylonjs/Particles/gpuParticleSystem";
  51603. export * from "babylonjs/Particles/IParticleSystem";
  51604. export * from "babylonjs/Particles/particle";
  51605. export * from "babylonjs/Particles/particleHelper";
  51606. export * from "babylonjs/Particles/particleSystem";
  51607. export * from "babylonjs/Particles/particleSystemComponent";
  51608. export * from "babylonjs/Particles/particleSystemSet";
  51609. export * from "babylonjs/Particles/solidParticle";
  51610. export * from "babylonjs/Particles/solidParticleSystem";
  51611. export * from "babylonjs/Particles/subEmitter";
  51612. }
  51613. declare module "babylonjs/Physics/physicsEngineComponent" {
  51614. import { Nullable } from "babylonjs/types";
  51615. import { Observable, Observer } from "babylonjs/Misc/observable";
  51616. import { Vector3 } from "babylonjs/Maths/math";
  51617. import { Mesh } from "babylonjs/Meshes/mesh";
  51618. import { ISceneComponent } from "babylonjs/sceneComponent";
  51619. import { Scene } from "babylonjs/scene";
  51620. import { Node } from "babylonjs/node";
  51621. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51622. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51623. module "babylonjs/scene" {
  51624. interface Scene {
  51625. /** @hidden (Backing field) */
  51626. _physicsEngine: Nullable<IPhysicsEngine>;
  51627. /**
  51628. * Gets the current physics engine
  51629. * @returns a IPhysicsEngine or null if none attached
  51630. */
  51631. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51632. /**
  51633. * Enables physics to the current scene
  51634. * @param gravity defines the scene's gravity for the physics engine
  51635. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51636. * @return a boolean indicating if the physics engine was initialized
  51637. */
  51638. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51639. /**
  51640. * Disables and disposes the physics engine associated with the scene
  51641. */
  51642. disablePhysicsEngine(): void;
  51643. /**
  51644. * Gets a boolean indicating if there is an active physics engine
  51645. * @returns a boolean indicating if there is an active physics engine
  51646. */
  51647. isPhysicsEnabled(): boolean;
  51648. /**
  51649. * Deletes a physics compound impostor
  51650. * @param compound defines the compound to delete
  51651. */
  51652. deleteCompoundImpostor(compound: any): void;
  51653. /**
  51654. * An event triggered when physic simulation is about to be run
  51655. */
  51656. onBeforePhysicsObservable: Observable<Scene>;
  51657. /**
  51658. * An event triggered when physic simulation has been done
  51659. */
  51660. onAfterPhysicsObservable: Observable<Scene>;
  51661. }
  51662. }
  51663. module "babylonjs/Meshes/abstractMesh" {
  51664. interface AbstractMesh {
  51665. /** @hidden */
  51666. _physicsImpostor: Nullable<PhysicsImpostor>;
  51667. /**
  51668. * Gets or sets impostor used for physic simulation
  51669. * @see http://doc.babylonjs.com/features/physics_engine
  51670. */
  51671. physicsImpostor: Nullable<PhysicsImpostor>;
  51672. /**
  51673. * Gets the current physics impostor
  51674. * @see http://doc.babylonjs.com/features/physics_engine
  51675. * @returns a physics impostor or null
  51676. */
  51677. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51678. /** Apply a physic impulse to the mesh
  51679. * @param force defines the force to apply
  51680. * @param contactPoint defines where to apply the force
  51681. * @returns the current mesh
  51682. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51683. */
  51684. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51685. /**
  51686. * Creates a physic joint between two meshes
  51687. * @param otherMesh defines the other mesh to use
  51688. * @param pivot1 defines the pivot to use on this mesh
  51689. * @param pivot2 defines the pivot to use on the other mesh
  51690. * @param options defines additional options (can be plugin dependent)
  51691. * @returns the current mesh
  51692. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51693. */
  51694. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51695. /** @hidden */
  51696. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51697. }
  51698. }
  51699. /**
  51700. * Defines the physics engine scene component responsible to manage a physics engine
  51701. */
  51702. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51703. /**
  51704. * The component name helpful to identify the component in the list of scene components.
  51705. */
  51706. readonly name: string;
  51707. /**
  51708. * The scene the component belongs to.
  51709. */
  51710. scene: Scene;
  51711. /**
  51712. * Creates a new instance of the component for the given scene
  51713. * @param scene Defines the scene to register the component in
  51714. */
  51715. constructor(scene: Scene);
  51716. /**
  51717. * Registers the component in a given scene
  51718. */
  51719. register(): void;
  51720. /**
  51721. * Rebuilds the elements related to this component in case of
  51722. * context lost for instance.
  51723. */
  51724. rebuild(): void;
  51725. /**
  51726. * Disposes the component and the associated ressources
  51727. */
  51728. dispose(): void;
  51729. }
  51730. }
  51731. declare module "babylonjs/Physics/physicsHelper" {
  51732. import { Nullable } from "babylonjs/types";
  51733. import { Vector3 } from "babylonjs/Maths/math";
  51734. import { Mesh } from "babylonjs/Meshes/mesh";
  51735. import { Ray } from "babylonjs/Culling/ray";
  51736. import { Scene } from "babylonjs/scene";
  51737. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51738. /**
  51739. * A helper for physics simulations
  51740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51741. */
  51742. export class PhysicsHelper {
  51743. private _scene;
  51744. private _physicsEngine;
  51745. /**
  51746. * Initializes the Physics helper
  51747. * @param scene Babylon.js scene
  51748. */
  51749. constructor(scene: Scene);
  51750. /**
  51751. * Applies a radial explosion impulse
  51752. * @param origin the origin of the explosion
  51753. * @param radius the explosion radius
  51754. * @param strength the explosion strength
  51755. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51756. * @returns A physics radial explosion event, or null
  51757. */
  51758. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51759. /**
  51760. * Applies a radial explosion force
  51761. * @param origin the origin of the explosion
  51762. * @param radius the explosion radius
  51763. * @param strength the explosion strength
  51764. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51765. * @returns A physics radial explosion event, or null
  51766. */
  51767. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51768. /**
  51769. * Creates a gravitational field
  51770. * @param origin the origin of the explosion
  51771. * @param radius the explosion radius
  51772. * @param strength the explosion strength
  51773. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51774. * @returns A physics gravitational field event, or null
  51775. */
  51776. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51777. /**
  51778. * Creates a physics updraft event
  51779. * @param origin the origin of the updraft
  51780. * @param radius the radius of the updraft
  51781. * @param strength the strength of the updraft
  51782. * @param height the height of the updraft
  51783. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51784. * @returns A physics updraft event, or null
  51785. */
  51786. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51787. /**
  51788. * Creates a physics vortex event
  51789. * @param origin the of the vortex
  51790. * @param radius the radius of the vortex
  51791. * @param strength the strength of the vortex
  51792. * @param height the height of the vortex
  51793. * @returns a Physics vortex event, or null
  51794. * A physics vortex event or null
  51795. */
  51796. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  51797. }
  51798. /**
  51799. * Represents a physics radial explosion event
  51800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51801. */
  51802. export class PhysicsRadialExplosionEvent {
  51803. private _scene;
  51804. private _sphere;
  51805. private _sphereOptions;
  51806. private _rays;
  51807. private _dataFetched;
  51808. /**
  51809. * Initializes a radial explosioin event
  51810. * @param scene BabylonJS scene
  51811. */
  51812. constructor(scene: Scene);
  51813. /**
  51814. * Returns the data related to the radial explosion event (sphere & rays).
  51815. * @returns The radial explosion event data
  51816. */
  51817. getData(): PhysicsRadialExplosionEventData;
  51818. /**
  51819. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51820. * @param impostor A physics imposter
  51821. * @param origin the origin of the explosion
  51822. * @param radius the explosion radius
  51823. * @param strength the explosion strength
  51824. * @param falloff possible options: Constant & Linear
  51825. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  51826. */
  51827. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  51828. /**
  51829. * Disposes the sphere.
  51830. * @param force Specifies if the sphere should be disposed by force
  51831. */
  51832. dispose(force?: boolean): void;
  51833. /*** Helpers ***/
  51834. private _prepareSphere;
  51835. private _intersectsWithSphere;
  51836. }
  51837. /**
  51838. * Represents a gravitational field event
  51839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51840. */
  51841. export class PhysicsGravitationalFieldEvent {
  51842. private _physicsHelper;
  51843. private _scene;
  51844. private _origin;
  51845. private _radius;
  51846. private _strength;
  51847. private _falloff;
  51848. private _tickCallback;
  51849. private _sphere;
  51850. private _dataFetched;
  51851. /**
  51852. * Initializes the physics gravitational field event
  51853. * @param physicsHelper A physics helper
  51854. * @param scene BabylonJS scene
  51855. * @param origin The origin position of the gravitational field event
  51856. * @param radius The radius of the gravitational field event
  51857. * @param strength The strength of the gravitational field event
  51858. * @param falloff The falloff for the gravitational field event
  51859. */
  51860. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  51861. /**
  51862. * Returns the data related to the gravitational field event (sphere).
  51863. * @returns A gravitational field event
  51864. */
  51865. getData(): PhysicsGravitationalFieldEventData;
  51866. /**
  51867. * Enables the gravitational field.
  51868. */
  51869. enable(): void;
  51870. /**
  51871. * Disables the gravitational field.
  51872. */
  51873. disable(): void;
  51874. /**
  51875. * Disposes the sphere.
  51876. * @param force The force to dispose from the gravitational field event
  51877. */
  51878. dispose(force?: boolean): void;
  51879. private _tick;
  51880. }
  51881. /**
  51882. * Represents a physics updraft event
  51883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51884. */
  51885. export class PhysicsUpdraftEvent {
  51886. private _scene;
  51887. private _origin;
  51888. private _radius;
  51889. private _strength;
  51890. private _height;
  51891. private _updraftMode;
  51892. private _physicsEngine;
  51893. private _originTop;
  51894. private _originDirection;
  51895. private _tickCallback;
  51896. private _cylinder;
  51897. private _cylinderPosition;
  51898. private _dataFetched;
  51899. /**
  51900. * Initializes the physics updraft event
  51901. * @param _scene BabylonJS scene
  51902. * @param _origin The origin position of the updraft
  51903. * @param _radius The radius of the updraft
  51904. * @param _strength The strength of the updraft
  51905. * @param _height The height of the updraft
  51906. * @param _updraftMode The mode of the updraft
  51907. */
  51908. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  51909. /**
  51910. * Returns the data related to the updraft event (cylinder).
  51911. * @returns A physics updraft event
  51912. */
  51913. getData(): PhysicsUpdraftEventData;
  51914. /**
  51915. * Enables the updraft.
  51916. */
  51917. enable(): void;
  51918. /**
  51919. * Disables the cortex.
  51920. */
  51921. disable(): void;
  51922. /**
  51923. * Disposes the sphere.
  51924. * @param force Specifies if the updraft should be disposed by force
  51925. */
  51926. dispose(force?: boolean): void;
  51927. private getImpostorForceAndContactPoint;
  51928. private _tick;
  51929. /*** Helpers ***/
  51930. private _prepareCylinder;
  51931. private _intersectsWithCylinder;
  51932. }
  51933. /**
  51934. * Represents a physics vortex event
  51935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51936. */
  51937. export class PhysicsVortexEvent {
  51938. private _scene;
  51939. private _origin;
  51940. private _radius;
  51941. private _strength;
  51942. private _height;
  51943. private _physicsEngine;
  51944. private _originTop;
  51945. private _centripetalForceThreshold;
  51946. private _updraftMultiplier;
  51947. private _tickCallback;
  51948. private _cylinder;
  51949. private _cylinderPosition;
  51950. private _dataFetched;
  51951. /**
  51952. * Initializes the physics vortex event
  51953. * @param _scene The BabylonJS scene
  51954. * @param _origin The origin position of the vortex
  51955. * @param _radius The radius of the vortex
  51956. * @param _strength The strength of the vortex
  51957. * @param _height The height of the vortex
  51958. */
  51959. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  51960. /**
  51961. * Returns the data related to the vortex event (cylinder).
  51962. * @returns The physics vortex event data
  51963. */
  51964. getData(): PhysicsVortexEventData;
  51965. /**
  51966. * Enables the vortex.
  51967. */
  51968. enable(): void;
  51969. /**
  51970. * Disables the cortex.
  51971. */
  51972. disable(): void;
  51973. /**
  51974. * Disposes the sphere.
  51975. * @param force
  51976. */
  51977. dispose(force?: boolean): void;
  51978. private getImpostorForceAndContactPoint;
  51979. private _tick;
  51980. /*** Helpers ***/
  51981. private _prepareCylinder;
  51982. private _intersectsWithCylinder;
  51983. }
  51984. /**
  51985. * The strenght of the force in correspondence to the distance of the affected object
  51986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51987. */
  51988. export enum PhysicsRadialImpulseFalloff {
  51989. /** Defines that impulse is constant in strength across it's whole radius */
  51990. Constant = 0,
  51991. /** DEfines that impulse gets weaker if it's further from the origin */
  51992. Linear = 1
  51993. }
  51994. /**
  51995. * The strength of the force in correspondence to the distance of the affected object
  51996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51997. */
  51998. export enum PhysicsUpdraftMode {
  51999. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52000. Center = 0,
  52001. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52002. Perpendicular = 1
  52003. }
  52004. /**
  52005. * Interface for a physics force and contact point
  52006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52007. */
  52008. export interface PhysicsForceAndContactPoint {
  52009. /**
  52010. * The force applied at the contact point
  52011. */
  52012. force: Vector3;
  52013. /**
  52014. * The contact point
  52015. */
  52016. contactPoint: Vector3;
  52017. }
  52018. /**
  52019. * Interface for radial explosion event data
  52020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52021. */
  52022. export interface PhysicsRadialExplosionEventData {
  52023. /**
  52024. * A sphere used for the radial explosion event
  52025. */
  52026. sphere: Mesh;
  52027. /**
  52028. * An array of rays for the radial explosion event
  52029. */
  52030. rays: Array<Ray>;
  52031. }
  52032. /**
  52033. * Interface for gravitational field event data
  52034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52035. */
  52036. export interface PhysicsGravitationalFieldEventData {
  52037. /**
  52038. * A sphere mesh used for the gravitational field event
  52039. */
  52040. sphere: Mesh;
  52041. }
  52042. /**
  52043. * Interface for updraft event data
  52044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52045. */
  52046. export interface PhysicsUpdraftEventData {
  52047. /**
  52048. * A cylinder used for the updraft event
  52049. */
  52050. cylinder: Mesh;
  52051. }
  52052. /**
  52053. * Interface for vortex event data
  52054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52055. */
  52056. export interface PhysicsVortexEventData {
  52057. /**
  52058. * A cylinder used for the vortex event
  52059. */
  52060. cylinder: Mesh;
  52061. }
  52062. }
  52063. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52064. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52065. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52066. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52067. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52068. import { Nullable } from "babylonjs/types";
  52069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52070. /**
  52071. * AmmoJS Physics plugin
  52072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52073. * @see https://github.com/kripken/ammo.js/
  52074. */
  52075. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52076. private _useDeltaForWorldStep;
  52077. /**
  52078. * Reference to the Ammo library
  52079. */
  52080. bjsAMMO: any;
  52081. /**
  52082. * Created ammoJS world which physics bodies are added to
  52083. */
  52084. world: any;
  52085. /**
  52086. * Name of the plugin
  52087. */
  52088. name: string;
  52089. private _timeStep;
  52090. private _fixedTimeStep;
  52091. private _maxSteps;
  52092. private _tmpQuaternion;
  52093. private _tmpAmmoTransform;
  52094. private _tmpAmmoQuaternion;
  52095. private _tmpAmmoConcreteContactResultCallback;
  52096. private _collisionConfiguration;
  52097. private _dispatcher;
  52098. private _overlappingPairCache;
  52099. private _solver;
  52100. private _tmpAmmoVectorA;
  52101. private _tmpAmmoVectorB;
  52102. private _tmpAmmoVectorC;
  52103. private _tmpContactCallbackResult;
  52104. private static readonly DISABLE_COLLISION_FLAG;
  52105. private static readonly KINEMATIC_FLAG;
  52106. private static readonly DISABLE_DEACTIVATION_FLAG;
  52107. /**
  52108. * Initializes the ammoJS plugin
  52109. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52110. * @param ammoInjection can be used to inject your own ammo reference
  52111. */
  52112. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52113. /**
  52114. * Sets the gravity of the physics world (m/(s^2))
  52115. * @param gravity Gravity to set
  52116. */
  52117. setGravity(gravity: Vector3): void;
  52118. /**
  52119. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52120. * @param timeStep timestep to use in seconds
  52121. */
  52122. setTimeStep(timeStep: number): void;
  52123. /**
  52124. * 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)
  52125. * @param fixedTimeStep fixedTimeStep to use in seconds
  52126. */
  52127. setFixedTimeStep(fixedTimeStep: number): void;
  52128. /**
  52129. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52130. * @param maxSteps the maximum number of steps by the physics engine per frame
  52131. */
  52132. setMaxSteps(maxSteps: number): void;
  52133. /**
  52134. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52135. * @returns the current timestep in seconds
  52136. */
  52137. getTimeStep(): number;
  52138. private _isImpostorInContact;
  52139. private _isImpostorPairInContact;
  52140. private _stepSimulation;
  52141. /**
  52142. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52143. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52144. * After the step the babylon meshes are set to the position of the physics imposters
  52145. * @param delta amount of time to step forward
  52146. * @param impostors array of imposters to update before/after the step
  52147. */
  52148. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52149. private _tmpVector;
  52150. private _tmpMatrix;
  52151. /**
  52152. * Applies an implulse on the imposter
  52153. * @param impostor imposter to apply impulse
  52154. * @param force amount of force to be applied to the imposter
  52155. * @param contactPoint the location to apply the impulse on the imposter
  52156. */
  52157. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52158. /**
  52159. * Applies a force on the imposter
  52160. * @param impostor imposter to apply force
  52161. * @param force amount of force to be applied to the imposter
  52162. * @param contactPoint the location to apply the force on the imposter
  52163. */
  52164. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52165. /**
  52166. * Creates a physics body using the plugin
  52167. * @param impostor the imposter to create the physics body on
  52168. */
  52169. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52170. /**
  52171. * Removes the physics body from the imposter and disposes of the body's memory
  52172. * @param impostor imposter to remove the physics body from
  52173. */
  52174. removePhysicsBody(impostor: PhysicsImpostor): void;
  52175. /**
  52176. * Generates a joint
  52177. * @param impostorJoint the imposter joint to create the joint with
  52178. */
  52179. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52180. /**
  52181. * Removes a joint
  52182. * @param impostorJoint the imposter joint to remove the joint from
  52183. */
  52184. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52185. private _addMeshVerts;
  52186. private _createShape;
  52187. /**
  52188. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52189. * @param impostor imposter containing the physics body and babylon object
  52190. */
  52191. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52192. /**
  52193. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52194. * @param impostor imposter containing the physics body and babylon object
  52195. * @param newPosition new position
  52196. * @param newRotation new rotation
  52197. */
  52198. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52199. /**
  52200. * If this plugin is supported
  52201. * @returns true if its supported
  52202. */
  52203. isSupported(): boolean;
  52204. /**
  52205. * Sets the linear velocity of the physics body
  52206. * @param impostor imposter to set the velocity on
  52207. * @param velocity velocity to set
  52208. */
  52209. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52210. /**
  52211. * Sets the angular velocity of the physics body
  52212. * @param impostor imposter to set the velocity on
  52213. * @param velocity velocity to set
  52214. */
  52215. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52216. /**
  52217. * gets the linear velocity
  52218. * @param impostor imposter to get linear velocity from
  52219. * @returns linear velocity
  52220. */
  52221. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52222. /**
  52223. * gets the angular velocity
  52224. * @param impostor imposter to get angular velocity from
  52225. * @returns angular velocity
  52226. */
  52227. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52228. /**
  52229. * Sets the mass of physics body
  52230. * @param impostor imposter to set the mass on
  52231. * @param mass mass to set
  52232. */
  52233. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52234. /**
  52235. * Gets the mass of the physics body
  52236. * @param impostor imposter to get the mass from
  52237. * @returns mass
  52238. */
  52239. getBodyMass(impostor: PhysicsImpostor): number;
  52240. /**
  52241. * Gets friction of the impostor
  52242. * @param impostor impostor to get friction from
  52243. * @returns friction value
  52244. */
  52245. getBodyFriction(impostor: PhysicsImpostor): number;
  52246. /**
  52247. * Sets friction of the impostor
  52248. * @param impostor impostor to set friction on
  52249. * @param friction friction value
  52250. */
  52251. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52252. /**
  52253. * Gets restitution of the impostor
  52254. * @param impostor impostor to get restitution from
  52255. * @returns restitution value
  52256. */
  52257. getBodyRestitution(impostor: PhysicsImpostor): number;
  52258. /**
  52259. * Sets resitution of the impostor
  52260. * @param impostor impostor to set resitution on
  52261. * @param restitution resitution value
  52262. */
  52263. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52264. /**
  52265. * Sleeps the physics body and stops it from being active
  52266. * @param impostor impostor to sleep
  52267. */
  52268. sleepBody(impostor: PhysicsImpostor): void;
  52269. /**
  52270. * Activates the physics body
  52271. * @param impostor impostor to activate
  52272. */
  52273. wakeUpBody(impostor: PhysicsImpostor): void;
  52274. /**
  52275. * Updates the distance parameters of the joint
  52276. * @param joint joint to update
  52277. * @param maxDistance maximum distance of the joint
  52278. * @param minDistance minimum distance of the joint
  52279. */
  52280. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52281. /**
  52282. * Sets a motor on the joint
  52283. * @param joint joint to set motor on
  52284. * @param speed speed of the motor
  52285. * @param maxForce maximum force of the motor
  52286. * @param motorIndex index of the motor
  52287. */
  52288. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52289. /**
  52290. * Sets the motors limit
  52291. * @param joint joint to set limit on
  52292. * @param upperLimit upper limit
  52293. * @param lowerLimit lower limit
  52294. */
  52295. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52296. /**
  52297. * Syncs the position and rotation of a mesh with the impostor
  52298. * @param mesh mesh to sync
  52299. * @param impostor impostor to update the mesh with
  52300. */
  52301. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52302. /**
  52303. * Gets the radius of the impostor
  52304. * @param impostor impostor to get radius from
  52305. * @returns the radius
  52306. */
  52307. getRadius(impostor: PhysicsImpostor): number;
  52308. /**
  52309. * Gets the box size of the impostor
  52310. * @param impostor impostor to get box size from
  52311. * @param result the resulting box size
  52312. */
  52313. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52314. /**
  52315. * Disposes of the impostor
  52316. */
  52317. dispose(): void;
  52318. }
  52319. }
  52320. declare module "babylonjs/Physics/Plugins/index" {
  52321. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52322. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52323. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52324. }
  52325. declare module "babylonjs/Physics/index" {
  52326. export * from "babylonjs/Physics/IPhysicsEngine";
  52327. export * from "babylonjs/Physics/physicsEngine";
  52328. export * from "babylonjs/Physics/physicsEngineComponent";
  52329. export * from "babylonjs/Physics/physicsHelper";
  52330. export * from "babylonjs/Physics/physicsImpostor";
  52331. export * from "babylonjs/Physics/physicsJoint";
  52332. export * from "babylonjs/Physics/Plugins/index";
  52333. }
  52334. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52335. /** @hidden */
  52336. export var blackAndWhitePixelShader: {
  52337. name: string;
  52338. shader: string;
  52339. };
  52340. }
  52341. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52342. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52343. import { Camera } from "babylonjs/Cameras/camera";
  52344. import { Engine } from "babylonjs/Engines/engine";
  52345. import "babylonjs/Shaders/blackAndWhite.fragment";
  52346. /**
  52347. * Post process used to render in black and white
  52348. */
  52349. export class BlackAndWhitePostProcess extends PostProcess {
  52350. /**
  52351. * Linear about to convert he result to black and white (default: 1)
  52352. */
  52353. degree: number;
  52354. /**
  52355. * Creates a black and white post process
  52356. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52357. * @param name The name of the effect.
  52358. * @param options The required width/height ratio to downsize to before computing the render pass.
  52359. * @param camera The camera to apply the render pass to.
  52360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52361. * @param engine The engine which the post process will be applied. (default: current engine)
  52362. * @param reusable If the post process can be reused on the same frame. (default: false)
  52363. */
  52364. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52365. }
  52366. }
  52367. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52368. import { Nullable } from "babylonjs/types";
  52369. import { Camera } from "babylonjs/Cameras/camera";
  52370. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52371. import { Engine } from "babylonjs/Engines/engine";
  52372. /**
  52373. * This represents a set of one or more post processes in Babylon.
  52374. * A post process can be used to apply a shader to a texture after it is rendered.
  52375. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52376. */
  52377. export class PostProcessRenderEffect {
  52378. private _postProcesses;
  52379. private _getPostProcesses;
  52380. private _singleInstance;
  52381. private _cameras;
  52382. private _indicesForCamera;
  52383. /**
  52384. * Name of the effect
  52385. * @hidden
  52386. */
  52387. _name: string;
  52388. /**
  52389. * Instantiates a post process render effect.
  52390. * A post process can be used to apply a shader to a texture after it is rendered.
  52391. * @param engine The engine the effect is tied to
  52392. * @param name The name of the effect
  52393. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52394. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52395. */
  52396. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52397. /**
  52398. * Checks if all the post processes in the effect are supported.
  52399. */
  52400. readonly isSupported: boolean;
  52401. /**
  52402. * Updates the current state of the effect
  52403. * @hidden
  52404. */
  52405. _update(): void;
  52406. /**
  52407. * Attaches the effect on cameras
  52408. * @param cameras The camera to attach to.
  52409. * @hidden
  52410. */
  52411. _attachCameras(cameras: Camera): void;
  52412. /**
  52413. * Attaches the effect on cameras
  52414. * @param cameras The camera to attach to.
  52415. * @hidden
  52416. */
  52417. _attachCameras(cameras: Camera[]): void;
  52418. /**
  52419. * Detatches the effect on cameras
  52420. * @param cameras The camera to detatch from.
  52421. * @hidden
  52422. */
  52423. _detachCameras(cameras: Camera): void;
  52424. /**
  52425. * Detatches the effect on cameras
  52426. * @param cameras The camera to detatch from.
  52427. * @hidden
  52428. */
  52429. _detachCameras(cameras: Camera[]): void;
  52430. /**
  52431. * Enables the effect on given cameras
  52432. * @param cameras The camera to enable.
  52433. * @hidden
  52434. */
  52435. _enable(cameras: Camera): void;
  52436. /**
  52437. * Enables the effect on given cameras
  52438. * @param cameras The camera to enable.
  52439. * @hidden
  52440. */
  52441. _enable(cameras: Nullable<Camera[]>): void;
  52442. /**
  52443. * Disables the effect on the given cameras
  52444. * @param cameras The camera to disable.
  52445. * @hidden
  52446. */
  52447. _disable(cameras: Camera): void;
  52448. /**
  52449. * Disables the effect on the given cameras
  52450. * @param cameras The camera to disable.
  52451. * @hidden
  52452. */
  52453. _disable(cameras: Nullable<Camera[]>): void;
  52454. /**
  52455. * Gets a list of the post processes contained in the effect.
  52456. * @param camera The camera to get the post processes on.
  52457. * @returns The list of the post processes in the effect.
  52458. */
  52459. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52460. }
  52461. }
  52462. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52463. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52464. /** @hidden */
  52465. export var extractHighlightsPixelShader: {
  52466. name: string;
  52467. shader: string;
  52468. };
  52469. }
  52470. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52471. import { Nullable } from "babylonjs/types";
  52472. import { Camera } from "babylonjs/Cameras/camera";
  52473. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52474. import { Engine } from "babylonjs/Engines/engine";
  52475. import "babylonjs/Shaders/extractHighlights.fragment";
  52476. /**
  52477. * 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.
  52478. */
  52479. export class ExtractHighlightsPostProcess extends PostProcess {
  52480. /**
  52481. * The luminance threshold, pixels below this value will be set to black.
  52482. */
  52483. threshold: number;
  52484. /** @hidden */
  52485. _exposure: number;
  52486. /**
  52487. * Post process which has the input texture to be used when performing highlight extraction
  52488. * @hidden
  52489. */
  52490. _inputPostProcess: Nullable<PostProcess>;
  52491. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52492. }
  52493. }
  52494. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52495. /** @hidden */
  52496. export var bloomMergePixelShader: {
  52497. name: string;
  52498. shader: string;
  52499. };
  52500. }
  52501. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52502. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52503. import { Nullable } from "babylonjs/types";
  52504. import { Engine } from "babylonjs/Engines/engine";
  52505. import { Camera } from "babylonjs/Cameras/camera";
  52506. import "babylonjs/Shaders/bloomMerge.fragment";
  52507. /**
  52508. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52509. */
  52510. export class BloomMergePostProcess extends PostProcess {
  52511. /** Weight of the bloom to be added to the original input. */
  52512. weight: number;
  52513. /**
  52514. * Creates a new instance of @see BloomMergePostProcess
  52515. * @param name The name of the effect.
  52516. * @param originalFromInput Post process which's input will be used for the merge.
  52517. * @param blurred Blurred highlights post process which's output will be used.
  52518. * @param weight Weight of the bloom to be added to the original input.
  52519. * @param options The required width/height ratio to downsize to before computing the render pass.
  52520. * @param camera The camera to apply the render pass to.
  52521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52522. * @param engine The engine which the post process will be applied. (default: current engine)
  52523. * @param reusable If the post process can be reused on the same frame. (default: false)
  52524. * @param textureType Type of textures used when performing the post process. (default: 0)
  52525. * @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)
  52526. */
  52527. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52528. /** Weight of the bloom to be added to the original input. */
  52529. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52530. }
  52531. }
  52532. declare module "babylonjs/PostProcesses/bloomEffect" {
  52533. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52534. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52535. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52536. import { Camera } from "babylonjs/Cameras/camera";
  52537. import { Scene } from "babylonjs/scene";
  52538. /**
  52539. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52540. */
  52541. export class BloomEffect extends PostProcessRenderEffect {
  52542. private bloomScale;
  52543. /**
  52544. * @hidden Internal
  52545. */
  52546. _effects: Array<PostProcess>;
  52547. /**
  52548. * @hidden Internal
  52549. */
  52550. _downscale: ExtractHighlightsPostProcess;
  52551. private _blurX;
  52552. private _blurY;
  52553. private _merge;
  52554. /**
  52555. * The luminance threshold to find bright areas of the image to bloom.
  52556. */
  52557. threshold: number;
  52558. /**
  52559. * The strength of the bloom.
  52560. */
  52561. weight: number;
  52562. /**
  52563. * Specifies the size of the bloom blur kernel, relative to the final output size
  52564. */
  52565. kernel: number;
  52566. /**
  52567. * Creates a new instance of @see BloomEffect
  52568. * @param scene The scene the effect belongs to.
  52569. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52570. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52571. * @param bloomWeight The the strength of bloom.
  52572. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52573. * @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)
  52574. */
  52575. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52576. /**
  52577. * Disposes each of the internal effects for a given camera.
  52578. * @param camera The camera to dispose the effect on.
  52579. */
  52580. disposeEffects(camera: Camera): void;
  52581. /**
  52582. * @hidden Internal
  52583. */
  52584. _updateEffects(): void;
  52585. /**
  52586. * Internal
  52587. * @returns if all the contained post processes are ready.
  52588. * @hidden
  52589. */
  52590. _isReady(): boolean;
  52591. }
  52592. }
  52593. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52594. /** @hidden */
  52595. export var chromaticAberrationPixelShader: {
  52596. name: string;
  52597. shader: string;
  52598. };
  52599. }
  52600. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52601. import { Vector2 } from "babylonjs/Maths/math";
  52602. import { Nullable } from "babylonjs/types";
  52603. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52604. import { Camera } from "babylonjs/Cameras/camera";
  52605. import { Engine } from "babylonjs/Engines/engine";
  52606. import "babylonjs/Shaders/chromaticAberration.fragment";
  52607. /**
  52608. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52609. */
  52610. export class ChromaticAberrationPostProcess extends PostProcess {
  52611. /**
  52612. * The amount of seperation of rgb channels (default: 30)
  52613. */
  52614. aberrationAmount: number;
  52615. /**
  52616. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52617. */
  52618. radialIntensity: number;
  52619. /**
  52620. * 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))
  52621. */
  52622. direction: Vector2;
  52623. /**
  52624. * 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))
  52625. */
  52626. centerPosition: Vector2;
  52627. /**
  52628. * Creates a new instance ChromaticAberrationPostProcess
  52629. * @param name The name of the effect.
  52630. * @param screenWidth The width of the screen to apply the effect on.
  52631. * @param screenHeight The height of the screen to apply the effect on.
  52632. * @param options The required width/height ratio to downsize to before computing the render pass.
  52633. * @param camera The camera to apply the render pass to.
  52634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52635. * @param engine The engine which the post process will be applied. (default: current engine)
  52636. * @param reusable If the post process can be reused on the same frame. (default: false)
  52637. * @param textureType Type of textures used when performing the post process. (default: 0)
  52638. * @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)
  52639. */
  52640. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52641. }
  52642. }
  52643. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52644. /** @hidden */
  52645. export var circleOfConfusionPixelShader: {
  52646. name: string;
  52647. shader: string;
  52648. };
  52649. }
  52650. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52651. import { Nullable } from "babylonjs/types";
  52652. import { Engine } from "babylonjs/Engines/engine";
  52653. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52654. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52655. import { Camera } from "babylonjs/Cameras/camera";
  52656. import "babylonjs/Shaders/circleOfConfusion.fragment";
  52657. /**
  52658. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52659. */
  52660. export class CircleOfConfusionPostProcess extends PostProcess {
  52661. /**
  52662. * 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.
  52663. */
  52664. lensSize: number;
  52665. /**
  52666. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52667. */
  52668. fStop: number;
  52669. /**
  52670. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52671. */
  52672. focusDistance: number;
  52673. /**
  52674. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52675. */
  52676. focalLength: number;
  52677. private _depthTexture;
  52678. /**
  52679. * Creates a new instance CircleOfConfusionPostProcess
  52680. * @param name The name of the effect.
  52681. * @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.
  52682. * @param options The required width/height ratio to downsize to before computing the render pass.
  52683. * @param camera The camera to apply the render pass to.
  52684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52685. * @param engine The engine which the post process will be applied. (default: current engine)
  52686. * @param reusable If the post process can be reused on the same frame. (default: false)
  52687. * @param textureType Type of textures used when performing the post process. (default: 0)
  52688. * @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)
  52689. */
  52690. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52691. /**
  52692. * 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.
  52693. */
  52694. depthTexture: RenderTargetTexture;
  52695. }
  52696. }
  52697. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  52698. /** @hidden */
  52699. export var colorCorrectionPixelShader: {
  52700. name: string;
  52701. shader: string;
  52702. };
  52703. }
  52704. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  52705. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52706. import { Engine } from "babylonjs/Engines/engine";
  52707. import { Camera } from "babylonjs/Cameras/camera";
  52708. import "babylonjs/Shaders/colorCorrection.fragment";
  52709. /**
  52710. *
  52711. * This post-process allows the modification of rendered colors by using
  52712. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52713. *
  52714. * The object needs to be provided an url to a texture containing the color
  52715. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52716. * Use an image editing software to tweak the LUT to match your needs.
  52717. *
  52718. * For an example of a color LUT, see here:
  52719. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52720. * For explanations on color grading, see here:
  52721. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52722. *
  52723. */
  52724. export class ColorCorrectionPostProcess extends PostProcess {
  52725. private _colorTableTexture;
  52726. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52727. }
  52728. }
  52729. declare module "babylonjs/Shaders/convolution.fragment" {
  52730. /** @hidden */
  52731. export var convolutionPixelShader: {
  52732. name: string;
  52733. shader: string;
  52734. };
  52735. }
  52736. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  52737. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52738. import { Nullable } from "babylonjs/types";
  52739. import { Camera } from "babylonjs/Cameras/camera";
  52740. import { Engine } from "babylonjs/Engines/engine";
  52741. import "babylonjs/Shaders/convolution.fragment";
  52742. /**
  52743. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52744. * input texture to perform effects such as edge detection or sharpening
  52745. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52746. */
  52747. export class ConvolutionPostProcess extends PostProcess {
  52748. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52749. kernel: number[];
  52750. /**
  52751. * Creates a new instance ConvolutionPostProcess
  52752. * @param name The name of the effect.
  52753. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52754. * @param options The required width/height ratio to downsize to before computing the render pass.
  52755. * @param camera The camera to apply the render pass to.
  52756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52757. * @param engine The engine which the post process will be applied. (default: current engine)
  52758. * @param reusable If the post process can be reused on the same frame. (default: false)
  52759. * @param textureType Type of textures used when performing the post process. (default: 0)
  52760. */
  52761. constructor(name: string,
  52762. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52763. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52764. /**
  52765. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52766. */
  52767. static EdgeDetect0Kernel: number[];
  52768. /**
  52769. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52770. */
  52771. static EdgeDetect1Kernel: number[];
  52772. /**
  52773. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52774. */
  52775. static EdgeDetect2Kernel: number[];
  52776. /**
  52777. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52778. */
  52779. static SharpenKernel: number[];
  52780. /**
  52781. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52782. */
  52783. static EmbossKernel: number[];
  52784. /**
  52785. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52786. */
  52787. static GaussianKernel: number[];
  52788. }
  52789. }
  52790. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  52791. import { Nullable } from "babylonjs/types";
  52792. import { Vector2 } from "babylonjs/Maths/math";
  52793. import { Camera } from "babylonjs/Cameras/camera";
  52794. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52795. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  52796. import { Engine } from "babylonjs/Engines/engine";
  52797. import { Scene } from "babylonjs/scene";
  52798. /**
  52799. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52800. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52801. * based on samples that have a large difference in distance than the center pixel.
  52802. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52803. */
  52804. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52805. direction: Vector2;
  52806. /**
  52807. * Creates a new instance CircleOfConfusionPostProcess
  52808. * @param name The name of the effect.
  52809. * @param scene The scene the effect belongs to.
  52810. * @param direction The direction the blur should be applied.
  52811. * @param kernel The size of the kernel used to blur.
  52812. * @param options The required width/height ratio to downsize to before computing the render pass.
  52813. * @param camera The camera to apply the render pass to.
  52814. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52815. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52817. * @param engine The engine which the post process will be applied. (default: current engine)
  52818. * @param reusable If the post process can be reused on the same frame. (default: false)
  52819. * @param textureType Type of textures used when performing the post process. (default: 0)
  52820. * @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)
  52821. */
  52822. 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);
  52823. }
  52824. }
  52825. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  52826. /** @hidden */
  52827. export var depthOfFieldMergePixelShader: {
  52828. name: string;
  52829. shader: string;
  52830. };
  52831. }
  52832. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  52833. import { Nullable } from "babylonjs/types";
  52834. import { Camera } from "babylonjs/Cameras/camera";
  52835. import { Effect } from "babylonjs/Materials/effect";
  52836. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52837. import { Engine } from "babylonjs/Engines/engine";
  52838. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  52839. /**
  52840. * Options to be set when merging outputs from the default pipeline.
  52841. */
  52842. export class DepthOfFieldMergePostProcessOptions {
  52843. /**
  52844. * The original image to merge on top of
  52845. */
  52846. originalFromInput: PostProcess;
  52847. /**
  52848. * Parameters to perform the merge of the depth of field effect
  52849. */
  52850. depthOfField?: {
  52851. circleOfConfusion: PostProcess;
  52852. blurSteps: Array<PostProcess>;
  52853. };
  52854. /**
  52855. * Parameters to perform the merge of bloom effect
  52856. */
  52857. bloom?: {
  52858. blurred: PostProcess;
  52859. weight: number;
  52860. };
  52861. }
  52862. /**
  52863. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52864. */
  52865. export class DepthOfFieldMergePostProcess extends PostProcess {
  52866. private blurSteps;
  52867. /**
  52868. * Creates a new instance of DepthOfFieldMergePostProcess
  52869. * @param name The name of the effect.
  52870. * @param originalFromInput Post process which's input will be used for the merge.
  52871. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52872. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52873. * @param options The required width/height ratio to downsize to before computing the render pass.
  52874. * @param camera The camera to apply the render pass to.
  52875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52876. * @param engine The engine which the post process will be applied. (default: current engine)
  52877. * @param reusable If the post process can be reused on the same frame. (default: false)
  52878. * @param textureType Type of textures used when performing the post process. (default: 0)
  52879. * @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)
  52880. */
  52881. 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);
  52882. /**
  52883. * Updates the effect with the current post process compile time values and recompiles the shader.
  52884. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52885. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52886. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52887. * @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
  52888. * @param onCompiled Called when the shader has been compiled.
  52889. * @param onError Called if there is an error when compiling a shader.
  52890. */
  52891. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52892. }
  52893. }
  52894. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  52895. import { Nullable } from "babylonjs/types";
  52896. import { Camera } from "babylonjs/Cameras/camera";
  52897. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52898. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52899. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52900. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  52901. import { Scene } from "babylonjs/scene";
  52902. /**
  52903. * Specifies the level of max blur that should be applied when using the depth of field effect
  52904. */
  52905. export enum DepthOfFieldEffectBlurLevel {
  52906. /**
  52907. * Subtle blur
  52908. */
  52909. Low = 0,
  52910. /**
  52911. * Medium blur
  52912. */
  52913. Medium = 1,
  52914. /**
  52915. * Large blur
  52916. */
  52917. High = 2
  52918. }
  52919. /**
  52920. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52921. */
  52922. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52923. private _circleOfConfusion;
  52924. /**
  52925. * @hidden Internal, blurs from high to low
  52926. */
  52927. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52928. private _depthOfFieldBlurY;
  52929. private _dofMerge;
  52930. /**
  52931. * @hidden Internal post processes in depth of field effect
  52932. */
  52933. _effects: Array<PostProcess>;
  52934. /**
  52935. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52936. */
  52937. focalLength: number;
  52938. /**
  52939. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52940. */
  52941. fStop: number;
  52942. /**
  52943. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52944. */
  52945. focusDistance: number;
  52946. /**
  52947. * 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.
  52948. */
  52949. lensSize: number;
  52950. /**
  52951. * Creates a new instance DepthOfFieldEffect
  52952. * @param scene The scene the effect belongs to.
  52953. * @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.
  52954. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52955. * @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)
  52956. */
  52957. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52958. /**
  52959. * 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.
  52960. */
  52961. depthTexture: RenderTargetTexture;
  52962. /**
  52963. * Disposes each of the internal effects for a given camera.
  52964. * @param camera The camera to dispose the effect on.
  52965. */
  52966. disposeEffects(camera: Camera): void;
  52967. /**
  52968. * @hidden Internal
  52969. */
  52970. _updateEffects(): void;
  52971. /**
  52972. * Internal
  52973. * @returns if all the contained post processes are ready.
  52974. * @hidden
  52975. */
  52976. _isReady(): boolean;
  52977. }
  52978. }
  52979. declare module "babylonjs/Shaders/displayPass.fragment" {
  52980. /** @hidden */
  52981. export var displayPassPixelShader: {
  52982. name: string;
  52983. shader: string;
  52984. };
  52985. }
  52986. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  52987. import { Nullable } from "babylonjs/types";
  52988. import { Camera } from "babylonjs/Cameras/camera";
  52989. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52990. import { Engine } from "babylonjs/Engines/engine";
  52991. import "babylonjs/Shaders/displayPass.fragment";
  52992. /**
  52993. * DisplayPassPostProcess which produces an output the same as it's input
  52994. */
  52995. export class DisplayPassPostProcess extends PostProcess {
  52996. /**
  52997. * Creates the DisplayPassPostProcess
  52998. * @param name The name of the effect.
  52999. * @param options The required width/height ratio to downsize to before computing the render pass.
  53000. * @param camera The camera to apply the render pass to.
  53001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53002. * @param engine The engine which the post process will be applied. (default: current engine)
  53003. * @param reusable If the post process can be reused on the same frame. (default: false)
  53004. */
  53005. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53006. }
  53007. }
  53008. declare module "babylonjs/Shaders/filter.fragment" {
  53009. /** @hidden */
  53010. export var filterPixelShader: {
  53011. name: string;
  53012. shader: string;
  53013. };
  53014. }
  53015. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53016. import { Nullable } from "babylonjs/types";
  53017. import { Matrix } from "babylonjs/Maths/math";
  53018. import { Camera } from "babylonjs/Cameras/camera";
  53019. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53020. import { Engine } from "babylonjs/Engines/engine";
  53021. import "babylonjs/Shaders/filter.fragment";
  53022. /**
  53023. * Applies a kernel filter to the image
  53024. */
  53025. export class FilterPostProcess extends PostProcess {
  53026. /** The matrix to be applied to the image */
  53027. kernelMatrix: Matrix;
  53028. /**
  53029. *
  53030. * @param name The name of the effect.
  53031. * @param kernelMatrix The matrix to be applied to the image
  53032. * @param options The required width/height ratio to downsize to before computing the render pass.
  53033. * @param camera The camera to apply the render pass to.
  53034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53035. * @param engine The engine which the post process will be applied. (default: current engine)
  53036. * @param reusable If the post process can be reused on the same frame. (default: false)
  53037. */
  53038. constructor(name: string,
  53039. /** The matrix to be applied to the image */
  53040. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53041. }
  53042. }
  53043. declare module "babylonjs/Shaders/fxaa.fragment" {
  53044. /** @hidden */
  53045. export var fxaaPixelShader: {
  53046. name: string;
  53047. shader: string;
  53048. };
  53049. }
  53050. declare module "babylonjs/Shaders/fxaa.vertex" {
  53051. /** @hidden */
  53052. export var fxaaVertexShader: {
  53053. name: string;
  53054. shader: string;
  53055. };
  53056. }
  53057. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53058. import { Nullable } from "babylonjs/types";
  53059. import { Camera } from "babylonjs/Cameras/camera";
  53060. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53061. import { Engine } from "babylonjs/Engines/engine";
  53062. import "babylonjs/Shaders/fxaa.fragment";
  53063. import "babylonjs/Shaders/fxaa.vertex";
  53064. /**
  53065. * Fxaa post process
  53066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53067. */
  53068. export class FxaaPostProcess extends PostProcess {
  53069. /** @hidden */
  53070. texelWidth: number;
  53071. /** @hidden */
  53072. texelHeight: number;
  53073. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53074. private _getDefines;
  53075. }
  53076. }
  53077. declare module "babylonjs/Shaders/grain.fragment" {
  53078. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53079. /** @hidden */
  53080. export var grainPixelShader: {
  53081. name: string;
  53082. shader: string;
  53083. };
  53084. }
  53085. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53086. import { Nullable } from "babylonjs/types";
  53087. import { Camera } from "babylonjs/Cameras/camera";
  53088. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53089. import { Engine } from "babylonjs/Engines/engine";
  53090. import "babylonjs/Shaders/grain.fragment";
  53091. /**
  53092. * The GrainPostProcess adds noise to the image at mid luminance levels
  53093. */
  53094. export class GrainPostProcess extends PostProcess {
  53095. /**
  53096. * The intensity of the grain added (default: 30)
  53097. */
  53098. intensity: number;
  53099. /**
  53100. * If the grain should be randomized on every frame
  53101. */
  53102. animated: boolean;
  53103. /**
  53104. * Creates a new instance of @see GrainPostProcess
  53105. * @param name The name of the effect.
  53106. * @param options The required width/height ratio to downsize to before computing the render pass.
  53107. * @param camera The camera to apply the render pass to.
  53108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53109. * @param engine The engine which the post process will be applied. (default: current engine)
  53110. * @param reusable If the post process can be reused on the same frame. (default: false)
  53111. * @param textureType Type of textures used when performing the post process. (default: 0)
  53112. * @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)
  53113. */
  53114. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53115. }
  53116. }
  53117. declare module "babylonjs/Shaders/highlights.fragment" {
  53118. /** @hidden */
  53119. export var highlightsPixelShader: {
  53120. name: string;
  53121. shader: string;
  53122. };
  53123. }
  53124. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53125. import { Nullable } from "babylonjs/types";
  53126. import { Camera } from "babylonjs/Cameras/camera";
  53127. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53128. import { Engine } from "babylonjs/Engines/engine";
  53129. import "babylonjs/Shaders/highlights.fragment";
  53130. /**
  53131. * Extracts highlights from the image
  53132. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53133. */
  53134. export class HighlightsPostProcess extends PostProcess {
  53135. /**
  53136. * Extracts highlights from the image
  53137. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53138. * @param name The name of the effect.
  53139. * @param options The required width/height ratio to downsize to before computing the render pass.
  53140. * @param camera The camera to apply the render pass to.
  53141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53142. * @param engine The engine which the post process will be applied. (default: current engine)
  53143. * @param reusable If the post process can be reused on the same frame. (default: false)
  53144. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53145. */
  53146. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53147. }
  53148. }
  53149. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53150. /** @hidden */
  53151. export var mrtFragmentDeclaration: {
  53152. name: string;
  53153. shader: string;
  53154. };
  53155. }
  53156. declare module "babylonjs/Shaders/geometry.fragment" {
  53157. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53158. /** @hidden */
  53159. export var geometryPixelShader: {
  53160. name: string;
  53161. shader: string;
  53162. };
  53163. }
  53164. declare module "babylonjs/Shaders/geometry.vertex" {
  53165. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53166. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53167. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53168. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53169. /** @hidden */
  53170. export var geometryVertexShader: {
  53171. name: string;
  53172. shader: string;
  53173. };
  53174. }
  53175. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53176. import { Matrix } from "babylonjs/Maths/math";
  53177. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53178. import { Mesh } from "babylonjs/Meshes/mesh";
  53179. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53180. import { Effect } from "babylonjs/Materials/effect";
  53181. import { Scene } from "babylonjs/scene";
  53182. import "babylonjs/Shaders/geometry.fragment";
  53183. import "babylonjs/Shaders/geometry.vertex";
  53184. /**
  53185. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53186. */
  53187. export class GeometryBufferRenderer {
  53188. /**
  53189. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53190. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53191. */
  53192. static readonly POSITION_TEXTURE_TYPE: number;
  53193. /**
  53194. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53195. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53196. */
  53197. static readonly VELOCITY_TEXTURE_TYPE: number;
  53198. /**
  53199. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53200. * in order to compute objects velocities when enableVelocity is set to "true"
  53201. * @hidden
  53202. */
  53203. _previousTransformationMatrices: {
  53204. [index: number]: Matrix;
  53205. };
  53206. private _scene;
  53207. private _multiRenderTarget;
  53208. private _ratio;
  53209. private _enablePosition;
  53210. private _enableVelocity;
  53211. private _positionIndex;
  53212. private _velocityIndex;
  53213. protected _effect: Effect;
  53214. protected _cachedDefines: string;
  53215. /**
  53216. * Set the render list (meshes to be rendered) used in the G buffer.
  53217. */
  53218. renderList: Mesh[];
  53219. /**
  53220. * Gets wether or not G buffer are supported by the running hardware.
  53221. * This requires draw buffer supports
  53222. */
  53223. readonly isSupported: boolean;
  53224. /**
  53225. * Returns the index of the given texture type in the G-Buffer textures array
  53226. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53227. * @returns the index of the given texture type in the G-Buffer textures array
  53228. */
  53229. getTextureIndex(textureType: number): number;
  53230. /**
  53231. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53232. */
  53233. /**
  53234. * Sets whether or not objects positions are enabled for the G buffer.
  53235. */
  53236. enablePosition: boolean;
  53237. /**
  53238. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53239. */
  53240. /**
  53241. * Sets wether or not objects velocities are enabled for the G buffer.
  53242. */
  53243. enableVelocity: boolean;
  53244. /**
  53245. * Gets the scene associated with the buffer.
  53246. */
  53247. readonly scene: Scene;
  53248. /**
  53249. * Gets the ratio used by the buffer during its creation.
  53250. * How big is the buffer related to the main canvas.
  53251. */
  53252. readonly ratio: number;
  53253. /** @hidden */
  53254. static _SceneComponentInitialization: (scene: Scene) => void;
  53255. /**
  53256. * Creates a new G Buffer for the scene
  53257. * @param scene The scene the buffer belongs to
  53258. * @param ratio How big is the buffer related to the main canvas.
  53259. */
  53260. constructor(scene: Scene, ratio?: number);
  53261. /**
  53262. * Checks wether everything is ready to render a submesh to the G buffer.
  53263. * @param subMesh the submesh to check readiness for
  53264. * @param useInstances is the mesh drawn using instance or not
  53265. * @returns true if ready otherwise false
  53266. */
  53267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53268. /**
  53269. * Gets the current underlying G Buffer.
  53270. * @returns the buffer
  53271. */
  53272. getGBuffer(): MultiRenderTarget;
  53273. /**
  53274. * Gets the number of samples used to render the buffer (anti aliasing).
  53275. */
  53276. /**
  53277. * Sets the number of samples used to render the buffer (anti aliasing).
  53278. */
  53279. samples: number;
  53280. /**
  53281. * Disposes the renderer and frees up associated resources.
  53282. */
  53283. dispose(): void;
  53284. protected _createRenderTargets(): void;
  53285. }
  53286. }
  53287. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53288. /** @hidden */
  53289. export var motionBlurPixelShader: {
  53290. name: string;
  53291. shader: string;
  53292. };
  53293. }
  53294. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53295. import { Nullable } from "babylonjs/types";
  53296. import { Camera } from "babylonjs/Cameras/camera";
  53297. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53298. import { Scene } from "babylonjs/scene";
  53299. import "babylonjs/Shaders/motionBlur.fragment";
  53300. import { Engine } from "babylonjs/Engines/engine";
  53301. /**
  53302. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53303. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53304. * As an example, all you have to do is to create the post-process:
  53305. * var mb = new BABYLON.MotionBlurPostProcess(
  53306. * 'mb', // The name of the effect.
  53307. * scene, // The scene containing the objects to blur according to their velocity.
  53308. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53309. * camera // The camera to apply the render pass to.
  53310. * );
  53311. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53312. */
  53313. export class MotionBlurPostProcess extends PostProcess {
  53314. /**
  53315. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53316. */
  53317. motionStrength: number;
  53318. /**
  53319. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53320. */
  53321. /**
  53322. * Sets the number of iterations to be used for motion blur quality
  53323. */
  53324. motionBlurSamples: number;
  53325. private _motionBlurSamples;
  53326. private _geometryBufferRenderer;
  53327. /**
  53328. * Creates a new instance MotionBlurPostProcess
  53329. * @param name The name of the effect.
  53330. * @param scene The scene containing the objects to blur according to their velocity.
  53331. * @param options The required width/height ratio to downsize to before computing the render pass.
  53332. * @param camera The camera to apply the render pass to.
  53333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53334. * @param engine The engine which the post process will be applied. (default: current engine)
  53335. * @param reusable If the post process can be reused on the same frame. (default: false)
  53336. * @param textureType Type of textures used when performing the post process. (default: 0)
  53337. * @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)
  53338. */
  53339. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53340. /**
  53341. * Disposes the post process.
  53342. * @param camera The camera to dispose the post process on.
  53343. */
  53344. dispose(camera?: Camera): void;
  53345. }
  53346. }
  53347. declare module "babylonjs/Shaders/refraction.fragment" {
  53348. /** @hidden */
  53349. export var refractionPixelShader: {
  53350. name: string;
  53351. shader: string;
  53352. };
  53353. }
  53354. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53355. import { Color3 } from "babylonjs/Maths/math";
  53356. import { Camera } from "babylonjs/Cameras/camera";
  53357. import { Texture } from "babylonjs/Materials/Textures/texture";
  53358. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53359. import { Engine } from "babylonjs/Engines/engine";
  53360. import "babylonjs/Shaders/refraction.fragment";
  53361. /**
  53362. * Post process which applies a refractin texture
  53363. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53364. */
  53365. export class RefractionPostProcess extends PostProcess {
  53366. /** the base color of the refraction (used to taint the rendering) */
  53367. color: Color3;
  53368. /** simulated refraction depth */
  53369. depth: number;
  53370. /** the coefficient of the base color (0 to remove base color tainting) */
  53371. colorLevel: number;
  53372. private _refTexture;
  53373. private _ownRefractionTexture;
  53374. /**
  53375. * Gets or sets the refraction texture
  53376. * Please note that you are responsible for disposing the texture if you set it manually
  53377. */
  53378. refractionTexture: Texture;
  53379. /**
  53380. * Initializes the RefractionPostProcess
  53381. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53382. * @param name The name of the effect.
  53383. * @param refractionTextureUrl Url of the refraction texture to use
  53384. * @param color the base color of the refraction (used to taint the rendering)
  53385. * @param depth simulated refraction depth
  53386. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53387. * @param camera The camera to apply the render pass to.
  53388. * @param options The required width/height ratio to downsize to before computing the render pass.
  53389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53390. * @param engine The engine which the post process will be applied. (default: current engine)
  53391. * @param reusable If the post process can be reused on the same frame. (default: false)
  53392. */
  53393. constructor(name: string, refractionTextureUrl: string,
  53394. /** the base color of the refraction (used to taint the rendering) */
  53395. color: Color3,
  53396. /** simulated refraction depth */
  53397. depth: number,
  53398. /** the coefficient of the base color (0 to remove base color tainting) */
  53399. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53400. /**
  53401. * Disposes of the post process
  53402. * @param camera Camera to dispose post process on
  53403. */
  53404. dispose(camera: Camera): void;
  53405. }
  53406. }
  53407. declare module "babylonjs/Shaders/sharpen.fragment" {
  53408. /** @hidden */
  53409. export var sharpenPixelShader: {
  53410. name: string;
  53411. shader: string;
  53412. };
  53413. }
  53414. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53415. import { Nullable } from "babylonjs/types";
  53416. import { Camera } from "babylonjs/Cameras/camera";
  53417. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53418. import "babylonjs/Shaders/sharpen.fragment";
  53419. import { Engine } from "babylonjs/Engines/engine";
  53420. /**
  53421. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53422. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53423. */
  53424. export class SharpenPostProcess extends PostProcess {
  53425. /**
  53426. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53427. */
  53428. colorAmount: number;
  53429. /**
  53430. * How much sharpness should be applied (default: 0.3)
  53431. */
  53432. edgeAmount: number;
  53433. /**
  53434. * Creates a new instance ConvolutionPostProcess
  53435. * @param name The name of the effect.
  53436. * @param options The required width/height ratio to downsize to before computing the render pass.
  53437. * @param camera The camera to apply the render pass to.
  53438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53439. * @param engine The engine which the post process will be applied. (default: current engine)
  53440. * @param reusable If the post process can be reused on the same frame. (default: false)
  53441. * @param textureType Type of textures used when performing the post process. (default: 0)
  53442. * @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)
  53443. */
  53444. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53445. }
  53446. }
  53447. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53448. import { Nullable } from "babylonjs/types";
  53449. import { Camera } from "babylonjs/Cameras/camera";
  53450. import { Engine } from "babylonjs/Engines/engine";
  53451. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53452. /**
  53453. * PostProcessRenderPipeline
  53454. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53455. */
  53456. export class PostProcessRenderPipeline {
  53457. private engine;
  53458. private _renderEffects;
  53459. private _renderEffectsForIsolatedPass;
  53460. /**
  53461. * @hidden
  53462. */
  53463. protected _cameras: Camera[];
  53464. /** @hidden */
  53465. _name: string;
  53466. /**
  53467. * Gets pipeline name
  53468. */
  53469. readonly name: string;
  53470. /**
  53471. * Initializes a PostProcessRenderPipeline
  53472. * @param engine engine to add the pipeline to
  53473. * @param name name of the pipeline
  53474. */
  53475. constructor(engine: Engine, name: string);
  53476. /**
  53477. * Gets the class name
  53478. * @returns "PostProcessRenderPipeline"
  53479. */
  53480. getClassName(): string;
  53481. /**
  53482. * If all the render effects in the pipeline are supported
  53483. */
  53484. readonly isSupported: boolean;
  53485. /**
  53486. * Adds an effect to the pipeline
  53487. * @param renderEffect the effect to add
  53488. */
  53489. addEffect(renderEffect: PostProcessRenderEffect): void;
  53490. /** @hidden */
  53491. _rebuild(): void;
  53492. /** @hidden */
  53493. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53494. /** @hidden */
  53495. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53496. /** @hidden */
  53497. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53498. /** @hidden */
  53499. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53500. /** @hidden */
  53501. _attachCameras(cameras: Camera, unique: boolean): void;
  53502. /** @hidden */
  53503. _attachCameras(cameras: Camera[], unique: boolean): void;
  53504. /** @hidden */
  53505. _detachCameras(cameras: Camera): void;
  53506. /** @hidden */
  53507. _detachCameras(cameras: Nullable<Camera[]>): void;
  53508. /** @hidden */
  53509. _update(): void;
  53510. /** @hidden */
  53511. _reset(): void;
  53512. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53513. /**
  53514. * Disposes of the pipeline
  53515. */
  53516. dispose(): void;
  53517. }
  53518. }
  53519. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  53520. import { IAnimatable } from "babylonjs/Misc/tools";
  53521. import { Camera } from "babylonjs/Cameras/camera";
  53522. import { IDisposable } from "babylonjs/scene";
  53523. import { Scene } from "babylonjs/scene";
  53524. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  53525. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53526. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53527. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  53528. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53529. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53530. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  53531. import { Animation } from "babylonjs/Animations/animation";
  53532. /**
  53533. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53534. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53535. */
  53536. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53537. private _scene;
  53538. private _camerasToBeAttached;
  53539. /**
  53540. * ID of the sharpen post process,
  53541. */
  53542. private readonly SharpenPostProcessId;
  53543. /**
  53544. * @ignore
  53545. * ID of the image processing post process;
  53546. */
  53547. readonly ImageProcessingPostProcessId: string;
  53548. /**
  53549. * @ignore
  53550. * ID of the Fast Approximate Anti-Aliasing post process;
  53551. */
  53552. readonly FxaaPostProcessId: string;
  53553. /**
  53554. * ID of the chromatic aberration post process,
  53555. */
  53556. private readonly ChromaticAberrationPostProcessId;
  53557. /**
  53558. * ID of the grain post process
  53559. */
  53560. private readonly GrainPostProcessId;
  53561. /**
  53562. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53563. */
  53564. sharpen: SharpenPostProcess;
  53565. private _sharpenEffect;
  53566. private bloom;
  53567. /**
  53568. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53569. */
  53570. depthOfField: DepthOfFieldEffect;
  53571. /**
  53572. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53573. */
  53574. fxaa: FxaaPostProcess;
  53575. /**
  53576. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53577. */
  53578. imageProcessing: ImageProcessingPostProcess;
  53579. /**
  53580. * Chromatic aberration post process which will shift rgb colors in the image
  53581. */
  53582. chromaticAberration: ChromaticAberrationPostProcess;
  53583. private _chromaticAberrationEffect;
  53584. /**
  53585. * Grain post process which add noise to the image
  53586. */
  53587. grain: GrainPostProcess;
  53588. private _grainEffect;
  53589. /**
  53590. * Glow post process which adds a glow to emissive areas of the image
  53591. */
  53592. private _glowLayer;
  53593. /**
  53594. * Animations which can be used to tweak settings over a period of time
  53595. */
  53596. animations: Animation[];
  53597. private _imageProcessingConfigurationObserver;
  53598. private _sharpenEnabled;
  53599. private _bloomEnabled;
  53600. private _depthOfFieldEnabled;
  53601. private _depthOfFieldBlurLevel;
  53602. private _fxaaEnabled;
  53603. private _imageProcessingEnabled;
  53604. private _defaultPipelineTextureType;
  53605. private _bloomScale;
  53606. private _chromaticAberrationEnabled;
  53607. private _grainEnabled;
  53608. private _buildAllowed;
  53609. /**
  53610. * Gets active scene
  53611. */
  53612. readonly scene: Scene;
  53613. /**
  53614. * Enable or disable the sharpen process from the pipeline
  53615. */
  53616. sharpenEnabled: boolean;
  53617. private _resizeObserver;
  53618. private _hardwareScaleLevel;
  53619. private _bloomKernel;
  53620. /**
  53621. * Specifies the size of the bloom blur kernel, relative to the final output size
  53622. */
  53623. bloomKernel: number;
  53624. /**
  53625. * Specifies the weight of the bloom in the final rendering
  53626. */
  53627. private _bloomWeight;
  53628. /**
  53629. * Specifies the luma threshold for the area that will be blurred by the bloom
  53630. */
  53631. private _bloomThreshold;
  53632. private _hdr;
  53633. /**
  53634. * The strength of the bloom.
  53635. */
  53636. bloomWeight: number;
  53637. /**
  53638. * The strength of the bloom.
  53639. */
  53640. bloomThreshold: number;
  53641. /**
  53642. * The scale of the bloom, lower value will provide better performance.
  53643. */
  53644. bloomScale: number;
  53645. /**
  53646. * Enable or disable the bloom from the pipeline
  53647. */
  53648. bloomEnabled: boolean;
  53649. private _rebuildBloom;
  53650. /**
  53651. * If the depth of field is enabled.
  53652. */
  53653. depthOfFieldEnabled: boolean;
  53654. /**
  53655. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53656. */
  53657. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53658. /**
  53659. * If the anti aliasing is enabled.
  53660. */
  53661. fxaaEnabled: boolean;
  53662. private _samples;
  53663. /**
  53664. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53665. */
  53666. samples: number;
  53667. /**
  53668. * If image processing is enabled.
  53669. */
  53670. imageProcessingEnabled: boolean;
  53671. /**
  53672. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53673. */
  53674. glowLayerEnabled: boolean;
  53675. /**
  53676. * Enable or disable the chromaticAberration process from the pipeline
  53677. */
  53678. chromaticAberrationEnabled: boolean;
  53679. /**
  53680. * Enable or disable the grain process from the pipeline
  53681. */
  53682. grainEnabled: boolean;
  53683. /**
  53684. * @constructor
  53685. * @param name - The rendering pipeline name (default: "")
  53686. * @param hdr - If high dynamic range textures should be used (default: true)
  53687. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53688. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53689. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53690. */
  53691. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53692. /**
  53693. * Get the class name
  53694. * @returns "DefaultRenderingPipeline"
  53695. */
  53696. getClassName(): string;
  53697. /**
  53698. * Force the compilation of the entire pipeline.
  53699. */
  53700. prepare(): void;
  53701. private _hasCleared;
  53702. private _prevPostProcess;
  53703. private _prevPrevPostProcess;
  53704. private _setAutoClearAndTextureSharing;
  53705. private _depthOfFieldSceneObserver;
  53706. private _buildPipeline;
  53707. private _disposePostProcesses;
  53708. /**
  53709. * Adds a camera to the pipeline
  53710. * @param camera the camera to be added
  53711. */
  53712. addCamera(camera: Camera): void;
  53713. /**
  53714. * Removes a camera from the pipeline
  53715. * @param camera the camera to remove
  53716. */
  53717. removeCamera(camera: Camera): void;
  53718. /**
  53719. * Dispose of the pipeline and stop all post processes
  53720. */
  53721. dispose(): void;
  53722. /**
  53723. * Serialize the rendering pipeline (Used when exporting)
  53724. * @returns the serialized object
  53725. */
  53726. serialize(): any;
  53727. /**
  53728. * Parse the serialized pipeline
  53729. * @param source Source pipeline.
  53730. * @param scene The scene to load the pipeline to.
  53731. * @param rootUrl The URL of the serialized pipeline.
  53732. * @returns An instantiated pipeline from the serialized object.
  53733. */
  53734. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53735. }
  53736. }
  53737. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  53738. /** @hidden */
  53739. export var lensHighlightsPixelShader: {
  53740. name: string;
  53741. shader: string;
  53742. };
  53743. }
  53744. declare module "babylonjs/Shaders/depthOfField.fragment" {
  53745. /** @hidden */
  53746. export var depthOfFieldPixelShader: {
  53747. name: string;
  53748. shader: string;
  53749. };
  53750. }
  53751. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  53752. import { Camera } from "babylonjs/Cameras/camera";
  53753. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53754. import { Scene } from "babylonjs/scene";
  53755. import "babylonjs/Shaders/chromaticAberration.fragment";
  53756. import "babylonjs/Shaders/lensHighlights.fragment";
  53757. import "babylonjs/Shaders/depthOfField.fragment";
  53758. /**
  53759. * BABYLON.JS Chromatic Aberration GLSL Shader
  53760. * Author: Olivier Guyot
  53761. * Separates very slightly R, G and B colors on the edges of the screen
  53762. * Inspired by Francois Tarlier & Martins Upitis
  53763. */
  53764. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53765. /**
  53766. * @ignore
  53767. * The chromatic aberration PostProcess id in the pipeline
  53768. */
  53769. LensChromaticAberrationEffect: string;
  53770. /**
  53771. * @ignore
  53772. * The highlights enhancing PostProcess id in the pipeline
  53773. */
  53774. HighlightsEnhancingEffect: string;
  53775. /**
  53776. * @ignore
  53777. * The depth-of-field PostProcess id in the pipeline
  53778. */
  53779. LensDepthOfFieldEffect: string;
  53780. private _scene;
  53781. private _depthTexture;
  53782. private _grainTexture;
  53783. private _chromaticAberrationPostProcess;
  53784. private _highlightsPostProcess;
  53785. private _depthOfFieldPostProcess;
  53786. private _edgeBlur;
  53787. private _grainAmount;
  53788. private _chromaticAberration;
  53789. private _distortion;
  53790. private _highlightsGain;
  53791. private _highlightsThreshold;
  53792. private _dofDistance;
  53793. private _dofAperture;
  53794. private _dofDarken;
  53795. private _dofPentagon;
  53796. private _blurNoise;
  53797. /**
  53798. * @constructor
  53799. *
  53800. * Effect parameters are as follow:
  53801. * {
  53802. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53803. * edge_blur: number; // from 0 to x (1 for realism)
  53804. * distortion: number; // from 0 to x (1 for realism)
  53805. * grain_amount: number; // from 0 to 1
  53806. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53807. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53808. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53809. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53810. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53811. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53812. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53813. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53814. * }
  53815. * Note: if an effect parameter is unset, effect is disabled
  53816. *
  53817. * @param name The rendering pipeline name
  53818. * @param parameters - An object containing all parameters (see above)
  53819. * @param scene The scene linked to this pipeline
  53820. * @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)
  53821. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53822. */
  53823. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53824. /**
  53825. * Sets the amount of blur at the edges
  53826. * @param amount blur amount
  53827. */
  53828. setEdgeBlur(amount: number): void;
  53829. /**
  53830. * Sets edge blur to 0
  53831. */
  53832. disableEdgeBlur(): void;
  53833. /**
  53834. * Sets the amout of grain
  53835. * @param amount Amount of grain
  53836. */
  53837. setGrainAmount(amount: number): void;
  53838. /**
  53839. * Set grain amount to 0
  53840. */
  53841. disableGrain(): void;
  53842. /**
  53843. * Sets the chromatic aberration amount
  53844. * @param amount amount of chromatic aberration
  53845. */
  53846. setChromaticAberration(amount: number): void;
  53847. /**
  53848. * Sets chromatic aberration amount to 0
  53849. */
  53850. disableChromaticAberration(): void;
  53851. /**
  53852. * Sets the EdgeDistortion amount
  53853. * @param amount amount of EdgeDistortion
  53854. */
  53855. setEdgeDistortion(amount: number): void;
  53856. /**
  53857. * Sets edge distortion to 0
  53858. */
  53859. disableEdgeDistortion(): void;
  53860. /**
  53861. * Sets the FocusDistance amount
  53862. * @param amount amount of FocusDistance
  53863. */
  53864. setFocusDistance(amount: number): void;
  53865. /**
  53866. * Disables depth of field
  53867. */
  53868. disableDepthOfField(): void;
  53869. /**
  53870. * Sets the Aperture amount
  53871. * @param amount amount of Aperture
  53872. */
  53873. setAperture(amount: number): void;
  53874. /**
  53875. * Sets the DarkenOutOfFocus amount
  53876. * @param amount amount of DarkenOutOfFocus
  53877. */
  53878. setDarkenOutOfFocus(amount: number): void;
  53879. /**
  53880. * Creates a pentagon bokeh effect
  53881. */
  53882. enablePentagonBokeh(): void;
  53883. /**
  53884. * Disables the pentagon bokeh effect
  53885. */
  53886. disablePentagonBokeh(): void;
  53887. /**
  53888. * Enables noise blur
  53889. */
  53890. enableNoiseBlur(): void;
  53891. /**
  53892. * Disables noise blur
  53893. */
  53894. disableNoiseBlur(): void;
  53895. /**
  53896. * Sets the HighlightsGain amount
  53897. * @param amount amount of HighlightsGain
  53898. */
  53899. setHighlightsGain(amount: number): void;
  53900. /**
  53901. * Sets the HighlightsThreshold amount
  53902. * @param amount amount of HighlightsThreshold
  53903. */
  53904. setHighlightsThreshold(amount: number): void;
  53905. /**
  53906. * Disables highlights
  53907. */
  53908. disableHighlights(): void;
  53909. /**
  53910. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53911. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53912. */
  53913. dispose(disableDepthRender?: boolean): void;
  53914. private _createChromaticAberrationPostProcess;
  53915. private _createHighlightsPostProcess;
  53916. private _createDepthOfFieldPostProcess;
  53917. private _createGrainTexture;
  53918. }
  53919. }
  53920. declare module "babylonjs/Shaders/ssao2.fragment" {
  53921. /** @hidden */
  53922. export var ssao2PixelShader: {
  53923. name: string;
  53924. shader: string;
  53925. };
  53926. }
  53927. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  53928. /** @hidden */
  53929. export var ssaoCombinePixelShader: {
  53930. name: string;
  53931. shader: string;
  53932. };
  53933. }
  53934. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  53935. import { Camera } from "babylonjs/Cameras/camera";
  53936. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53937. import { Scene } from "babylonjs/scene";
  53938. import "babylonjs/Shaders/ssao2.fragment";
  53939. import "babylonjs/Shaders/ssaoCombine.fragment";
  53940. /**
  53941. * Render pipeline to produce ssao effect
  53942. */
  53943. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53944. /**
  53945. * @ignore
  53946. * The PassPostProcess id in the pipeline that contains the original scene color
  53947. */
  53948. SSAOOriginalSceneColorEffect: string;
  53949. /**
  53950. * @ignore
  53951. * The SSAO PostProcess id in the pipeline
  53952. */
  53953. SSAORenderEffect: string;
  53954. /**
  53955. * @ignore
  53956. * The horizontal blur PostProcess id in the pipeline
  53957. */
  53958. SSAOBlurHRenderEffect: string;
  53959. /**
  53960. * @ignore
  53961. * The vertical blur PostProcess id in the pipeline
  53962. */
  53963. SSAOBlurVRenderEffect: string;
  53964. /**
  53965. * @ignore
  53966. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53967. */
  53968. SSAOCombineRenderEffect: string;
  53969. /**
  53970. * The output strength of the SSAO post-process. Default value is 1.0.
  53971. */
  53972. totalStrength: number;
  53973. /**
  53974. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53975. */
  53976. maxZ: number;
  53977. /**
  53978. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53979. */
  53980. minZAspect: number;
  53981. private _samples;
  53982. /**
  53983. * Number of samples used for the SSAO calculations. Default value is 8
  53984. */
  53985. samples: number;
  53986. private _textureSamples;
  53987. /**
  53988. * Number of samples to use for antialiasing
  53989. */
  53990. textureSamples: number;
  53991. /**
  53992. * Ratio object used for SSAO ratio and blur ratio
  53993. */
  53994. private _ratio;
  53995. /**
  53996. * Dynamically generated sphere sampler.
  53997. */
  53998. private _sampleSphere;
  53999. /**
  54000. * Blur filter offsets
  54001. */
  54002. private _samplerOffsets;
  54003. private _expensiveBlur;
  54004. /**
  54005. * If bilateral blur should be used
  54006. */
  54007. expensiveBlur: boolean;
  54008. /**
  54009. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54010. */
  54011. radius: number;
  54012. /**
  54013. * The base color of the SSAO post-process
  54014. * The final result is "base + ssao" between [0, 1]
  54015. */
  54016. base: number;
  54017. /**
  54018. * Support test.
  54019. */
  54020. static readonly IsSupported: boolean;
  54021. private _scene;
  54022. private _depthTexture;
  54023. private _normalTexture;
  54024. private _randomTexture;
  54025. private _originalColorPostProcess;
  54026. private _ssaoPostProcess;
  54027. private _blurHPostProcess;
  54028. private _blurVPostProcess;
  54029. private _ssaoCombinePostProcess;
  54030. private _firstUpdate;
  54031. /**
  54032. * Gets active scene
  54033. */
  54034. readonly scene: Scene;
  54035. /**
  54036. * @constructor
  54037. * @param name The rendering pipeline name
  54038. * @param scene The scene linked to this pipeline
  54039. * @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 }
  54040. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54041. */
  54042. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54043. /**
  54044. * Get the class name
  54045. * @returns "SSAO2RenderingPipeline"
  54046. */
  54047. getClassName(): string;
  54048. /**
  54049. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54050. */
  54051. dispose(disableGeometryBufferRenderer?: boolean): void;
  54052. private _createBlurPostProcess;
  54053. /** @hidden */
  54054. _rebuild(): void;
  54055. private _bits;
  54056. private _radicalInverse_VdC;
  54057. private _hammersley;
  54058. private _hemisphereSample_uniform;
  54059. private _generateHemisphere;
  54060. private _createSSAOPostProcess;
  54061. private _createSSAOCombinePostProcess;
  54062. private _createRandomTexture;
  54063. /**
  54064. * Serialize the rendering pipeline (Used when exporting)
  54065. * @returns the serialized object
  54066. */
  54067. serialize(): any;
  54068. /**
  54069. * Parse the serialized pipeline
  54070. * @param source Source pipeline.
  54071. * @param scene The scene to load the pipeline to.
  54072. * @param rootUrl The URL of the serialized pipeline.
  54073. * @returns An instantiated pipeline from the serialized object.
  54074. */
  54075. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54076. }
  54077. }
  54078. declare module "babylonjs/Shaders/ssao.fragment" {
  54079. /** @hidden */
  54080. export var ssaoPixelShader: {
  54081. name: string;
  54082. shader: string;
  54083. };
  54084. }
  54085. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54086. import { Camera } from "babylonjs/Cameras/camera";
  54087. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54088. import { Scene } from "babylonjs/scene";
  54089. import "babylonjs/Shaders/ssao.fragment";
  54090. import "babylonjs/Shaders/ssaoCombine.fragment";
  54091. /**
  54092. * Render pipeline to produce ssao effect
  54093. */
  54094. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54095. /**
  54096. * @ignore
  54097. * The PassPostProcess id in the pipeline that contains the original scene color
  54098. */
  54099. SSAOOriginalSceneColorEffect: string;
  54100. /**
  54101. * @ignore
  54102. * The SSAO PostProcess id in the pipeline
  54103. */
  54104. SSAORenderEffect: string;
  54105. /**
  54106. * @ignore
  54107. * The horizontal blur PostProcess id in the pipeline
  54108. */
  54109. SSAOBlurHRenderEffect: string;
  54110. /**
  54111. * @ignore
  54112. * The vertical blur PostProcess id in the pipeline
  54113. */
  54114. SSAOBlurVRenderEffect: string;
  54115. /**
  54116. * @ignore
  54117. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54118. */
  54119. SSAOCombineRenderEffect: string;
  54120. /**
  54121. * The output strength of the SSAO post-process. Default value is 1.0.
  54122. */
  54123. totalStrength: number;
  54124. /**
  54125. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54126. */
  54127. radius: number;
  54128. /**
  54129. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54130. * Must not be equal to fallOff and superior to fallOff.
  54131. * Default value is 0.0075
  54132. */
  54133. area: number;
  54134. /**
  54135. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54136. * Must not be equal to area and inferior to area.
  54137. * Default value is 0.000001
  54138. */
  54139. fallOff: number;
  54140. /**
  54141. * The base color of the SSAO post-process
  54142. * The final result is "base + ssao" between [0, 1]
  54143. */
  54144. base: number;
  54145. private _scene;
  54146. private _depthTexture;
  54147. private _randomTexture;
  54148. private _originalColorPostProcess;
  54149. private _ssaoPostProcess;
  54150. private _blurHPostProcess;
  54151. private _blurVPostProcess;
  54152. private _ssaoCombinePostProcess;
  54153. private _firstUpdate;
  54154. /**
  54155. * Gets active scene
  54156. */
  54157. readonly scene: Scene;
  54158. /**
  54159. * @constructor
  54160. * @param name - The rendering pipeline name
  54161. * @param scene - The scene linked to this pipeline
  54162. * @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 }
  54163. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54164. */
  54165. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54166. /**
  54167. * Get the class name
  54168. * @returns "SSAORenderingPipeline"
  54169. */
  54170. getClassName(): string;
  54171. /**
  54172. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54173. */
  54174. dispose(disableDepthRender?: boolean): void;
  54175. private _createBlurPostProcess;
  54176. /** @hidden */
  54177. _rebuild(): void;
  54178. private _createSSAOPostProcess;
  54179. private _createSSAOCombinePostProcess;
  54180. private _createRandomTexture;
  54181. }
  54182. }
  54183. declare module "babylonjs/Shaders/standard.fragment" {
  54184. /** @hidden */
  54185. export var standardPixelShader: {
  54186. name: string;
  54187. shader: string;
  54188. };
  54189. }
  54190. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54191. import { Nullable } from "babylonjs/types";
  54192. import { IAnimatable } from "babylonjs/Misc/tools";
  54193. import { Camera } from "babylonjs/Cameras/camera";
  54194. import { Texture } from "babylonjs/Materials/Textures/texture";
  54195. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54196. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54197. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54198. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54199. import { IDisposable } from "babylonjs/scene";
  54200. import { SpotLight } from "babylonjs/Lights/spotLight";
  54201. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54202. import { Scene } from "babylonjs/scene";
  54203. import { Animation } from "babylonjs/Animations/animation";
  54204. import "babylonjs/Shaders/standard.fragment";
  54205. /**
  54206. * Standard rendering pipeline
  54207. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54208. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54209. */
  54210. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54211. /**
  54212. * Public members
  54213. */
  54214. /**
  54215. * Post-process which contains the original scene color before the pipeline applies all the effects
  54216. */
  54217. originalPostProcess: Nullable<PostProcess>;
  54218. /**
  54219. * Post-process used to down scale an image x4
  54220. */
  54221. downSampleX4PostProcess: Nullable<PostProcess>;
  54222. /**
  54223. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54224. */
  54225. brightPassPostProcess: Nullable<PostProcess>;
  54226. /**
  54227. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54228. */
  54229. blurHPostProcesses: PostProcess[];
  54230. /**
  54231. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54232. */
  54233. blurVPostProcesses: PostProcess[];
  54234. /**
  54235. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54236. */
  54237. textureAdderPostProcess: Nullable<PostProcess>;
  54238. /**
  54239. * Post-process used to create volumetric lighting effect
  54240. */
  54241. volumetricLightPostProcess: Nullable<PostProcess>;
  54242. /**
  54243. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54244. */
  54245. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54246. /**
  54247. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54248. */
  54249. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54250. /**
  54251. * Post-process used to merge the volumetric light effect and the real scene color
  54252. */
  54253. volumetricLightMergePostProces: Nullable<PostProcess>;
  54254. /**
  54255. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54256. */
  54257. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54258. /**
  54259. * Base post-process used to calculate the average luminance of the final image for HDR
  54260. */
  54261. luminancePostProcess: Nullable<PostProcess>;
  54262. /**
  54263. * Post-processes used to create down sample post-processes in order to get
  54264. * the average luminance of the final image for HDR
  54265. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54266. */
  54267. luminanceDownSamplePostProcesses: PostProcess[];
  54268. /**
  54269. * Post-process used to create a HDR effect (light adaptation)
  54270. */
  54271. hdrPostProcess: Nullable<PostProcess>;
  54272. /**
  54273. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54274. */
  54275. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54276. /**
  54277. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54278. */
  54279. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54280. /**
  54281. * Post-process used to merge the final HDR post-process and the real scene color
  54282. */
  54283. hdrFinalPostProcess: Nullable<PostProcess>;
  54284. /**
  54285. * Post-process used to create a lens flare effect
  54286. */
  54287. lensFlarePostProcess: Nullable<PostProcess>;
  54288. /**
  54289. * Post-process that merges the result of the lens flare post-process and the real scene color
  54290. */
  54291. lensFlareComposePostProcess: Nullable<PostProcess>;
  54292. /**
  54293. * Post-process used to create a motion blur effect
  54294. */
  54295. motionBlurPostProcess: Nullable<PostProcess>;
  54296. /**
  54297. * Post-process used to create a depth of field effect
  54298. */
  54299. depthOfFieldPostProcess: Nullable<PostProcess>;
  54300. /**
  54301. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54302. */
  54303. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54304. /**
  54305. * Represents the brightness threshold in order to configure the illuminated surfaces
  54306. */
  54307. brightThreshold: number;
  54308. /**
  54309. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54310. */
  54311. blurWidth: number;
  54312. /**
  54313. * Sets if the blur for highlighted surfaces must be only horizontal
  54314. */
  54315. horizontalBlur: boolean;
  54316. /**
  54317. * Sets the overall exposure used by the pipeline
  54318. */
  54319. exposure: number;
  54320. /**
  54321. * Texture used typically to simulate "dirty" on camera lens
  54322. */
  54323. lensTexture: Nullable<Texture>;
  54324. /**
  54325. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54326. */
  54327. volumetricLightCoefficient: number;
  54328. /**
  54329. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54330. */
  54331. volumetricLightPower: number;
  54332. /**
  54333. * Used the set the blur intensity to smooth the volumetric lights
  54334. */
  54335. volumetricLightBlurScale: number;
  54336. /**
  54337. * Light (spot or directional) used to generate the volumetric lights rays
  54338. * The source light must have a shadow generate so the pipeline can get its
  54339. * depth map
  54340. */
  54341. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54342. /**
  54343. * For eye adaptation, represents the minimum luminance the eye can see
  54344. */
  54345. hdrMinimumLuminance: number;
  54346. /**
  54347. * For eye adaptation, represents the decrease luminance speed
  54348. */
  54349. hdrDecreaseRate: number;
  54350. /**
  54351. * For eye adaptation, represents the increase luminance speed
  54352. */
  54353. hdrIncreaseRate: number;
  54354. /**
  54355. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54356. */
  54357. lensColorTexture: Nullable<Texture>;
  54358. /**
  54359. * The overall strengh for the lens flare effect
  54360. */
  54361. lensFlareStrength: number;
  54362. /**
  54363. * Dispersion coefficient for lens flare ghosts
  54364. */
  54365. lensFlareGhostDispersal: number;
  54366. /**
  54367. * Main lens flare halo width
  54368. */
  54369. lensFlareHaloWidth: number;
  54370. /**
  54371. * Based on the lens distortion effect, defines how much the lens flare result
  54372. * is distorted
  54373. */
  54374. lensFlareDistortionStrength: number;
  54375. /**
  54376. * Lens star texture must be used to simulate rays on the flares and is available
  54377. * in the documentation
  54378. */
  54379. lensStarTexture: Nullable<Texture>;
  54380. /**
  54381. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54382. * flare effect by taking account of the dirt texture
  54383. */
  54384. lensFlareDirtTexture: Nullable<Texture>;
  54385. /**
  54386. * Represents the focal length for the depth of field effect
  54387. */
  54388. depthOfFieldDistance: number;
  54389. /**
  54390. * Represents the blur intensity for the blurred part of the depth of field effect
  54391. */
  54392. depthOfFieldBlurWidth: number;
  54393. /**
  54394. * For motion blur, defines how much the image is blurred by the movement
  54395. */
  54396. motionStrength: number;
  54397. /**
  54398. * List of animations for the pipeline (IAnimatable implementation)
  54399. */
  54400. animations: Animation[];
  54401. /**
  54402. * Private members
  54403. */
  54404. private _scene;
  54405. private _currentDepthOfFieldSource;
  54406. private _basePostProcess;
  54407. private _hdrCurrentLuminance;
  54408. private _floatTextureType;
  54409. private _ratio;
  54410. private _bloomEnabled;
  54411. private _depthOfFieldEnabled;
  54412. private _vlsEnabled;
  54413. private _lensFlareEnabled;
  54414. private _hdrEnabled;
  54415. private _motionBlurEnabled;
  54416. private _fxaaEnabled;
  54417. private _motionBlurSamples;
  54418. private _volumetricLightStepsCount;
  54419. private _samples;
  54420. /**
  54421. * @ignore
  54422. * Specifies if the bloom pipeline is enabled
  54423. */
  54424. BloomEnabled: boolean;
  54425. /**
  54426. * @ignore
  54427. * Specifies if the depth of field pipeline is enabed
  54428. */
  54429. DepthOfFieldEnabled: boolean;
  54430. /**
  54431. * @ignore
  54432. * Specifies if the lens flare pipeline is enabed
  54433. */
  54434. LensFlareEnabled: boolean;
  54435. /**
  54436. * @ignore
  54437. * Specifies if the HDR pipeline is enabled
  54438. */
  54439. HDREnabled: boolean;
  54440. /**
  54441. * @ignore
  54442. * Specifies if the volumetric lights scattering effect is enabled
  54443. */
  54444. VLSEnabled: boolean;
  54445. /**
  54446. * @ignore
  54447. * Specifies if the motion blur effect is enabled
  54448. */
  54449. MotionBlurEnabled: boolean;
  54450. /**
  54451. * Specifies if anti-aliasing is enabled
  54452. */
  54453. fxaaEnabled: boolean;
  54454. /**
  54455. * Specifies the number of steps used to calculate the volumetric lights
  54456. * Typically in interval [50, 200]
  54457. */
  54458. volumetricLightStepsCount: number;
  54459. /**
  54460. * Specifies the number of samples used for the motion blur effect
  54461. * Typically in interval [16, 64]
  54462. */
  54463. motionBlurSamples: number;
  54464. /**
  54465. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54466. */
  54467. samples: number;
  54468. /**
  54469. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54470. * @constructor
  54471. * @param name The rendering pipeline name
  54472. * @param scene The scene linked to this pipeline
  54473. * @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)
  54474. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54475. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54476. */
  54477. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54478. private _buildPipeline;
  54479. private _createDownSampleX4PostProcess;
  54480. private _createBrightPassPostProcess;
  54481. private _createBlurPostProcesses;
  54482. private _createTextureAdderPostProcess;
  54483. private _createVolumetricLightPostProcess;
  54484. private _createLuminancePostProcesses;
  54485. private _createHdrPostProcess;
  54486. private _createLensFlarePostProcess;
  54487. private _createDepthOfFieldPostProcess;
  54488. private _createMotionBlurPostProcess;
  54489. private _getDepthTexture;
  54490. private _disposePostProcesses;
  54491. /**
  54492. * Dispose of the pipeline and stop all post processes
  54493. */
  54494. dispose(): void;
  54495. /**
  54496. * Serialize the rendering pipeline (Used when exporting)
  54497. * @returns the serialized object
  54498. */
  54499. serialize(): any;
  54500. /**
  54501. * Parse the serialized pipeline
  54502. * @param source Source pipeline.
  54503. * @param scene The scene to load the pipeline to.
  54504. * @param rootUrl The URL of the serialized pipeline.
  54505. * @returns An instantiated pipeline from the serialized object.
  54506. */
  54507. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54508. /**
  54509. * Luminance steps
  54510. */
  54511. static LuminanceSteps: number;
  54512. }
  54513. }
  54514. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  54515. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  54516. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  54517. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  54518. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  54519. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  54520. }
  54521. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54522. import { Camera } from "babylonjs/Cameras/camera";
  54523. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54524. /**
  54525. * PostProcessRenderPipelineManager class
  54526. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54527. */
  54528. export class PostProcessRenderPipelineManager {
  54529. private _renderPipelines;
  54530. /**
  54531. * Initializes a PostProcessRenderPipelineManager
  54532. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54533. */
  54534. constructor();
  54535. /**
  54536. * Gets the list of supported render pipelines
  54537. */
  54538. readonly supportedPipelines: PostProcessRenderPipeline[];
  54539. /**
  54540. * Adds a pipeline to the manager
  54541. * @param renderPipeline The pipeline to add
  54542. */
  54543. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54544. /**
  54545. * Attaches a camera to the pipeline
  54546. * @param renderPipelineName The name of the pipeline to attach to
  54547. * @param cameras the camera to attach
  54548. * @param unique if the camera can be attached multiple times to the pipeline
  54549. */
  54550. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54551. /**
  54552. * Detaches a camera from the pipeline
  54553. * @param renderPipelineName The name of the pipeline to detach from
  54554. * @param cameras the camera to detach
  54555. */
  54556. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54557. /**
  54558. * Enables an effect by name on a pipeline
  54559. * @param renderPipelineName the name of the pipeline to enable the effect in
  54560. * @param renderEffectName the name of the effect to enable
  54561. * @param cameras the cameras that the effect should be enabled on
  54562. */
  54563. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54564. /**
  54565. * Disables an effect by name on a pipeline
  54566. * @param renderPipelineName the name of the pipeline to disable the effect in
  54567. * @param renderEffectName the name of the effect to disable
  54568. * @param cameras the cameras that the effect should be disabled on
  54569. */
  54570. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54571. /**
  54572. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54573. */
  54574. update(): void;
  54575. /** @hidden */
  54576. _rebuild(): void;
  54577. /**
  54578. * Disposes of the manager and pipelines
  54579. */
  54580. dispose(): void;
  54581. }
  54582. }
  54583. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54584. import { ISceneComponent } from "babylonjs/sceneComponent";
  54585. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54586. import { Scene } from "babylonjs/scene";
  54587. module "babylonjs/scene" {
  54588. interface Scene {
  54589. /** @hidden (Backing field) */
  54590. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54591. /**
  54592. * Gets the postprocess render pipeline manager
  54593. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54594. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54595. */
  54596. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54597. }
  54598. }
  54599. /**
  54600. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54601. */
  54602. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54603. /**
  54604. * The component name helpfull to identify the component in the list of scene components.
  54605. */
  54606. readonly name: string;
  54607. /**
  54608. * The scene the component belongs to.
  54609. */
  54610. scene: Scene;
  54611. /**
  54612. * Creates a new instance of the component for the given scene
  54613. * @param scene Defines the scene to register the component in
  54614. */
  54615. constructor(scene: Scene);
  54616. /**
  54617. * Registers the component in a given scene
  54618. */
  54619. register(): void;
  54620. /**
  54621. * Rebuilds the elements related to this component in case of
  54622. * context lost for instance.
  54623. */
  54624. rebuild(): void;
  54625. /**
  54626. * Disposes the component and the associated ressources
  54627. */
  54628. dispose(): void;
  54629. private _gatherRenderTargets;
  54630. }
  54631. }
  54632. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  54633. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  54634. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54635. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54636. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54637. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54638. }
  54639. declare module "babylonjs/Shaders/tonemap.fragment" {
  54640. /** @hidden */
  54641. export var tonemapPixelShader: {
  54642. name: string;
  54643. shader: string;
  54644. };
  54645. }
  54646. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  54647. import { Camera } from "babylonjs/Cameras/camera";
  54648. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54649. import "babylonjs/Shaders/tonemap.fragment";
  54650. import { Engine } from "babylonjs/Engines/engine";
  54651. /** Defines operator used for tonemapping */
  54652. export enum TonemappingOperator {
  54653. /** Hable */
  54654. Hable = 0,
  54655. /** Reinhard */
  54656. Reinhard = 1,
  54657. /** HejiDawson */
  54658. HejiDawson = 2,
  54659. /** Photographic */
  54660. Photographic = 3
  54661. }
  54662. /**
  54663. * Defines a post process to apply tone mapping
  54664. */
  54665. export class TonemapPostProcess extends PostProcess {
  54666. private _operator;
  54667. /** Defines the required exposure adjustement */
  54668. exposureAdjustment: number;
  54669. /**
  54670. * Creates a new TonemapPostProcess
  54671. * @param name defines the name of the postprocess
  54672. * @param _operator defines the operator to use
  54673. * @param exposureAdjustment defines the required exposure adjustement
  54674. * @param camera defines the camera to use (can be null)
  54675. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54676. * @param engine defines the hosting engine (can be ignore if camera is set)
  54677. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54678. */
  54679. constructor(name: string, _operator: TonemappingOperator,
  54680. /** Defines the required exposure adjustement */
  54681. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54682. }
  54683. }
  54684. declare module "babylonjs/Shaders/depth.vertex" {
  54685. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54686. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54687. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54688. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54689. /** @hidden */
  54690. export var depthVertexShader: {
  54691. name: string;
  54692. shader: string;
  54693. };
  54694. }
  54695. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  54696. /** @hidden */
  54697. export var volumetricLightScatteringPixelShader: {
  54698. name: string;
  54699. shader: string;
  54700. };
  54701. }
  54702. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  54703. /** @hidden */
  54704. export var volumetricLightScatteringPassPixelShader: {
  54705. name: string;
  54706. shader: string;
  54707. };
  54708. }
  54709. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  54710. import { Vector3 } from "babylonjs/Maths/math";
  54711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54712. import { Mesh } from "babylonjs/Meshes/mesh";
  54713. import { Camera } from "babylonjs/Cameras/camera";
  54714. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54715. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54716. import { Scene } from "babylonjs/scene";
  54717. import "babylonjs/Meshes/Builders/planeBuilder";
  54718. import "babylonjs/Shaders/depth.vertex";
  54719. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  54720. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  54721. import { Engine } from "babylonjs/Engines/engine";
  54722. /**
  54723. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54724. */
  54725. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54726. private _volumetricLightScatteringPass;
  54727. private _volumetricLightScatteringRTT;
  54728. private _viewPort;
  54729. private _screenCoordinates;
  54730. private _cachedDefines;
  54731. /**
  54732. * If not undefined, the mesh position is computed from the attached node position
  54733. */
  54734. attachedNode: {
  54735. position: Vector3;
  54736. };
  54737. /**
  54738. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54739. */
  54740. customMeshPosition: Vector3;
  54741. /**
  54742. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54743. */
  54744. useCustomMeshPosition: boolean;
  54745. /**
  54746. * If the post-process should inverse the light scattering direction
  54747. */
  54748. invert: boolean;
  54749. /**
  54750. * The internal mesh used by the post-process
  54751. */
  54752. mesh: Mesh;
  54753. /**
  54754. * @hidden
  54755. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54756. */
  54757. useDiffuseColor: boolean;
  54758. /**
  54759. * Array containing the excluded meshes not rendered in the internal pass
  54760. */
  54761. excludedMeshes: AbstractMesh[];
  54762. /**
  54763. * Controls the overall intensity of the post-process
  54764. */
  54765. exposure: number;
  54766. /**
  54767. * Dissipates each sample's contribution in range [0, 1]
  54768. */
  54769. decay: number;
  54770. /**
  54771. * Controls the overall intensity of each sample
  54772. */
  54773. weight: number;
  54774. /**
  54775. * Controls the density of each sample
  54776. */
  54777. density: number;
  54778. /**
  54779. * @constructor
  54780. * @param name The post-process name
  54781. * @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)
  54782. * @param camera The camera that the post-process will be attached to
  54783. * @param mesh The mesh used to create the light scattering
  54784. * @param samples The post-process quality, default 100
  54785. * @param samplingModeThe post-process filtering mode
  54786. * @param engine The babylon engine
  54787. * @param reusable If the post-process is reusable
  54788. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54789. */
  54790. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54791. /**
  54792. * Returns the string "VolumetricLightScatteringPostProcess"
  54793. * @returns "VolumetricLightScatteringPostProcess"
  54794. */
  54795. getClassName(): string;
  54796. private _isReady;
  54797. /**
  54798. * Sets the new light position for light scattering effect
  54799. * @param position The new custom light position
  54800. */
  54801. setCustomMeshPosition(position: Vector3): void;
  54802. /**
  54803. * Returns the light position for light scattering effect
  54804. * @return Vector3 The custom light position
  54805. */
  54806. getCustomMeshPosition(): Vector3;
  54807. /**
  54808. * Disposes the internal assets and detaches the post-process from the camera
  54809. */
  54810. dispose(camera: Camera): void;
  54811. /**
  54812. * Returns the render target texture used by the post-process
  54813. * @return the render target texture used by the post-process
  54814. */
  54815. getPass(): RenderTargetTexture;
  54816. private _meshExcluded;
  54817. private _createPass;
  54818. private _updateMeshScreenCoordinates;
  54819. /**
  54820. * Creates a default mesh for the Volumeric Light Scattering post-process
  54821. * @param name The mesh name
  54822. * @param scene The scene where to create the mesh
  54823. * @return the default mesh
  54824. */
  54825. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54826. }
  54827. }
  54828. declare module "babylonjs/PostProcesses/index" {
  54829. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  54830. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  54831. export * from "babylonjs/PostProcesses/bloomEffect";
  54832. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  54833. export * from "babylonjs/PostProcesses/blurPostProcess";
  54834. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54835. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  54836. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  54837. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  54838. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54839. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  54840. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  54841. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  54842. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54843. export * from "babylonjs/PostProcesses/filterPostProcess";
  54844. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  54845. export * from "babylonjs/PostProcesses/grainPostProcess";
  54846. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  54847. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54848. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  54849. export * from "babylonjs/PostProcesses/passPostProcess";
  54850. export * from "babylonjs/PostProcesses/postProcess";
  54851. export * from "babylonjs/PostProcesses/postProcessManager";
  54852. export * from "babylonjs/PostProcesses/refractionPostProcess";
  54853. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  54854. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  54855. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  54856. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  54857. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  54858. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  54859. }
  54860. declare module "babylonjs/Probes/index" {
  54861. export * from "babylonjs/Probes/reflectionProbe";
  54862. }
  54863. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  54864. import { Scene } from "babylonjs/scene";
  54865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54866. import { Color3 } from "babylonjs/Maths/math";
  54867. import { SmartArray } from "babylonjs/Misc/smartArray";
  54868. import { ISceneComponent } from "babylonjs/sceneComponent";
  54869. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  54870. import "babylonjs/Meshes/Builders/boxBuilder";
  54871. import "babylonjs/Shaders/color.fragment";
  54872. import "babylonjs/Shaders/color.vertex";
  54873. module "babylonjs/scene" {
  54874. interface Scene {
  54875. /** @hidden (Backing field) */
  54876. _boundingBoxRenderer: BoundingBoxRenderer;
  54877. /** @hidden (Backing field) */
  54878. _forceShowBoundingBoxes: boolean;
  54879. /**
  54880. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54881. */
  54882. forceShowBoundingBoxes: boolean;
  54883. /**
  54884. * Gets the bounding box renderer associated with the scene
  54885. * @returns a BoundingBoxRenderer
  54886. */
  54887. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54888. }
  54889. }
  54890. module "babylonjs/Meshes/abstractMesh" {
  54891. interface AbstractMesh {
  54892. /** @hidden (Backing field) */
  54893. _showBoundingBox: boolean;
  54894. /**
  54895. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54896. */
  54897. showBoundingBox: boolean;
  54898. }
  54899. }
  54900. /**
  54901. * Component responsible of rendering the bounding box of the meshes in a scene.
  54902. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54903. */
  54904. export class BoundingBoxRenderer implements ISceneComponent {
  54905. /**
  54906. * The component name helpfull to identify the component in the list of scene components.
  54907. */
  54908. readonly name: string;
  54909. /**
  54910. * The scene the component belongs to.
  54911. */
  54912. scene: Scene;
  54913. /**
  54914. * Color of the bounding box lines placed in front of an object
  54915. */
  54916. frontColor: Color3;
  54917. /**
  54918. * Color of the bounding box lines placed behind an object
  54919. */
  54920. backColor: Color3;
  54921. /**
  54922. * Defines if the renderer should show the back lines or not
  54923. */
  54924. showBackLines: boolean;
  54925. /**
  54926. * @hidden
  54927. */
  54928. renderList: SmartArray<BoundingBox>;
  54929. private _colorShader;
  54930. private _vertexBuffers;
  54931. private _indexBuffer;
  54932. /**
  54933. * Instantiates a new bounding box renderer in a scene.
  54934. * @param scene the scene the renderer renders in
  54935. */
  54936. constructor(scene: Scene);
  54937. /**
  54938. * Registers the component in a given scene
  54939. */
  54940. register(): void;
  54941. private _evaluateSubMesh;
  54942. private _activeMesh;
  54943. private _prepareRessources;
  54944. private _createIndexBuffer;
  54945. /**
  54946. * Rebuilds the elements related to this component in case of
  54947. * context lost for instance.
  54948. */
  54949. rebuild(): void;
  54950. /**
  54951. * @hidden
  54952. */
  54953. reset(): void;
  54954. /**
  54955. * Render the bounding boxes of a specific rendering group
  54956. * @param renderingGroupId defines the rendering group to render
  54957. */
  54958. render(renderingGroupId: number): void;
  54959. /**
  54960. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54961. * @param mesh Define the mesh to render the occlusion bounding box for
  54962. */
  54963. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54964. /**
  54965. * Dispose and release the resources attached to this renderer.
  54966. */
  54967. dispose(): void;
  54968. }
  54969. }
  54970. declare module "babylonjs/Shaders/depth.fragment" {
  54971. /** @hidden */
  54972. export var depthPixelShader: {
  54973. name: string;
  54974. shader: string;
  54975. };
  54976. }
  54977. declare module "babylonjs/Rendering/depthRenderer" {
  54978. import { Nullable } from "babylonjs/types";
  54979. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54980. import { Scene } from "babylonjs/scene";
  54981. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54982. import { Camera } from "babylonjs/Cameras/camera";
  54983. import "babylonjs/Shaders/depth.fragment";
  54984. import "babylonjs/Shaders/depth.vertex";
  54985. /**
  54986. * This represents a depth renderer in Babylon.
  54987. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54988. */
  54989. export class DepthRenderer {
  54990. private _scene;
  54991. private _depthMap;
  54992. private _effect;
  54993. private _cachedDefines;
  54994. private _camera;
  54995. /**
  54996. * Specifiess that the depth renderer will only be used within
  54997. * the camera it is created for.
  54998. * This can help forcing its rendering during the camera processing.
  54999. */
  55000. useOnlyInActiveCamera: boolean;
  55001. /** @hidden */
  55002. static _SceneComponentInitialization: (scene: Scene) => void;
  55003. /**
  55004. * Instantiates a depth renderer
  55005. * @param scene The scene the renderer belongs to
  55006. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55007. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55008. */
  55009. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55010. /**
  55011. * Creates the depth rendering effect and checks if the effect is ready.
  55012. * @param subMesh The submesh to be used to render the depth map of
  55013. * @param useInstances If multiple world instances should be used
  55014. * @returns if the depth renderer is ready to render the depth map
  55015. */
  55016. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55017. /**
  55018. * Gets the texture which the depth map will be written to.
  55019. * @returns The depth map texture
  55020. */
  55021. getDepthMap(): RenderTargetTexture;
  55022. /**
  55023. * Disposes of the depth renderer.
  55024. */
  55025. dispose(): void;
  55026. }
  55027. }
  55028. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  55029. import { Nullable } from "babylonjs/types";
  55030. import { Scene } from "babylonjs/scene";
  55031. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  55032. import { Camera } from "babylonjs/Cameras/camera";
  55033. import { ISceneComponent } from "babylonjs/sceneComponent";
  55034. module "babylonjs/scene" {
  55035. interface Scene {
  55036. /** @hidden (Backing field) */
  55037. _depthRenderer: {
  55038. [id: string]: DepthRenderer;
  55039. };
  55040. /**
  55041. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55042. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55043. * @returns the created depth renderer
  55044. */
  55045. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55046. /**
  55047. * Disables a depth renderer for a given camera
  55048. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55049. */
  55050. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55051. }
  55052. }
  55053. /**
  55054. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55055. * in several rendering techniques.
  55056. */
  55057. export class DepthRendererSceneComponent implements ISceneComponent {
  55058. /**
  55059. * The component name helpfull to identify the component in the list of scene components.
  55060. */
  55061. readonly name: string;
  55062. /**
  55063. * The scene the component belongs to.
  55064. */
  55065. scene: Scene;
  55066. /**
  55067. * Creates a new instance of the component for the given scene
  55068. * @param scene Defines the scene to register the component in
  55069. */
  55070. constructor(scene: Scene);
  55071. /**
  55072. * Registers the component in a given scene
  55073. */
  55074. register(): void;
  55075. /**
  55076. * Rebuilds the elements related to this component in case of
  55077. * context lost for instance.
  55078. */
  55079. rebuild(): void;
  55080. /**
  55081. * Disposes the component and the associated ressources
  55082. */
  55083. dispose(): void;
  55084. private _gatherRenderTargets;
  55085. private _gatherActiveCameraRenderTargets;
  55086. }
  55087. }
  55088. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55089. import { Nullable } from "babylonjs/types";
  55090. import { Scene } from "babylonjs/scene";
  55091. import { ISceneComponent } from "babylonjs/sceneComponent";
  55092. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55093. module "babylonjs/scene" {
  55094. interface Scene {
  55095. /** @hidden (Backing field) */
  55096. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55097. /**
  55098. * Gets or Sets the current geometry buffer associated to the scene.
  55099. */
  55100. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55101. /**
  55102. * Enables a GeometryBufferRender and associates it with the scene
  55103. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55104. * @returns the GeometryBufferRenderer
  55105. */
  55106. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55107. /**
  55108. * Disables the GeometryBufferRender associated with the scene
  55109. */
  55110. disableGeometryBufferRenderer(): void;
  55111. }
  55112. }
  55113. /**
  55114. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55115. * in several rendering techniques.
  55116. */
  55117. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55118. /**
  55119. * The component name helpful to identify the component in the list of scene components.
  55120. */
  55121. readonly name: string;
  55122. /**
  55123. * The scene the component belongs to.
  55124. */
  55125. scene: Scene;
  55126. /**
  55127. * Creates a new instance of the component for the given scene
  55128. * @param scene Defines the scene to register the component in
  55129. */
  55130. constructor(scene: Scene);
  55131. /**
  55132. * Registers the component in a given scene
  55133. */
  55134. register(): void;
  55135. /**
  55136. * Rebuilds the elements related to this component in case of
  55137. * context lost for instance.
  55138. */
  55139. rebuild(): void;
  55140. /**
  55141. * Disposes the component and the associated ressources
  55142. */
  55143. dispose(): void;
  55144. private _gatherRenderTargets;
  55145. }
  55146. }
  55147. declare module "babylonjs/Shaders/outline.fragment" {
  55148. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55149. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55150. /** @hidden */
  55151. export var outlinePixelShader: {
  55152. name: string;
  55153. shader: string;
  55154. };
  55155. }
  55156. declare module "babylonjs/Shaders/outline.vertex" {
  55157. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55158. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55159. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55160. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55161. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55162. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55163. /** @hidden */
  55164. export var outlineVertexShader: {
  55165. name: string;
  55166. shader: string;
  55167. };
  55168. }
  55169. declare module "babylonjs/Rendering/outlineRenderer" {
  55170. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55171. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55172. import { Scene } from "babylonjs/scene";
  55173. import { ISceneComponent } from "babylonjs/sceneComponent";
  55174. import "babylonjs/Shaders/outline.fragment";
  55175. import "babylonjs/Shaders/outline.vertex";
  55176. module "babylonjs/scene" {
  55177. interface Scene {
  55178. /** @hidden */
  55179. _outlineRenderer: OutlineRenderer;
  55180. /**
  55181. * Gets the outline renderer associated with the scene
  55182. * @returns a OutlineRenderer
  55183. */
  55184. getOutlineRenderer(): OutlineRenderer;
  55185. }
  55186. }
  55187. module "babylonjs/Meshes/abstractMesh" {
  55188. interface AbstractMesh {
  55189. /** @hidden (Backing field) */
  55190. _renderOutline: boolean;
  55191. /**
  55192. * Gets or sets a boolean indicating if the outline must be rendered as well
  55193. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55194. */
  55195. renderOutline: boolean;
  55196. /** @hidden (Backing field) */
  55197. _renderOverlay: boolean;
  55198. /**
  55199. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55200. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55201. */
  55202. renderOverlay: boolean;
  55203. }
  55204. }
  55205. /**
  55206. * This class is responsible to draw bothe outline/overlay of meshes.
  55207. * It should not be used directly but through the available method on mesh.
  55208. */
  55209. export class OutlineRenderer implements ISceneComponent {
  55210. /**
  55211. * The name of the component. Each component must have a unique name.
  55212. */
  55213. name: string;
  55214. /**
  55215. * The scene the component belongs to.
  55216. */
  55217. scene: Scene;
  55218. /**
  55219. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55220. */
  55221. zOffset: number;
  55222. private _engine;
  55223. private _effect;
  55224. private _cachedDefines;
  55225. private _savedDepthWrite;
  55226. /**
  55227. * Instantiates a new outline renderer. (There could be only one per scene).
  55228. * @param scene Defines the scene it belongs to
  55229. */
  55230. constructor(scene: Scene);
  55231. /**
  55232. * Register the component to one instance of a scene.
  55233. */
  55234. register(): void;
  55235. /**
  55236. * Rebuilds the elements related to this component in case of
  55237. * context lost for instance.
  55238. */
  55239. rebuild(): void;
  55240. /**
  55241. * Disposes the component and the associated ressources.
  55242. */
  55243. dispose(): void;
  55244. /**
  55245. * Renders the outline in the canvas.
  55246. * @param subMesh Defines the sumesh to render
  55247. * @param batch Defines the batch of meshes in case of instances
  55248. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55249. */
  55250. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55251. /**
  55252. * Returns whether or not the outline renderer is ready for a given submesh.
  55253. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55254. * @param subMesh Defines the submesh to check readyness for
  55255. * @param useInstances Defines wheter wee are trying to render instances or not
  55256. * @returns true if ready otherwise false
  55257. */
  55258. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55259. private _beforeRenderingMesh;
  55260. private _afterRenderingMesh;
  55261. }
  55262. }
  55263. declare module "babylonjs/Rendering/index" {
  55264. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55265. export * from "babylonjs/Rendering/depthRenderer";
  55266. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55267. export * from "babylonjs/Rendering/edgesRenderer";
  55268. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55269. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55270. export * from "babylonjs/Rendering/outlineRenderer";
  55271. export * from "babylonjs/Rendering/renderingGroup";
  55272. export * from "babylonjs/Rendering/renderingManager";
  55273. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55274. }
  55275. declare module "babylonjs/Sprites/index" {
  55276. export * from "babylonjs/Sprites/sprite";
  55277. export * from "babylonjs/Sprites/spriteManager";
  55278. export * from "babylonjs/Sprites/spriteSceneComponent";
  55279. }
  55280. declare module "babylonjs/Misc/assetsManager" {
  55281. import { Scene } from "babylonjs/scene";
  55282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55283. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55284. import { Skeleton } from "babylonjs/Bones/skeleton";
  55285. import { Observable } from "babylonjs/Misc/observable";
  55286. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55287. import { Texture } from "babylonjs/Materials/Textures/texture";
  55288. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55289. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55290. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55291. /**
  55292. * Defines the list of states available for a task inside a AssetsManager
  55293. */
  55294. export enum AssetTaskState {
  55295. /**
  55296. * Initialization
  55297. */
  55298. INIT = 0,
  55299. /**
  55300. * Running
  55301. */
  55302. RUNNING = 1,
  55303. /**
  55304. * Done
  55305. */
  55306. DONE = 2,
  55307. /**
  55308. * Error
  55309. */
  55310. ERROR = 3
  55311. }
  55312. /**
  55313. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55314. */
  55315. export abstract class AbstractAssetTask {
  55316. /**
  55317. * Task name
  55318. */ name: string;
  55319. /**
  55320. * Callback called when the task is successful
  55321. */
  55322. onSuccess: (task: any) => void;
  55323. /**
  55324. * Callback called when the task is not successful
  55325. */
  55326. onError: (task: any, message?: string, exception?: any) => void;
  55327. /**
  55328. * Creates a new AssetsManager
  55329. * @param name defines the name of the task
  55330. */
  55331. constructor(
  55332. /**
  55333. * Task name
  55334. */ name: string);
  55335. private _isCompleted;
  55336. private _taskState;
  55337. private _errorObject;
  55338. /**
  55339. * Get if the task is completed
  55340. */
  55341. readonly isCompleted: boolean;
  55342. /**
  55343. * Gets the current state of the task
  55344. */
  55345. readonly taskState: AssetTaskState;
  55346. /**
  55347. * Gets the current error object (if task is in error)
  55348. */
  55349. readonly errorObject: {
  55350. message?: string;
  55351. exception?: any;
  55352. };
  55353. /**
  55354. * Internal only
  55355. * @hidden
  55356. */
  55357. _setErrorObject(message?: string, exception?: any): void;
  55358. /**
  55359. * Execute the current task
  55360. * @param scene defines the scene where you want your assets to be loaded
  55361. * @param onSuccess is a callback called when the task is successfully executed
  55362. * @param onError is a callback called if an error occurs
  55363. */
  55364. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55365. /**
  55366. * Execute the current task
  55367. * @param scene defines the scene where you want your assets to be loaded
  55368. * @param onSuccess is a callback called when the task is successfully executed
  55369. * @param onError is a callback called if an error occurs
  55370. */
  55371. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55372. /**
  55373. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55374. * This can be used with failed tasks that have the reason for failure fixed.
  55375. */
  55376. reset(): void;
  55377. private onErrorCallback;
  55378. private onDoneCallback;
  55379. }
  55380. /**
  55381. * Define the interface used by progress events raised during assets loading
  55382. */
  55383. export interface IAssetsProgressEvent {
  55384. /**
  55385. * Defines the number of remaining tasks to process
  55386. */
  55387. remainingCount: number;
  55388. /**
  55389. * Defines the total number of tasks
  55390. */
  55391. totalCount: number;
  55392. /**
  55393. * Defines the task that was just processed
  55394. */
  55395. task: AbstractAssetTask;
  55396. }
  55397. /**
  55398. * Class used to share progress information about assets loading
  55399. */
  55400. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55401. /**
  55402. * Defines the number of remaining tasks to process
  55403. */
  55404. remainingCount: number;
  55405. /**
  55406. * Defines the total number of tasks
  55407. */
  55408. totalCount: number;
  55409. /**
  55410. * Defines the task that was just processed
  55411. */
  55412. task: AbstractAssetTask;
  55413. /**
  55414. * Creates a AssetsProgressEvent
  55415. * @param remainingCount defines the number of remaining tasks to process
  55416. * @param totalCount defines the total number of tasks
  55417. * @param task defines the task that was just processed
  55418. */
  55419. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55420. }
  55421. /**
  55422. * Define a task used by AssetsManager to load meshes
  55423. */
  55424. export class MeshAssetTask extends AbstractAssetTask {
  55425. /**
  55426. * Defines the name of the task
  55427. */
  55428. name: string;
  55429. /**
  55430. * Defines the list of mesh's names you want to load
  55431. */
  55432. meshesNames: any;
  55433. /**
  55434. * Defines the root url to use as a base to load your meshes and associated resources
  55435. */
  55436. rootUrl: string;
  55437. /**
  55438. * Defines the filename of the scene to load from
  55439. */
  55440. sceneFilename: string;
  55441. /**
  55442. * Gets the list of loaded meshes
  55443. */
  55444. loadedMeshes: Array<AbstractMesh>;
  55445. /**
  55446. * Gets the list of loaded particle systems
  55447. */
  55448. loadedParticleSystems: Array<IParticleSystem>;
  55449. /**
  55450. * Gets the list of loaded skeletons
  55451. */
  55452. loadedSkeletons: Array<Skeleton>;
  55453. /**
  55454. * Gets the list of loaded animation groups
  55455. */
  55456. loadedAnimationGroups: Array<AnimationGroup>;
  55457. /**
  55458. * Callback called when the task is successful
  55459. */
  55460. onSuccess: (task: MeshAssetTask) => void;
  55461. /**
  55462. * Callback called when the task is successful
  55463. */
  55464. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55465. /**
  55466. * Creates a new MeshAssetTask
  55467. * @param name defines the name of the task
  55468. * @param meshesNames defines the list of mesh's names you want to load
  55469. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55470. * @param sceneFilename defines the filename of the scene to load from
  55471. */
  55472. constructor(
  55473. /**
  55474. * Defines the name of the task
  55475. */
  55476. name: string,
  55477. /**
  55478. * Defines the list of mesh's names you want to load
  55479. */
  55480. meshesNames: any,
  55481. /**
  55482. * Defines the root url to use as a base to load your meshes and associated resources
  55483. */
  55484. rootUrl: string,
  55485. /**
  55486. * Defines the filename of the scene to load from
  55487. */
  55488. sceneFilename: string);
  55489. /**
  55490. * Execute the current task
  55491. * @param scene defines the scene where you want your assets to be loaded
  55492. * @param onSuccess is a callback called when the task is successfully executed
  55493. * @param onError is a callback called if an error occurs
  55494. */
  55495. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55496. }
  55497. /**
  55498. * Define a task used by AssetsManager to load text content
  55499. */
  55500. export class TextFileAssetTask extends AbstractAssetTask {
  55501. /**
  55502. * Defines the name of the task
  55503. */
  55504. name: string;
  55505. /**
  55506. * Defines the location of the file to load
  55507. */
  55508. url: string;
  55509. /**
  55510. * Gets the loaded text string
  55511. */
  55512. text: string;
  55513. /**
  55514. * Callback called when the task is successful
  55515. */
  55516. onSuccess: (task: TextFileAssetTask) => void;
  55517. /**
  55518. * Callback called when the task is successful
  55519. */
  55520. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55521. /**
  55522. * Creates a new TextFileAssetTask object
  55523. * @param name defines the name of the task
  55524. * @param url defines the location of the file to load
  55525. */
  55526. constructor(
  55527. /**
  55528. * Defines the name of the task
  55529. */
  55530. name: string,
  55531. /**
  55532. * Defines the location of the file to load
  55533. */
  55534. url: string);
  55535. /**
  55536. * Execute the current task
  55537. * @param scene defines the scene where you want your assets to be loaded
  55538. * @param onSuccess is a callback called when the task is successfully executed
  55539. * @param onError is a callback called if an error occurs
  55540. */
  55541. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55542. }
  55543. /**
  55544. * Define a task used by AssetsManager to load binary data
  55545. */
  55546. export class BinaryFileAssetTask extends AbstractAssetTask {
  55547. /**
  55548. * Defines the name of the task
  55549. */
  55550. name: string;
  55551. /**
  55552. * Defines the location of the file to load
  55553. */
  55554. url: string;
  55555. /**
  55556. * Gets the lodaded data (as an array buffer)
  55557. */
  55558. data: ArrayBuffer;
  55559. /**
  55560. * Callback called when the task is successful
  55561. */
  55562. onSuccess: (task: BinaryFileAssetTask) => void;
  55563. /**
  55564. * Callback called when the task is successful
  55565. */
  55566. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55567. /**
  55568. * Creates a new BinaryFileAssetTask object
  55569. * @param name defines the name of the new task
  55570. * @param url defines the location of the file to load
  55571. */
  55572. constructor(
  55573. /**
  55574. * Defines the name of the task
  55575. */
  55576. name: string,
  55577. /**
  55578. * Defines the location of the file to load
  55579. */
  55580. url: string);
  55581. /**
  55582. * Execute the current task
  55583. * @param scene defines the scene where you want your assets to be loaded
  55584. * @param onSuccess is a callback called when the task is successfully executed
  55585. * @param onError is a callback called if an error occurs
  55586. */
  55587. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55588. }
  55589. /**
  55590. * Define a task used by AssetsManager to load images
  55591. */
  55592. export class ImageAssetTask extends AbstractAssetTask {
  55593. /**
  55594. * Defines the name of the task
  55595. */
  55596. name: string;
  55597. /**
  55598. * Defines the location of the image to load
  55599. */
  55600. url: string;
  55601. /**
  55602. * Gets the loaded images
  55603. */
  55604. image: HTMLImageElement;
  55605. /**
  55606. * Callback called when the task is successful
  55607. */
  55608. onSuccess: (task: ImageAssetTask) => void;
  55609. /**
  55610. * Callback called when the task is successful
  55611. */
  55612. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55613. /**
  55614. * Creates a new ImageAssetTask
  55615. * @param name defines the name of the task
  55616. * @param url defines the location of the image to load
  55617. */
  55618. constructor(
  55619. /**
  55620. * Defines the name of the task
  55621. */
  55622. name: string,
  55623. /**
  55624. * Defines the location of the image to load
  55625. */
  55626. url: string);
  55627. /**
  55628. * Execute the current task
  55629. * @param scene defines the scene where you want your assets to be loaded
  55630. * @param onSuccess is a callback called when the task is successfully executed
  55631. * @param onError is a callback called if an error occurs
  55632. */
  55633. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55634. }
  55635. /**
  55636. * Defines the interface used by texture loading tasks
  55637. */
  55638. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55639. /**
  55640. * Gets the loaded texture
  55641. */
  55642. texture: TEX;
  55643. }
  55644. /**
  55645. * Define a task used by AssetsManager to load 2D textures
  55646. */
  55647. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55648. /**
  55649. * Defines the name of the task
  55650. */
  55651. name: string;
  55652. /**
  55653. * Defines the location of the file to load
  55654. */
  55655. url: string;
  55656. /**
  55657. * Defines if mipmap should not be generated (default is false)
  55658. */
  55659. noMipmap?: boolean | undefined;
  55660. /**
  55661. * Defines if texture must be inverted on Y axis (default is false)
  55662. */
  55663. invertY?: boolean | undefined;
  55664. /**
  55665. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55666. */
  55667. samplingMode: number;
  55668. /**
  55669. * Gets the loaded texture
  55670. */
  55671. texture: Texture;
  55672. /**
  55673. * Callback called when the task is successful
  55674. */
  55675. onSuccess: (task: TextureAssetTask) => void;
  55676. /**
  55677. * Callback called when the task is successful
  55678. */
  55679. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55680. /**
  55681. * Creates a new TextureAssetTask object
  55682. * @param name defines the name of the task
  55683. * @param url defines the location of the file to load
  55684. * @param noMipmap defines if mipmap should not be generated (default is false)
  55685. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55686. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55687. */
  55688. constructor(
  55689. /**
  55690. * Defines the name of the task
  55691. */
  55692. name: string,
  55693. /**
  55694. * Defines the location of the file to load
  55695. */
  55696. url: string,
  55697. /**
  55698. * Defines if mipmap should not be generated (default is false)
  55699. */
  55700. noMipmap?: boolean | undefined,
  55701. /**
  55702. * Defines if texture must be inverted on Y axis (default is false)
  55703. */
  55704. invertY?: boolean | undefined,
  55705. /**
  55706. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55707. */
  55708. samplingMode?: number);
  55709. /**
  55710. * Execute the current task
  55711. * @param scene defines the scene where you want your assets to be loaded
  55712. * @param onSuccess is a callback called when the task is successfully executed
  55713. * @param onError is a callback called if an error occurs
  55714. */
  55715. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55716. }
  55717. /**
  55718. * Define a task used by AssetsManager to load cube textures
  55719. */
  55720. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55721. /**
  55722. * Defines the name of the task
  55723. */
  55724. name: string;
  55725. /**
  55726. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55727. */
  55728. url: string;
  55729. /**
  55730. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55731. */
  55732. extensions?: string[] | undefined;
  55733. /**
  55734. * Defines if mipmaps should not be generated (default is false)
  55735. */
  55736. noMipmap?: boolean | undefined;
  55737. /**
  55738. * Defines the explicit list of files (undefined by default)
  55739. */
  55740. files?: string[] | undefined;
  55741. /**
  55742. * Gets the loaded texture
  55743. */
  55744. texture: CubeTexture;
  55745. /**
  55746. * Callback called when the task is successful
  55747. */
  55748. onSuccess: (task: CubeTextureAssetTask) => void;
  55749. /**
  55750. * Callback called when the task is successful
  55751. */
  55752. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55753. /**
  55754. * Creates a new CubeTextureAssetTask
  55755. * @param name defines the name of the task
  55756. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55757. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55758. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55759. * @param files defines the explicit list of files (undefined by default)
  55760. */
  55761. constructor(
  55762. /**
  55763. * Defines the name of the task
  55764. */
  55765. name: string,
  55766. /**
  55767. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55768. */
  55769. url: string,
  55770. /**
  55771. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55772. */
  55773. extensions?: string[] | undefined,
  55774. /**
  55775. * Defines if mipmaps should not be generated (default is false)
  55776. */
  55777. noMipmap?: boolean | undefined,
  55778. /**
  55779. * Defines the explicit list of files (undefined by default)
  55780. */
  55781. files?: string[] | undefined);
  55782. /**
  55783. * Execute the current task
  55784. * @param scene defines the scene where you want your assets to be loaded
  55785. * @param onSuccess is a callback called when the task is successfully executed
  55786. * @param onError is a callback called if an error occurs
  55787. */
  55788. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55789. }
  55790. /**
  55791. * Define a task used by AssetsManager to load HDR cube textures
  55792. */
  55793. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55794. /**
  55795. * Defines the name of the task
  55796. */
  55797. name: string;
  55798. /**
  55799. * Defines the location of the file to load
  55800. */
  55801. url: string;
  55802. /**
  55803. * Defines the desired size (the more it increases the longer the generation will be)
  55804. */
  55805. size: number;
  55806. /**
  55807. * Defines if mipmaps should not be generated (default is false)
  55808. */
  55809. noMipmap: boolean;
  55810. /**
  55811. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55812. */
  55813. generateHarmonics: boolean;
  55814. /**
  55815. * 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)
  55816. */
  55817. gammaSpace: boolean;
  55818. /**
  55819. * Internal Use Only
  55820. */
  55821. reserved: boolean;
  55822. /**
  55823. * Gets the loaded texture
  55824. */
  55825. texture: HDRCubeTexture;
  55826. /**
  55827. * Callback called when the task is successful
  55828. */
  55829. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55830. /**
  55831. * Callback called when the task is successful
  55832. */
  55833. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55834. /**
  55835. * Creates a new HDRCubeTextureAssetTask object
  55836. * @param name defines the name of the task
  55837. * @param url defines the location of the file to load
  55838. * @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.
  55839. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55840. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55841. * @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)
  55842. * @param reserved Internal use only
  55843. */
  55844. constructor(
  55845. /**
  55846. * Defines the name of the task
  55847. */
  55848. name: string,
  55849. /**
  55850. * Defines the location of the file to load
  55851. */
  55852. url: string,
  55853. /**
  55854. * Defines the desired size (the more it increases the longer the generation will be)
  55855. */
  55856. size: number,
  55857. /**
  55858. * Defines if mipmaps should not be generated (default is false)
  55859. */
  55860. noMipmap?: boolean,
  55861. /**
  55862. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55863. */
  55864. generateHarmonics?: boolean,
  55865. /**
  55866. * 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)
  55867. */
  55868. gammaSpace?: boolean,
  55869. /**
  55870. * Internal Use Only
  55871. */
  55872. reserved?: boolean);
  55873. /**
  55874. * Execute the current task
  55875. * @param scene defines the scene where you want your assets to be loaded
  55876. * @param onSuccess is a callback called when the task is successfully executed
  55877. * @param onError is a callback called if an error occurs
  55878. */
  55879. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55880. }
  55881. /**
  55882. * This class can be used to easily import assets into a scene
  55883. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55884. */
  55885. export class AssetsManager {
  55886. private _scene;
  55887. private _isLoading;
  55888. protected _tasks: AbstractAssetTask[];
  55889. protected _waitingTasksCount: number;
  55890. protected _totalTasksCount: number;
  55891. /**
  55892. * Callback called when all tasks are processed
  55893. */
  55894. onFinish: (tasks: AbstractAssetTask[]) => void;
  55895. /**
  55896. * Callback called when a task is successful
  55897. */
  55898. onTaskSuccess: (task: AbstractAssetTask) => void;
  55899. /**
  55900. * Callback called when a task had an error
  55901. */
  55902. onTaskError: (task: AbstractAssetTask) => void;
  55903. /**
  55904. * Callback called when a task is done (whatever the result is)
  55905. */
  55906. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55907. /**
  55908. * Observable called when all tasks are processed
  55909. */
  55910. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55911. /**
  55912. * Observable called when a task had an error
  55913. */
  55914. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55915. /**
  55916. * Observable called when a task is successful
  55917. */
  55918. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55919. /**
  55920. * Observable called when a task is done (whatever the result is)
  55921. */
  55922. onProgressObservable: Observable<IAssetsProgressEvent>;
  55923. /**
  55924. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55925. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55926. */
  55927. useDefaultLoadingScreen: boolean;
  55928. /**
  55929. * Creates a new AssetsManager
  55930. * @param scene defines the scene to work on
  55931. */
  55932. constructor(scene: Scene);
  55933. /**
  55934. * Add a MeshAssetTask to the list of active tasks
  55935. * @param taskName defines the name of the new task
  55936. * @param meshesNames defines the name of meshes to load
  55937. * @param rootUrl defines the root url to use to locate files
  55938. * @param sceneFilename defines the filename of the scene file
  55939. * @returns a new MeshAssetTask object
  55940. */
  55941. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55942. /**
  55943. * Add a TextFileAssetTask to the list of active tasks
  55944. * @param taskName defines the name of the new task
  55945. * @param url defines the url of the file to load
  55946. * @returns a new TextFileAssetTask object
  55947. */
  55948. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55949. /**
  55950. * Add a BinaryFileAssetTask to the list of active tasks
  55951. * @param taskName defines the name of the new task
  55952. * @param url defines the url of the file to load
  55953. * @returns a new BinaryFileAssetTask object
  55954. */
  55955. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55956. /**
  55957. * Add a ImageAssetTask to the list of active tasks
  55958. * @param taskName defines the name of the new task
  55959. * @param url defines the url of the file to load
  55960. * @returns a new ImageAssetTask object
  55961. */
  55962. addImageTask(taskName: string, url: string): ImageAssetTask;
  55963. /**
  55964. * Add a TextureAssetTask to the list of active tasks
  55965. * @param taskName defines the name of the new task
  55966. * @param url defines the url of the file to load
  55967. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55968. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55969. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55970. * @returns a new TextureAssetTask object
  55971. */
  55972. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55973. /**
  55974. * Add a CubeTextureAssetTask to the list of active tasks
  55975. * @param taskName defines the name of the new task
  55976. * @param url defines the url of the file to load
  55977. * @param extensions defines the extension to use to load the cube map (can be null)
  55978. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55979. * @param files defines the list of files to load (can be null)
  55980. * @returns a new CubeTextureAssetTask object
  55981. */
  55982. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55983. /**
  55984. *
  55985. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55986. * @param taskName defines the name of the new task
  55987. * @param url defines the url of the file to load
  55988. * @param size defines the size you want for the cubemap (can be null)
  55989. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55990. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55991. * @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)
  55992. * @param reserved Internal use only
  55993. * @returns a new HDRCubeTextureAssetTask object
  55994. */
  55995. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55996. /**
  55997. * Remove a task from the assets manager.
  55998. * @param task the task to remove
  55999. */
  56000. removeTask(task: AbstractAssetTask): void;
  56001. private _decreaseWaitingTasksCount;
  56002. private _runTask;
  56003. /**
  56004. * Reset the AssetsManager and remove all tasks
  56005. * @return the current instance of the AssetsManager
  56006. */
  56007. reset(): AssetsManager;
  56008. /**
  56009. * Start the loading process
  56010. * @return the current instance of the AssetsManager
  56011. */
  56012. load(): AssetsManager;
  56013. }
  56014. }
  56015. declare module "babylonjs/Misc/deferred" {
  56016. /**
  56017. * Wrapper class for promise with external resolve and reject.
  56018. */
  56019. export class Deferred<T> {
  56020. /**
  56021. * The promise associated with this deferred object.
  56022. */
  56023. readonly promise: Promise<T>;
  56024. private _resolve;
  56025. private _reject;
  56026. /**
  56027. * The resolve method of the promise associated with this deferred object.
  56028. */
  56029. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56030. /**
  56031. * The reject method of the promise associated with this deferred object.
  56032. */
  56033. readonly reject: (reason?: any) => void;
  56034. /**
  56035. * Constructor for this deferred object.
  56036. */
  56037. constructor();
  56038. }
  56039. }
  56040. declare module "babylonjs/Misc/filesInput" {
  56041. import { Engine } from "babylonjs/Engines/engine";
  56042. import { Scene } from "babylonjs/scene";
  56043. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  56044. /**
  56045. * Class used to help managing file picking and drag'n'drop
  56046. */
  56047. export class FilesInput {
  56048. /**
  56049. * List of files ready to be loaded
  56050. */
  56051. static readonly FilesToLoad: {
  56052. [key: string]: File;
  56053. };
  56054. /**
  56055. * Callback called when a file is processed
  56056. */
  56057. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56058. private _engine;
  56059. private _currentScene;
  56060. private _sceneLoadedCallback;
  56061. private _progressCallback;
  56062. private _additionalRenderLoopLogicCallback;
  56063. private _textureLoadingCallback;
  56064. private _startingProcessingFilesCallback;
  56065. private _onReloadCallback;
  56066. private _errorCallback;
  56067. private _elementToMonitor;
  56068. private _sceneFileToLoad;
  56069. private _filesToLoad;
  56070. /**
  56071. * Creates a new FilesInput
  56072. * @param engine defines the rendering engine
  56073. * @param scene defines the hosting scene
  56074. * @param sceneLoadedCallback callback called when scene is loaded
  56075. * @param progressCallback callback called to track progress
  56076. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56077. * @param textureLoadingCallback callback called when a texture is loading
  56078. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56079. * @param onReloadCallback callback called when a reload is requested
  56080. * @param errorCallback callback call if an error occurs
  56081. */
  56082. 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);
  56083. private _dragEnterHandler;
  56084. private _dragOverHandler;
  56085. private _dropHandler;
  56086. /**
  56087. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56088. * @param elementToMonitor defines the DOM element to track
  56089. */
  56090. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56091. /**
  56092. * Release all associated resources
  56093. */
  56094. dispose(): void;
  56095. private renderFunction;
  56096. private drag;
  56097. private drop;
  56098. private _traverseFolder;
  56099. private _processFiles;
  56100. /**
  56101. * Load files from a drop event
  56102. * @param event defines the drop event to use as source
  56103. */
  56104. loadFiles(event: any): void;
  56105. private _processReload;
  56106. /**
  56107. * Reload the current scene from the loaded files
  56108. */
  56109. reload(): void;
  56110. }
  56111. }
  56112. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56113. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56114. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56115. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56116. }
  56117. declare module "babylonjs/Misc/sceneOptimizer" {
  56118. import { Scene, IDisposable } from "babylonjs/scene";
  56119. import { Observable } from "babylonjs/Misc/observable";
  56120. /**
  56121. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56122. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56123. */
  56124. export class SceneOptimization {
  56125. /**
  56126. * Defines the priority of this optimization (0 by default which means first in the list)
  56127. */
  56128. priority: number;
  56129. /**
  56130. * Gets a string describing the action executed by the current optimization
  56131. * @returns description string
  56132. */
  56133. getDescription(): string;
  56134. /**
  56135. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56136. * @param scene defines the current scene where to apply this optimization
  56137. * @param optimizer defines the current optimizer
  56138. * @returns true if everything that can be done was applied
  56139. */
  56140. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56141. /**
  56142. * Creates the SceneOptimization object
  56143. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56144. * @param desc defines the description associated with the optimization
  56145. */
  56146. constructor(
  56147. /**
  56148. * Defines the priority of this optimization (0 by default which means first in the list)
  56149. */
  56150. priority?: number);
  56151. }
  56152. /**
  56153. * Defines an optimization used to reduce the size of render target textures
  56154. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56155. */
  56156. export class TextureOptimization extends SceneOptimization {
  56157. /**
  56158. * Defines the priority of this optimization (0 by default which means first in the list)
  56159. */
  56160. priority: number;
  56161. /**
  56162. * 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
  56163. */
  56164. maximumSize: number;
  56165. /**
  56166. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56167. */
  56168. step: number;
  56169. /**
  56170. * Gets a string describing the action executed by the current optimization
  56171. * @returns description string
  56172. */
  56173. getDescription(): string;
  56174. /**
  56175. * Creates the TextureOptimization object
  56176. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56177. * @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
  56178. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56179. */
  56180. constructor(
  56181. /**
  56182. * Defines the priority of this optimization (0 by default which means first in the list)
  56183. */
  56184. priority?: number,
  56185. /**
  56186. * 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
  56187. */
  56188. maximumSize?: number,
  56189. /**
  56190. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56191. */
  56192. step?: number);
  56193. /**
  56194. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56195. * @param scene defines the current scene where to apply this optimization
  56196. * @param optimizer defines the current optimizer
  56197. * @returns true if everything that can be done was applied
  56198. */
  56199. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56200. }
  56201. /**
  56202. * Defines an optimization used to increase or decrease the rendering resolution
  56203. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56204. */
  56205. export class HardwareScalingOptimization extends SceneOptimization {
  56206. /**
  56207. * Defines the priority of this optimization (0 by default which means first in the list)
  56208. */
  56209. priority: number;
  56210. /**
  56211. * Defines the maximum scale to use (2 by default)
  56212. */
  56213. maximumScale: number;
  56214. /**
  56215. * Defines the step to use between two passes (0.5 by default)
  56216. */
  56217. step: number;
  56218. private _currentScale;
  56219. private _directionOffset;
  56220. /**
  56221. * Gets a string describing the action executed by the current optimization
  56222. * @return description string
  56223. */
  56224. getDescription(): string;
  56225. /**
  56226. * Creates the HardwareScalingOptimization object
  56227. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56228. * @param maximumScale defines the maximum scale to use (2 by default)
  56229. * @param step defines the step to use between two passes (0.5 by default)
  56230. */
  56231. constructor(
  56232. /**
  56233. * Defines the priority of this optimization (0 by default which means first in the list)
  56234. */
  56235. priority?: number,
  56236. /**
  56237. * Defines the maximum scale to use (2 by default)
  56238. */
  56239. maximumScale?: number,
  56240. /**
  56241. * Defines the step to use between two passes (0.5 by default)
  56242. */
  56243. step?: number);
  56244. /**
  56245. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56246. * @param scene defines the current scene where to apply this optimization
  56247. * @param optimizer defines the current optimizer
  56248. * @returns true if everything that can be done was applied
  56249. */
  56250. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56251. }
  56252. /**
  56253. * Defines an optimization used to remove shadows
  56254. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56255. */
  56256. export class ShadowsOptimization extends SceneOptimization {
  56257. /**
  56258. * Gets a string describing the action executed by the current optimization
  56259. * @return description string
  56260. */
  56261. getDescription(): string;
  56262. /**
  56263. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56264. * @param scene defines the current scene where to apply this optimization
  56265. * @param optimizer defines the current optimizer
  56266. * @returns true if everything that can be done was applied
  56267. */
  56268. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56269. }
  56270. /**
  56271. * Defines an optimization used to turn post-processes off
  56272. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56273. */
  56274. export class PostProcessesOptimization extends SceneOptimization {
  56275. /**
  56276. * Gets a string describing the action executed by the current optimization
  56277. * @return description string
  56278. */
  56279. getDescription(): string;
  56280. /**
  56281. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56282. * @param scene defines the current scene where to apply this optimization
  56283. * @param optimizer defines the current optimizer
  56284. * @returns true if everything that can be done was applied
  56285. */
  56286. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56287. }
  56288. /**
  56289. * Defines an optimization used to turn lens flares off
  56290. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56291. */
  56292. export class LensFlaresOptimization extends SceneOptimization {
  56293. /**
  56294. * Gets a string describing the action executed by the current optimization
  56295. * @return description string
  56296. */
  56297. getDescription(): string;
  56298. /**
  56299. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56300. * @param scene defines the current scene where to apply this optimization
  56301. * @param optimizer defines the current optimizer
  56302. * @returns true if everything that can be done was applied
  56303. */
  56304. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56305. }
  56306. /**
  56307. * Defines an optimization based on user defined callback.
  56308. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56309. */
  56310. export class CustomOptimization extends SceneOptimization {
  56311. /**
  56312. * Callback called to apply the custom optimization.
  56313. */
  56314. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56315. /**
  56316. * Callback called to get custom description
  56317. */
  56318. onGetDescription: () => string;
  56319. /**
  56320. * Gets a string describing the action executed by the current optimization
  56321. * @returns description string
  56322. */
  56323. getDescription(): string;
  56324. /**
  56325. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56326. * @param scene defines the current scene where to apply this optimization
  56327. * @param optimizer defines the current optimizer
  56328. * @returns true if everything that can be done was applied
  56329. */
  56330. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56331. }
  56332. /**
  56333. * Defines an optimization used to turn particles off
  56334. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56335. */
  56336. export class ParticlesOptimization extends SceneOptimization {
  56337. /**
  56338. * Gets a string describing the action executed by the current optimization
  56339. * @return description string
  56340. */
  56341. getDescription(): string;
  56342. /**
  56343. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56344. * @param scene defines the current scene where to apply this optimization
  56345. * @param optimizer defines the current optimizer
  56346. * @returns true if everything that can be done was applied
  56347. */
  56348. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56349. }
  56350. /**
  56351. * Defines an optimization used to turn render targets off
  56352. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56353. */
  56354. export class RenderTargetsOptimization extends SceneOptimization {
  56355. /**
  56356. * Gets a string describing the action executed by the current optimization
  56357. * @return description string
  56358. */
  56359. getDescription(): string;
  56360. /**
  56361. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56362. * @param scene defines the current scene where to apply this optimization
  56363. * @param optimizer defines the current optimizer
  56364. * @returns true if everything that can be done was applied
  56365. */
  56366. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56367. }
  56368. /**
  56369. * Defines an optimization used to merge meshes with compatible materials
  56370. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56371. */
  56372. export class MergeMeshesOptimization extends SceneOptimization {
  56373. private static _UpdateSelectionTree;
  56374. /**
  56375. * Gets or sets a boolean which defines if optimization octree has to be updated
  56376. */
  56377. /**
  56378. * Gets or sets a boolean which defines if optimization octree has to be updated
  56379. */
  56380. static UpdateSelectionTree: boolean;
  56381. /**
  56382. * Gets a string describing the action executed by the current optimization
  56383. * @return description string
  56384. */
  56385. getDescription(): string;
  56386. private _canBeMerged;
  56387. /**
  56388. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56389. * @param scene defines the current scene where to apply this optimization
  56390. * @param optimizer defines the current optimizer
  56391. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56392. * @returns true if everything that can be done was applied
  56393. */
  56394. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56395. }
  56396. /**
  56397. * Defines a list of options used by SceneOptimizer
  56398. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56399. */
  56400. export class SceneOptimizerOptions {
  56401. /**
  56402. * Defines the target frame rate to reach (60 by default)
  56403. */
  56404. targetFrameRate: number;
  56405. /**
  56406. * Defines the interval between two checkes (2000ms by default)
  56407. */
  56408. trackerDuration: number;
  56409. /**
  56410. * Gets the list of optimizations to apply
  56411. */
  56412. optimizations: SceneOptimization[];
  56413. /**
  56414. * Creates a new list of options used by SceneOptimizer
  56415. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56416. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56417. */
  56418. constructor(
  56419. /**
  56420. * Defines the target frame rate to reach (60 by default)
  56421. */
  56422. targetFrameRate?: number,
  56423. /**
  56424. * Defines the interval between two checkes (2000ms by default)
  56425. */
  56426. trackerDuration?: number);
  56427. /**
  56428. * Add a new optimization
  56429. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56430. * @returns the current SceneOptimizerOptions
  56431. */
  56432. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56433. /**
  56434. * Add a new custom optimization
  56435. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56436. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56437. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56438. * @returns the current SceneOptimizerOptions
  56439. */
  56440. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56441. /**
  56442. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56443. * @param targetFrameRate defines the target frame rate (60 by default)
  56444. * @returns a SceneOptimizerOptions object
  56445. */
  56446. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56447. /**
  56448. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56449. * @param targetFrameRate defines the target frame rate (60 by default)
  56450. * @returns a SceneOptimizerOptions object
  56451. */
  56452. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56453. /**
  56454. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56455. * @param targetFrameRate defines the target frame rate (60 by default)
  56456. * @returns a SceneOptimizerOptions object
  56457. */
  56458. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56459. }
  56460. /**
  56461. * Class used to run optimizations in order to reach a target frame rate
  56462. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56463. */
  56464. export class SceneOptimizer implements IDisposable {
  56465. private _isRunning;
  56466. private _options;
  56467. private _scene;
  56468. private _currentPriorityLevel;
  56469. private _targetFrameRate;
  56470. private _trackerDuration;
  56471. private _currentFrameRate;
  56472. private _sceneDisposeObserver;
  56473. private _improvementMode;
  56474. /**
  56475. * Defines an observable called when the optimizer reaches the target frame rate
  56476. */
  56477. onSuccessObservable: Observable<SceneOptimizer>;
  56478. /**
  56479. * Defines an observable called when the optimizer enables an optimization
  56480. */
  56481. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56482. /**
  56483. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56484. */
  56485. onFailureObservable: Observable<SceneOptimizer>;
  56486. /**
  56487. * Gets a boolean indicating if the optimizer is in improvement mode
  56488. */
  56489. readonly isInImprovementMode: boolean;
  56490. /**
  56491. * Gets the current priority level (0 at start)
  56492. */
  56493. readonly currentPriorityLevel: number;
  56494. /**
  56495. * Gets the current frame rate checked by the SceneOptimizer
  56496. */
  56497. readonly currentFrameRate: number;
  56498. /**
  56499. * Gets or sets the current target frame rate (60 by default)
  56500. */
  56501. /**
  56502. * Gets or sets the current target frame rate (60 by default)
  56503. */
  56504. targetFrameRate: number;
  56505. /**
  56506. * Gets or sets the current interval between two checks (every 2000ms by default)
  56507. */
  56508. /**
  56509. * Gets or sets the current interval between two checks (every 2000ms by default)
  56510. */
  56511. trackerDuration: number;
  56512. /**
  56513. * Gets the list of active optimizations
  56514. */
  56515. readonly optimizations: SceneOptimization[];
  56516. /**
  56517. * Creates a new SceneOptimizer
  56518. * @param scene defines the scene to work on
  56519. * @param options defines the options to use with the SceneOptimizer
  56520. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56521. * @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)
  56522. */
  56523. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56524. /**
  56525. * Stops the current optimizer
  56526. */
  56527. stop(): void;
  56528. /**
  56529. * Reset the optimizer to initial step (current priority level = 0)
  56530. */
  56531. reset(): void;
  56532. /**
  56533. * Start the optimizer. By default it will try to reach a specific framerate
  56534. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56535. */
  56536. start(): void;
  56537. private _checkCurrentState;
  56538. /**
  56539. * Release all resources
  56540. */
  56541. dispose(): void;
  56542. /**
  56543. * Helper function to create a SceneOptimizer with one single line of code
  56544. * @param scene defines the scene to work on
  56545. * @param options defines the options to use with the SceneOptimizer
  56546. * @param onSuccess defines a callback to call on success
  56547. * @param onFailure defines a callback to call on failure
  56548. * @returns the new SceneOptimizer object
  56549. */
  56550. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56551. }
  56552. }
  56553. declare module "babylonjs/Misc/sceneSerializer" {
  56554. import { Scene } from "babylonjs/scene";
  56555. /**
  56556. * Class used to serialize a scene into a string
  56557. */
  56558. export class SceneSerializer {
  56559. /**
  56560. * Clear cache used by a previous serialization
  56561. */
  56562. static ClearCache(): void;
  56563. /**
  56564. * Serialize a scene into a JSON compatible object
  56565. * @param scene defines the scene to serialize
  56566. * @returns a JSON compatible object
  56567. */
  56568. static Serialize(scene: Scene): any;
  56569. /**
  56570. * Serialize a mesh into a JSON compatible object
  56571. * @param toSerialize defines the mesh to serialize
  56572. * @param withParents defines if parents must be serialized as well
  56573. * @param withChildren defines if children must be serialized as well
  56574. * @returns a JSON compatible object
  56575. */
  56576. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56577. }
  56578. }
  56579. declare module "babylonjs/Misc/videoRecorder" {
  56580. import { Nullable } from "babylonjs/types";
  56581. import { Engine } from "babylonjs/Engines/engine";
  56582. /**
  56583. * This represents the different options avilable for the video capture.
  56584. */
  56585. export interface VideoRecorderOptions {
  56586. /** Defines the mime type of the video */
  56587. mimeType: string;
  56588. /** Defines the video the video should be recorded at */
  56589. fps: number;
  56590. /** Defines the chunk size for the recording data */
  56591. recordChunckSize: number;
  56592. /** The audio tracks to attach to the record */
  56593. audioTracks?: MediaStreamTrack[];
  56594. }
  56595. /**
  56596. * This can helps recording videos from BabylonJS.
  56597. * This is based on the available WebRTC functionalities of the browser.
  56598. *
  56599. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56600. */
  56601. export class VideoRecorder {
  56602. private static readonly _defaultOptions;
  56603. /**
  56604. * Returns wehther or not the VideoRecorder is available in your browser.
  56605. * @param engine Defines the Babylon Engine to check the support for
  56606. * @returns true if supported otherwise false
  56607. */
  56608. static IsSupported(engine: Engine): boolean;
  56609. private readonly _options;
  56610. private _canvas;
  56611. private _mediaRecorder;
  56612. private _recordedChunks;
  56613. private _fileName;
  56614. private _resolve;
  56615. private _reject;
  56616. /**
  56617. * True wether a recording is already in progress.
  56618. */
  56619. readonly isRecording: boolean;
  56620. /**
  56621. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56622. * a video file.
  56623. * @param engine Defines the BabylonJS Engine you wish to record
  56624. * @param options Defines options that can be used to customized the capture
  56625. */
  56626. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56627. /**
  56628. * Stops the current recording before the default capture timeout passed in the startRecording
  56629. * functions.
  56630. */
  56631. stopRecording(): void;
  56632. /**
  56633. * Starts recording the canvas for a max duration specified in parameters.
  56634. * @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.
  56635. * @param maxDuration Defines the maximum recording time in seconds.
  56636. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56637. * @return a promise callback at the end of the recording with the video data in Blob.
  56638. */
  56639. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56640. /**
  56641. * Releases internal resources used during the recording.
  56642. */
  56643. dispose(): void;
  56644. private _handleDataAvailable;
  56645. private _handleError;
  56646. private _handleStop;
  56647. }
  56648. }
  56649. declare module "babylonjs/Misc/workerPool" {
  56650. import { IDisposable } from "babylonjs/scene";
  56651. /**
  56652. * Helper class to push actions to a pool of workers.
  56653. */
  56654. export class WorkerPool implements IDisposable {
  56655. private _workerInfos;
  56656. private _pendingActions;
  56657. /**
  56658. * Constructor
  56659. * @param workers Array of workers to use for actions
  56660. */
  56661. constructor(workers: Array<Worker>);
  56662. /**
  56663. * Terminates all workers and clears any pending actions.
  56664. */
  56665. dispose(): void;
  56666. /**
  56667. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56668. * pended until a worker has completed its action.
  56669. * @param action The action to perform. Call onComplete when the action is complete.
  56670. */
  56671. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56672. private _execute;
  56673. }
  56674. }
  56675. declare module "babylonjs/Misc/screenshotTools" {
  56676. import { Camera } from "babylonjs/Cameras/camera";
  56677. import { Engine } from "babylonjs/Engines/engine";
  56678. /**
  56679. * Class containing a set of static utilities functions for screenshots
  56680. */
  56681. export class ScreenshotTools {
  56682. /**
  56683. * Captures a screenshot of the current rendering
  56684. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56685. * @param engine defines the rendering engine
  56686. * @param camera defines the source camera
  56687. * @param size This parameter can be set to a single number or to an object with the
  56688. * following (optional) properties: precision, width, height. If a single number is passed,
  56689. * it will be used for both width and height. If an object is passed, the screenshot size
  56690. * will be derived from the parameters. The precision property is a multiplier allowing
  56691. * rendering at a higher or lower resolution
  56692. * @param successCallback defines the callback receives a single parameter which contains the
  56693. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56694. * src parameter of an <img> to display it
  56695. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56696. * Check your browser for supported MIME types
  56697. */
  56698. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56699. /**
  56700. * Generates an image screenshot from the specified camera.
  56701. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56702. * @param engine The engine to use for rendering
  56703. * @param camera The camera to use for rendering
  56704. * @param size This parameter can be set to a single number or to an object with the
  56705. * following (optional) properties: precision, width, height. If a single number is passed,
  56706. * it will be used for both width and height. If an object is passed, the screenshot size
  56707. * will be derived from the parameters. The precision property is a multiplier allowing
  56708. * rendering at a higher or lower resolution
  56709. * @param successCallback The callback receives a single parameter which contains the
  56710. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56711. * src parameter of an <img> to display it
  56712. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56713. * Check your browser for supported MIME types
  56714. * @param samples Texture samples (default: 1)
  56715. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56716. * @param fileName A name for for the downloaded file.
  56717. */
  56718. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56719. }
  56720. }
  56721. declare module "babylonjs/Misc/index" {
  56722. export * from "babylonjs/Misc/andOrNotEvaluator";
  56723. export * from "babylonjs/Misc/assetsManager";
  56724. export * from "babylonjs/Misc/dds";
  56725. export * from "babylonjs/Misc/decorators";
  56726. export * from "babylonjs/Misc/deferred";
  56727. export * from "babylonjs/Misc/environmentTextureTools";
  56728. export * from "babylonjs/Misc/filesInput";
  56729. export * from "babylonjs/Misc/HighDynamicRange/index";
  56730. export * from "babylonjs/Misc/khronosTextureContainer";
  56731. export * from "babylonjs/Misc/observable";
  56732. export * from "babylonjs/Misc/performanceMonitor";
  56733. export * from "babylonjs/Misc/promise";
  56734. export * from "babylonjs/Misc/sceneOptimizer";
  56735. export * from "babylonjs/Misc/sceneSerializer";
  56736. export * from "babylonjs/Misc/smartArray";
  56737. export * from "babylonjs/Misc/stringDictionary";
  56738. export * from "babylonjs/Misc/tags";
  56739. export * from "babylonjs/Misc/textureTools";
  56740. export * from "babylonjs/Misc/tga";
  56741. export * from "babylonjs/Misc/tools";
  56742. export * from "babylonjs/Misc/videoRecorder";
  56743. export * from "babylonjs/Misc/virtualJoystick";
  56744. export * from "babylonjs/Misc/workerPool";
  56745. export * from "babylonjs/Misc/logger";
  56746. export * from "babylonjs/Misc/typeStore";
  56747. export * from "babylonjs/Misc/filesInputStore";
  56748. export * from "babylonjs/Misc/deepCopier";
  56749. export * from "babylonjs/Misc/pivotTools";
  56750. export * from "babylonjs/Misc/precisionDate";
  56751. export * from "babylonjs/Misc/screenshotTools";
  56752. export * from "babylonjs/Misc/typeStore";
  56753. }
  56754. declare module "babylonjs/index" {
  56755. export * from "babylonjs/abstractScene";
  56756. export * from "babylonjs/Actions/index";
  56757. export * from "babylonjs/Animations/index";
  56758. export * from "babylonjs/assetContainer";
  56759. export * from "babylonjs/Audio/index";
  56760. export * from "babylonjs/Behaviors/index";
  56761. export * from "babylonjs/Bones/index";
  56762. export * from "babylonjs/Cameras/index";
  56763. export * from "babylonjs/Collisions/index";
  56764. export * from "babylonjs/Culling/index";
  56765. export * from "babylonjs/Debug/index";
  56766. export * from "babylonjs/Engines/index";
  56767. export * from "babylonjs/Events/index";
  56768. export * from "babylonjs/Gamepads/index";
  56769. export * from "babylonjs/Gizmos/index";
  56770. export * from "babylonjs/Helpers/index";
  56771. export * from "babylonjs/Instrumentation/index";
  56772. export * from "babylonjs/Layers/index";
  56773. export * from "babylonjs/LensFlares/index";
  56774. export * from "babylonjs/Lights/index";
  56775. export * from "babylonjs/Loading/index";
  56776. export * from "babylonjs/Materials/index";
  56777. export * from "babylonjs/Maths/index";
  56778. export * from "babylonjs/Meshes/index";
  56779. export * from "babylonjs/Morph/index";
  56780. export * from "babylonjs/node";
  56781. export * from "babylonjs/Offline/index";
  56782. export * from "babylonjs/Particles/index";
  56783. export * from "babylonjs/Physics/index";
  56784. export * from "babylonjs/PostProcesses/index";
  56785. export * from "babylonjs/Probes/index";
  56786. export * from "babylonjs/Rendering/index";
  56787. export * from "babylonjs/scene";
  56788. export * from "babylonjs/sceneComponent";
  56789. export * from "babylonjs/Sprites/index";
  56790. export * from "babylonjs/States/index";
  56791. export * from "babylonjs/Misc/index";
  56792. export * from "babylonjs/types";
  56793. }
  56794. declare module "babylonjs/Animations/pathCursor" {
  56795. import { Path2, Vector3 } from "babylonjs/Maths/math";
  56796. /**
  56797. * A cursor which tracks a point on a path
  56798. */
  56799. export class PathCursor {
  56800. private path;
  56801. /**
  56802. * Stores path cursor callbacks for when an onchange event is triggered
  56803. */
  56804. private _onchange;
  56805. /**
  56806. * The value of the path cursor
  56807. */
  56808. value: number;
  56809. /**
  56810. * The animation array of the path cursor
  56811. */
  56812. animations: Animation[];
  56813. /**
  56814. * Initializes the path cursor
  56815. * @param path The path to track
  56816. */
  56817. constructor(path: Path2);
  56818. /**
  56819. * Gets the cursor point on the path
  56820. * @returns A point on the path cursor at the cursor location
  56821. */
  56822. getPoint(): Vector3;
  56823. /**
  56824. * Moves the cursor ahead by the step amount
  56825. * @param step The amount to move the cursor forward
  56826. * @returns This path cursor
  56827. */
  56828. moveAhead(step?: number): PathCursor;
  56829. /**
  56830. * Moves the cursor behind by the step amount
  56831. * @param step The amount to move the cursor back
  56832. * @returns This path cursor
  56833. */
  56834. moveBack(step?: number): PathCursor;
  56835. /**
  56836. * Moves the cursor by the step amount
  56837. * If the step amount is greater than one, an exception is thrown
  56838. * @param step The amount to move the cursor
  56839. * @returns This path cursor
  56840. */
  56841. move(step: number): PathCursor;
  56842. /**
  56843. * Ensures that the value is limited between zero and one
  56844. * @returns This path cursor
  56845. */
  56846. private ensureLimits;
  56847. /**
  56848. * Runs onchange callbacks on change (used by the animation engine)
  56849. * @returns This path cursor
  56850. */
  56851. private raiseOnChange;
  56852. /**
  56853. * Executes a function on change
  56854. * @param f A path cursor onchange callback
  56855. * @returns This path cursor
  56856. */
  56857. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56858. }
  56859. }
  56860. declare module "babylonjs/Legacy/legacy" {
  56861. import * as Babylon from "babylonjs/index";
  56862. export * from "babylonjs/index";
  56863. }
  56864. declare module "babylonjs/Shaders/blur.fragment" {
  56865. /** @hidden */
  56866. export var blurPixelShader: {
  56867. name: string;
  56868. shader: string;
  56869. };
  56870. }
  56871. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  56872. /** @hidden */
  56873. export var bones300Declaration: {
  56874. name: string;
  56875. shader: string;
  56876. };
  56877. }
  56878. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  56879. /** @hidden */
  56880. export var instances300Declaration: {
  56881. name: string;
  56882. shader: string;
  56883. };
  56884. }
  56885. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  56886. /** @hidden */
  56887. export var pointCloudVertexDeclaration: {
  56888. name: string;
  56889. shader: string;
  56890. };
  56891. }
  56892. // Mixins
  56893. interface Window {
  56894. mozIndexedDB: IDBFactory;
  56895. webkitIndexedDB: IDBFactory;
  56896. msIndexedDB: IDBFactory;
  56897. webkitURL: typeof URL;
  56898. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56899. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56900. WebGLRenderingContext: WebGLRenderingContext;
  56901. MSGesture: MSGesture;
  56902. CANNON: any;
  56903. AudioContext: AudioContext;
  56904. webkitAudioContext: AudioContext;
  56905. PointerEvent: any;
  56906. Math: Math;
  56907. Uint8Array: Uint8ArrayConstructor;
  56908. Float32Array: Float32ArrayConstructor;
  56909. mozURL: typeof URL;
  56910. msURL: typeof URL;
  56911. VRFrameData: any; // WebVR, from specs 1.1
  56912. DracoDecoderModule: any;
  56913. setImmediate(handler: (...args: any[]) => void): number;
  56914. }
  56915. interface Document {
  56916. mozCancelFullScreen(): void;
  56917. msCancelFullScreen(): void;
  56918. webkitCancelFullScreen(): void;
  56919. requestPointerLock(): void;
  56920. exitPointerLock(): void;
  56921. mozFullScreen: boolean;
  56922. msIsFullScreen: boolean;
  56923. readonly webkitIsFullScreen: boolean;
  56924. readonly pointerLockElement: Element;
  56925. mozPointerLockElement: HTMLElement;
  56926. msPointerLockElement: HTMLElement;
  56927. webkitPointerLockElement: HTMLElement;
  56928. }
  56929. interface HTMLCanvasElement {
  56930. requestPointerLock(): void;
  56931. msRequestPointerLock?(): void;
  56932. mozRequestPointerLock?(): void;
  56933. webkitRequestPointerLock?(): void;
  56934. /** Track wether a record is in progress */
  56935. isRecording: boolean;
  56936. /** Capture Stream method defined by some browsers */
  56937. captureStream(fps?: number): MediaStream;
  56938. }
  56939. interface CanvasRenderingContext2D {
  56940. msImageSmoothingEnabled: boolean;
  56941. }
  56942. interface MouseEvent {
  56943. mozMovementX: number;
  56944. mozMovementY: number;
  56945. webkitMovementX: number;
  56946. webkitMovementY: number;
  56947. msMovementX: number;
  56948. msMovementY: number;
  56949. }
  56950. interface Navigator {
  56951. mozGetVRDevices: (any: any) => any;
  56952. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56953. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56954. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56955. webkitGetGamepads(): Gamepad[];
  56956. msGetGamepads(): Gamepad[];
  56957. webkitGamepads(): Gamepad[];
  56958. }
  56959. interface HTMLVideoElement {
  56960. mozSrcObject: any;
  56961. }
  56962. interface Math {
  56963. fround(x: number): number;
  56964. imul(a: number, b: number): number;
  56965. }
  56966. interface WebGLProgram {
  56967. context?: WebGLRenderingContext;
  56968. vertexShader?: WebGLShader;
  56969. fragmentShader?: WebGLShader;
  56970. isParallelCompiled: boolean;
  56971. onCompiled?: () => void;
  56972. }
  56973. interface WebGLRenderingContext {
  56974. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56975. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56976. vertexAttribDivisor(index: number, divisor: number): void;
  56977. createVertexArray(): any;
  56978. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56979. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56980. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56981. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56982. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56983. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56984. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56985. // Queries
  56986. createQuery(): WebGLQuery;
  56987. deleteQuery(query: WebGLQuery): void;
  56988. beginQuery(target: number, query: WebGLQuery): void;
  56989. endQuery(target: number): void;
  56990. getQueryParameter(query: WebGLQuery, pname: number): any;
  56991. getQuery(target: number, pname: number): any;
  56992. MAX_SAMPLES: number;
  56993. RGBA8: number;
  56994. READ_FRAMEBUFFER: number;
  56995. DRAW_FRAMEBUFFER: number;
  56996. UNIFORM_BUFFER: number;
  56997. HALF_FLOAT_OES: number;
  56998. RGBA16F: number;
  56999. RGBA32F: number;
  57000. R32F: number;
  57001. RG32F: number;
  57002. RGB32F: number;
  57003. R16F: number;
  57004. RG16F: number;
  57005. RGB16F: number;
  57006. RED: number;
  57007. RG: number;
  57008. R8: number;
  57009. RG8: number;
  57010. UNSIGNED_INT_24_8: number;
  57011. DEPTH24_STENCIL8: number;
  57012. /* Multiple Render Targets */
  57013. drawBuffers(buffers: number[]): void;
  57014. readBuffer(src: number): void;
  57015. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57016. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57017. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57018. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57019. // Occlusion Query
  57020. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57021. ANY_SAMPLES_PASSED: number;
  57022. QUERY_RESULT_AVAILABLE: number;
  57023. QUERY_RESULT: number;
  57024. }
  57025. interface WebGLBuffer {
  57026. references: number;
  57027. capacity: number;
  57028. is32Bits: boolean;
  57029. }
  57030. interface WebGLProgram {
  57031. transformFeedback?: WebGLTransformFeedback | null;
  57032. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57033. }
  57034. interface EXT_disjoint_timer_query {
  57035. QUERY_COUNTER_BITS_EXT: number;
  57036. TIME_ELAPSED_EXT: number;
  57037. TIMESTAMP_EXT: number;
  57038. GPU_DISJOINT_EXT: number;
  57039. QUERY_RESULT_EXT: number;
  57040. QUERY_RESULT_AVAILABLE_EXT: number;
  57041. queryCounterEXT(query: WebGLQuery, target: number): void;
  57042. createQueryEXT(): WebGLQuery;
  57043. beginQueryEXT(target: number, query: WebGLQuery): void;
  57044. endQueryEXT(target: number): void;
  57045. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57046. deleteQueryEXT(query: WebGLQuery): void;
  57047. }
  57048. interface WebGLUniformLocation {
  57049. _currentState: any;
  57050. }
  57051. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57052. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57053. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57054. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57055. interface WebGLRenderingContext {
  57056. readonly RASTERIZER_DISCARD: number;
  57057. readonly DEPTH_COMPONENT24: number;
  57058. readonly TEXTURE_3D: number;
  57059. readonly TEXTURE_2D_ARRAY: number;
  57060. readonly TEXTURE_COMPARE_FUNC: number;
  57061. readonly TEXTURE_COMPARE_MODE: number;
  57062. readonly COMPARE_REF_TO_TEXTURE: number;
  57063. readonly TEXTURE_WRAP_R: number;
  57064. readonly HALF_FLOAT: number;
  57065. readonly RGB8: number;
  57066. readonly RED_INTEGER: number;
  57067. readonly RG_INTEGER: number;
  57068. readonly RGB_INTEGER: number;
  57069. readonly RGBA_INTEGER: number;
  57070. readonly R8_SNORM: number;
  57071. readonly RG8_SNORM: number;
  57072. readonly RGB8_SNORM: number;
  57073. readonly RGBA8_SNORM: number;
  57074. readonly R8I: number;
  57075. readonly RG8I: number;
  57076. readonly RGB8I: number;
  57077. readonly RGBA8I: number;
  57078. readonly R8UI: number;
  57079. readonly RG8UI: number;
  57080. readonly RGB8UI: number;
  57081. readonly RGBA8UI: number;
  57082. readonly R16I: number;
  57083. readonly RG16I: number;
  57084. readonly RGB16I: number;
  57085. readonly RGBA16I: number;
  57086. readonly R16UI: number;
  57087. readonly RG16UI: number;
  57088. readonly RGB16UI: number;
  57089. readonly RGBA16UI: number;
  57090. readonly R32I: number;
  57091. readonly RG32I: number;
  57092. readonly RGB32I: number;
  57093. readonly RGBA32I: number;
  57094. readonly R32UI: number;
  57095. readonly RG32UI: number;
  57096. readonly RGB32UI: number;
  57097. readonly RGBA32UI: number;
  57098. readonly RGB10_A2UI: number;
  57099. readonly R11F_G11F_B10F: number;
  57100. readonly RGB9_E5: number;
  57101. readonly RGB10_A2: number;
  57102. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57103. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57104. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57105. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57106. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57107. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57108. 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;
  57109. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57110. readonly TRANSFORM_FEEDBACK: number;
  57111. readonly INTERLEAVED_ATTRIBS: number;
  57112. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57113. createTransformFeedback(): WebGLTransformFeedback;
  57114. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57115. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57116. beginTransformFeedback(primitiveMode: number): void;
  57117. endTransformFeedback(): void;
  57118. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57119. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57120. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57121. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57122. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57123. }
  57124. interface ImageBitmap {
  57125. readonly width: number;
  57126. readonly height: number;
  57127. close(): void;
  57128. }
  57129. interface WebGLQuery extends WebGLObject {
  57130. }
  57131. declare var WebGLQuery: {
  57132. prototype: WebGLQuery;
  57133. new(): WebGLQuery;
  57134. };
  57135. interface WebGLSampler extends WebGLObject {
  57136. }
  57137. declare var WebGLSampler: {
  57138. prototype: WebGLSampler;
  57139. new(): WebGLSampler;
  57140. };
  57141. interface WebGLSync extends WebGLObject {
  57142. }
  57143. declare var WebGLSync: {
  57144. prototype: WebGLSync;
  57145. new(): WebGLSync;
  57146. };
  57147. interface WebGLTransformFeedback extends WebGLObject {
  57148. }
  57149. declare var WebGLTransformFeedback: {
  57150. prototype: WebGLTransformFeedback;
  57151. new(): WebGLTransformFeedback;
  57152. };
  57153. interface WebGLVertexArrayObject extends WebGLObject {
  57154. }
  57155. declare var WebGLVertexArrayObject: {
  57156. prototype: WebGLVertexArrayObject;
  57157. new(): WebGLVertexArrayObject;
  57158. };
  57159. // Type definitions for WebVR API
  57160. // Project: https://w3c.github.io/webvr/
  57161. // Definitions by: six a <https://github.com/lostfictions>
  57162. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57163. interface VRDisplay extends EventTarget {
  57164. /**
  57165. * Dictionary of capabilities describing the VRDisplay.
  57166. */
  57167. readonly capabilities: VRDisplayCapabilities;
  57168. /**
  57169. * z-depth defining the far plane of the eye view frustum
  57170. * enables mapping of values in the render target depth
  57171. * attachment to scene coordinates. Initially set to 10000.0.
  57172. */
  57173. depthFar: number;
  57174. /**
  57175. * z-depth defining the near plane of the eye view frustum
  57176. * enables mapping of values in the render target depth
  57177. * attachment to scene coordinates. Initially set to 0.01.
  57178. */
  57179. depthNear: number;
  57180. /**
  57181. * An identifier for this distinct VRDisplay. Used as an
  57182. * association point in the Gamepad API.
  57183. */
  57184. readonly displayId: number;
  57185. /**
  57186. * A display name, a user-readable name identifying it.
  57187. */
  57188. readonly displayName: string;
  57189. readonly isConnected: boolean;
  57190. readonly isPresenting: boolean;
  57191. /**
  57192. * If this VRDisplay supports room-scale experiences, the optional
  57193. * stage attribute contains details on the room-scale parameters.
  57194. */
  57195. readonly stageParameters: VRStageParameters | null;
  57196. /**
  57197. * Passing the value returned by `requestAnimationFrame` to
  57198. * `cancelAnimationFrame` will unregister the callback.
  57199. * @param handle Define the hanle of the request to cancel
  57200. */
  57201. cancelAnimationFrame(handle: number): void;
  57202. /**
  57203. * Stops presenting to the VRDisplay.
  57204. * @returns a promise to know when it stopped
  57205. */
  57206. exitPresent(): Promise<void>;
  57207. /**
  57208. * Return the current VREyeParameters for the given eye.
  57209. * @param whichEye Define the eye we want the parameter for
  57210. * @returns the eye parameters
  57211. */
  57212. getEyeParameters(whichEye: string): VREyeParameters;
  57213. /**
  57214. * Populates the passed VRFrameData with the information required to render
  57215. * the current frame.
  57216. * @param frameData Define the data structure to populate
  57217. * @returns true if ok otherwise false
  57218. */
  57219. getFrameData(frameData: VRFrameData): boolean;
  57220. /**
  57221. * Get the layers currently being presented.
  57222. * @returns the list of VR layers
  57223. */
  57224. getLayers(): VRLayer[];
  57225. /**
  57226. * Return a VRPose containing the future predicted pose of the VRDisplay
  57227. * when the current frame will be presented. The value returned will not
  57228. * change until JavaScript has returned control to the browser.
  57229. *
  57230. * The VRPose will contain the position, orientation, velocity,
  57231. * and acceleration of each of these properties.
  57232. * @returns the pose object
  57233. */
  57234. getPose(): VRPose;
  57235. /**
  57236. * Return the current instantaneous pose of the VRDisplay, with no
  57237. * prediction applied.
  57238. * @returns the current instantaneous pose
  57239. */
  57240. getImmediatePose(): VRPose;
  57241. /**
  57242. * The callback passed to `requestAnimationFrame` will be called
  57243. * any time a new frame should be rendered. When the VRDisplay is
  57244. * presenting the callback will be called at the native refresh
  57245. * rate of the HMD. When not presenting this function acts
  57246. * identically to how window.requestAnimationFrame acts. Content should
  57247. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57248. * asynchronously from other displays and at differing refresh rates.
  57249. * @param callback Define the eaction to run next frame
  57250. * @returns the request handle it
  57251. */
  57252. requestAnimationFrame(callback: FrameRequestCallback): number;
  57253. /**
  57254. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57255. * Repeat calls while already presenting will update the VRLayers being displayed.
  57256. * @param layers Define the list of layer to present
  57257. * @returns a promise to know when the request has been fulfilled
  57258. */
  57259. requestPresent(layers: VRLayer[]): Promise<void>;
  57260. /**
  57261. * Reset the pose for this display, treating its current position and
  57262. * orientation as the "origin/zero" values. VRPose.position,
  57263. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57264. * updated when calling resetPose(). This should be called in only
  57265. * sitting-space experiences.
  57266. */
  57267. resetPose(): void;
  57268. /**
  57269. * The VRLayer provided to the VRDisplay will be captured and presented
  57270. * in the HMD. Calling this function has the same effect on the source
  57271. * canvas as any other operation that uses its source image, and canvases
  57272. * created without preserveDrawingBuffer set to true will be cleared.
  57273. * @param pose Define the pose to submit
  57274. */
  57275. submitFrame(pose?: VRPose): void;
  57276. }
  57277. declare var VRDisplay: {
  57278. prototype: VRDisplay;
  57279. new(): VRDisplay;
  57280. };
  57281. interface VRLayer {
  57282. leftBounds?: number[] | Float32Array | null;
  57283. rightBounds?: number[] | Float32Array | null;
  57284. source?: HTMLCanvasElement | null;
  57285. }
  57286. interface VRDisplayCapabilities {
  57287. readonly canPresent: boolean;
  57288. readonly hasExternalDisplay: boolean;
  57289. readonly hasOrientation: boolean;
  57290. readonly hasPosition: boolean;
  57291. readonly maxLayers: number;
  57292. }
  57293. interface VREyeParameters {
  57294. /** @deprecated */
  57295. readonly fieldOfView: VRFieldOfView;
  57296. readonly offset: Float32Array;
  57297. readonly renderHeight: number;
  57298. readonly renderWidth: number;
  57299. }
  57300. interface VRFieldOfView {
  57301. readonly downDegrees: number;
  57302. readonly leftDegrees: number;
  57303. readonly rightDegrees: number;
  57304. readonly upDegrees: number;
  57305. }
  57306. interface VRFrameData {
  57307. readonly leftProjectionMatrix: Float32Array;
  57308. readonly leftViewMatrix: Float32Array;
  57309. readonly pose: VRPose;
  57310. readonly rightProjectionMatrix: Float32Array;
  57311. readonly rightViewMatrix: Float32Array;
  57312. readonly timestamp: number;
  57313. }
  57314. interface VRPose {
  57315. readonly angularAcceleration: Float32Array | null;
  57316. readonly angularVelocity: Float32Array | null;
  57317. readonly linearAcceleration: Float32Array | null;
  57318. readonly linearVelocity: Float32Array | null;
  57319. readonly orientation: Float32Array | null;
  57320. readonly position: Float32Array | null;
  57321. readonly timestamp: number;
  57322. }
  57323. interface VRStageParameters {
  57324. sittingToStandingTransform?: Float32Array;
  57325. sizeX?: number;
  57326. sizeY?: number;
  57327. }
  57328. interface Navigator {
  57329. getVRDisplays(): Promise<VRDisplay[]>;
  57330. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57331. }
  57332. interface Window {
  57333. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57334. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57335. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57336. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57337. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57338. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57339. }
  57340. interface Gamepad {
  57341. readonly displayId: number;
  57342. }
  57343. interface XRDevice {
  57344. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57345. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57346. }
  57347. interface XRSession {
  57348. getInputSources(): Array<any>;
  57349. baseLayer: XRWebGLLayer;
  57350. requestFrameOfReference(type: string): Promise<void>;
  57351. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57352. end(): Promise<void>;
  57353. requestAnimationFrame: Function;
  57354. addEventListener: Function;
  57355. }
  57356. interface XRSessionCreationOptions {
  57357. outputContext?: WebGLRenderingContext | null;
  57358. immersive?: boolean;
  57359. environmentIntegration?: boolean;
  57360. }
  57361. interface XRLayer {
  57362. getViewport: Function;
  57363. framebufferWidth: number;
  57364. framebufferHeight: number;
  57365. }
  57366. interface XRView {
  57367. projectionMatrix: Float32Array;
  57368. }
  57369. interface XRFrame {
  57370. getDevicePose: Function;
  57371. getInputPose: Function;
  57372. views: Array<XRView>;
  57373. baseLayer: XRLayer;
  57374. }
  57375. interface XRFrameOfReference {
  57376. }
  57377. interface XRWebGLLayer extends XRLayer {
  57378. framebuffer: WebGLFramebuffer;
  57379. }
  57380. declare var XRWebGLLayer: {
  57381. prototype: XRWebGLLayer;
  57382. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57383. };
  57384. declare module "babylonjs" {
  57385. export * from "babylonjs/Legacy/legacy";
  57386. }
  57387. declare module BABYLON {
  57388. /** Alias type for value that can be null */
  57389. export type Nullable<T> = T | null;
  57390. /**
  57391. * Alias type for number that are floats
  57392. * @ignorenaming
  57393. */
  57394. export type float = number;
  57395. /**
  57396. * Alias type for number that are doubles.
  57397. * @ignorenaming
  57398. */
  57399. export type double = number;
  57400. /**
  57401. * Alias type for number that are integer
  57402. * @ignorenaming
  57403. */
  57404. export type int = number;
  57405. /** Alias type for number array or Float32Array */
  57406. export type FloatArray = number[] | Float32Array;
  57407. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57408. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57409. /**
  57410. * Alias for types that can be used by a Buffer or VertexBuffer.
  57411. */
  57412. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57413. /**
  57414. * Alias type for primitive types
  57415. * @ignorenaming
  57416. */
  57417. type Primitive = undefined | null | boolean | string | number | Function;
  57418. /**
  57419. * Type modifier to make all the properties of an object Readonly
  57420. */
  57421. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57422. /**
  57423. * Type modifier to make all the properties of an object Readonly recursively
  57424. */
  57425. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57426. /** @hidden */
  57427. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57428. }
  57429. /** @hidden */
  57430. /** @hidden */
  57431. type DeepImmutableObject<T> = {
  57432. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57433. };
  57434. }
  57435. declare module BABYLON {
  57436. /**
  57437. * Class containing a set of static utilities functions for arrays.
  57438. */
  57439. export class ArrayTools {
  57440. /**
  57441. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57442. * @param size the number of element to construct and put in the array
  57443. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57444. * @returns a new array filled with new objects
  57445. */
  57446. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57447. }
  57448. }
  57449. declare module BABYLON {
  57450. /**
  57451. * Scalar computation library
  57452. */
  57453. export class Scalar {
  57454. /**
  57455. * Two pi constants convenient for computation.
  57456. */
  57457. static TwoPi: number;
  57458. /**
  57459. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57460. * @param a number
  57461. * @param b number
  57462. * @param epsilon (default = 1.401298E-45)
  57463. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57464. */
  57465. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57466. /**
  57467. * Returns a string : the upper case translation of the number i to hexadecimal.
  57468. * @param i number
  57469. * @returns the upper case translation of the number i to hexadecimal.
  57470. */
  57471. static ToHex(i: number): string;
  57472. /**
  57473. * Returns -1 if value is negative and +1 is value is positive.
  57474. * @param value the value
  57475. * @returns the value itself if it's equal to zero.
  57476. */
  57477. static Sign(value: number): number;
  57478. /**
  57479. * Returns the value itself if it's between min and max.
  57480. * Returns min if the value is lower than min.
  57481. * Returns max if the value is greater than max.
  57482. * @param value the value to clmap
  57483. * @param min the min value to clamp to (default: 0)
  57484. * @param max the max value to clamp to (default: 1)
  57485. * @returns the clamped value
  57486. */
  57487. static Clamp(value: number, min?: number, max?: number): number;
  57488. /**
  57489. * the log2 of value.
  57490. * @param value the value to compute log2 of
  57491. * @returns the log2 of value.
  57492. */
  57493. static Log2(value: number): number;
  57494. /**
  57495. * Loops the value, so that it is never larger than length and never smaller than 0.
  57496. *
  57497. * This is similar to the modulo operator but it works with floating point numbers.
  57498. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57499. * With t = 5 and length = 2.5, the result would be 0.0.
  57500. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57501. * @param value the value
  57502. * @param length the length
  57503. * @returns the looped value
  57504. */
  57505. static Repeat(value: number, length: number): number;
  57506. /**
  57507. * Normalize the value between 0.0 and 1.0 using min and max values
  57508. * @param value value to normalize
  57509. * @param min max to normalize between
  57510. * @param max min to normalize between
  57511. * @returns the normalized value
  57512. */
  57513. static Normalize(value: number, min: number, max: number): number;
  57514. /**
  57515. * Denormalize the value from 0.0 and 1.0 using min and max values
  57516. * @param normalized value to denormalize
  57517. * @param min max to denormalize between
  57518. * @param max min to denormalize between
  57519. * @returns the denormalized value
  57520. */
  57521. static Denormalize(normalized: number, min: number, max: number): number;
  57522. /**
  57523. * Calculates the shortest difference between two given angles given in degrees.
  57524. * @param current current angle in degrees
  57525. * @param target target angle in degrees
  57526. * @returns the delta
  57527. */
  57528. static DeltaAngle(current: number, target: number): number;
  57529. /**
  57530. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57531. * @param tx value
  57532. * @param length length
  57533. * @returns The returned value will move back and forth between 0 and length
  57534. */
  57535. static PingPong(tx: number, length: number): number;
  57536. /**
  57537. * Interpolates between min and max with smoothing at the limits.
  57538. *
  57539. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57540. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57541. * @param from from
  57542. * @param to to
  57543. * @param tx value
  57544. * @returns the smooth stepped value
  57545. */
  57546. static SmoothStep(from: number, to: number, tx: number): number;
  57547. /**
  57548. * Moves a value current towards target.
  57549. *
  57550. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57551. * Negative values of maxDelta pushes the value away from target.
  57552. * @param current current value
  57553. * @param target target value
  57554. * @param maxDelta max distance to move
  57555. * @returns resulting value
  57556. */
  57557. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57558. /**
  57559. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57560. *
  57561. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57562. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57563. * @param current current value
  57564. * @param target target value
  57565. * @param maxDelta max distance to move
  57566. * @returns resulting angle
  57567. */
  57568. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57569. /**
  57570. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57571. * @param start start value
  57572. * @param end target value
  57573. * @param amount amount to lerp between
  57574. * @returns the lerped value
  57575. */
  57576. static Lerp(start: number, end: number, amount: number): number;
  57577. /**
  57578. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57579. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57580. * @param start start value
  57581. * @param end target value
  57582. * @param amount amount to lerp between
  57583. * @returns the lerped value
  57584. */
  57585. static LerpAngle(start: number, end: number, amount: number): number;
  57586. /**
  57587. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57588. * @param a start value
  57589. * @param b target value
  57590. * @param value value between a and b
  57591. * @returns the inverseLerp value
  57592. */
  57593. static InverseLerp(a: number, b: number, value: number): number;
  57594. /**
  57595. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57596. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57597. * @param value1 spline value
  57598. * @param tangent1 spline value
  57599. * @param value2 spline value
  57600. * @param tangent2 spline value
  57601. * @param amount input value
  57602. * @returns hermite result
  57603. */
  57604. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57605. /**
  57606. * Returns a random float number between and min and max values
  57607. * @param min min value of random
  57608. * @param max max value of random
  57609. * @returns random value
  57610. */
  57611. static RandomRange(min: number, max: number): number;
  57612. /**
  57613. * This function returns percentage of a number in a given range.
  57614. *
  57615. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57616. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57617. * @param number to convert to percentage
  57618. * @param min min range
  57619. * @param max max range
  57620. * @returns the percentage
  57621. */
  57622. static RangeToPercent(number: number, min: number, max: number): number;
  57623. /**
  57624. * This function returns number that corresponds to the percentage in a given range.
  57625. *
  57626. * PercentToRange(0.34,0,100) will return 34.
  57627. * @param percent to convert to number
  57628. * @param min min range
  57629. * @param max max range
  57630. * @returns the number
  57631. */
  57632. static PercentToRange(percent: number, min: number, max: number): number;
  57633. /**
  57634. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  57635. * @param angle The angle to normalize in radian.
  57636. * @return The converted angle.
  57637. */
  57638. static NormalizeRadians(angle: number): number;
  57639. }
  57640. }
  57641. declare module BABYLON {
  57642. /**
  57643. * Constant used to convert a value to gamma space
  57644. * @ignorenaming
  57645. */
  57646. export const ToGammaSpace: number;
  57647. /**
  57648. * Constant used to convert a value to linear space
  57649. * @ignorenaming
  57650. */
  57651. export const ToLinearSpace = 2.2;
  57652. /**
  57653. * Constant used to define the minimal number value in Babylon.js
  57654. * @ignorenaming
  57655. */
  57656. export const Epsilon = 0.001;
  57657. /**
  57658. * Class used to hold a RBG color
  57659. */
  57660. export class Color3 {
  57661. /**
  57662. * Defines the red component (between 0 and 1, default is 0)
  57663. */
  57664. r: number;
  57665. /**
  57666. * Defines the green component (between 0 and 1, default is 0)
  57667. */
  57668. g: number;
  57669. /**
  57670. * Defines the blue component (between 0 and 1, default is 0)
  57671. */
  57672. b: number;
  57673. /**
  57674. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  57675. * @param r defines the red component (between 0 and 1, default is 0)
  57676. * @param g defines the green component (between 0 and 1, default is 0)
  57677. * @param b defines the blue component (between 0 and 1, default is 0)
  57678. */
  57679. constructor(
  57680. /**
  57681. * Defines the red component (between 0 and 1, default is 0)
  57682. */
  57683. r?: number,
  57684. /**
  57685. * Defines the green component (between 0 and 1, default is 0)
  57686. */
  57687. g?: number,
  57688. /**
  57689. * Defines the blue component (between 0 and 1, default is 0)
  57690. */
  57691. b?: number);
  57692. /**
  57693. * Creates a string with the Color3 current values
  57694. * @returns the string representation of the Color3 object
  57695. */
  57696. toString(): string;
  57697. /**
  57698. * Returns the string "Color3"
  57699. * @returns "Color3"
  57700. */
  57701. getClassName(): string;
  57702. /**
  57703. * Compute the Color3 hash code
  57704. * @returns an unique number that can be used to hash Color3 objects
  57705. */
  57706. getHashCode(): number;
  57707. /**
  57708. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  57709. * @param array defines the array where to store the r,g,b components
  57710. * @param index defines an optional index in the target array to define where to start storing values
  57711. * @returns the current Color3 object
  57712. */
  57713. toArray(array: FloatArray, index?: number): Color3;
  57714. /**
  57715. * Returns a new Color4 object from the current Color3 and the given alpha
  57716. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  57717. * @returns a new Color4 object
  57718. */
  57719. toColor4(alpha?: number): Color4;
  57720. /**
  57721. * Returns a new array populated with 3 numeric elements : red, green and blue values
  57722. * @returns the new array
  57723. */
  57724. asArray(): number[];
  57725. /**
  57726. * Returns the luminance value
  57727. * @returns a float value
  57728. */
  57729. toLuminance(): number;
  57730. /**
  57731. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  57732. * @param otherColor defines the second operand
  57733. * @returns the new Color3 object
  57734. */
  57735. multiply(otherColor: DeepImmutable<Color3>): Color3;
  57736. /**
  57737. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  57738. * @param otherColor defines the second operand
  57739. * @param result defines the Color3 object where to store the result
  57740. * @returns the current Color3
  57741. */
  57742. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57743. /**
  57744. * Determines equality between Color3 objects
  57745. * @param otherColor defines the second operand
  57746. * @returns true if the rgb values are equal to the given ones
  57747. */
  57748. equals(otherColor: DeepImmutable<Color3>): boolean;
  57749. /**
  57750. * Determines equality between the current Color3 object and a set of r,b,g values
  57751. * @param r defines the red component to check
  57752. * @param g defines the green component to check
  57753. * @param b defines the blue component to check
  57754. * @returns true if the rgb values are equal to the given ones
  57755. */
  57756. equalsFloats(r: number, g: number, b: number): boolean;
  57757. /**
  57758. * Multiplies in place each rgb value by scale
  57759. * @param scale defines the scaling factor
  57760. * @returns the updated Color3
  57761. */
  57762. scale(scale: number): Color3;
  57763. /**
  57764. * Multiplies the rgb values by scale and stores the result into "result"
  57765. * @param scale defines the scaling factor
  57766. * @param result defines the Color3 object where to store the result
  57767. * @returns the unmodified current Color3
  57768. */
  57769. scaleToRef(scale: number, result: Color3): Color3;
  57770. /**
  57771. * Scale the current Color3 values by a factor and add the result to a given Color3
  57772. * @param scale defines the scale factor
  57773. * @param result defines color to store the result into
  57774. * @returns the unmodified current Color3
  57775. */
  57776. scaleAndAddToRef(scale: number, result: Color3): Color3;
  57777. /**
  57778. * Clamps the rgb values by the min and max values and stores the result into "result"
  57779. * @param min defines minimum clamping value (default is 0)
  57780. * @param max defines maximum clamping value (default is 1)
  57781. * @param result defines color to store the result into
  57782. * @returns the original Color3
  57783. */
  57784. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  57785. /**
  57786. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  57787. * @param otherColor defines the second operand
  57788. * @returns the new Color3
  57789. */
  57790. add(otherColor: DeepImmutable<Color3>): Color3;
  57791. /**
  57792. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  57793. * @param otherColor defines the second operand
  57794. * @param result defines Color3 object to store the result into
  57795. * @returns the unmodified current Color3
  57796. */
  57797. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57798. /**
  57799. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  57800. * @param otherColor defines the second operand
  57801. * @returns the new Color3
  57802. */
  57803. subtract(otherColor: DeepImmutable<Color3>): Color3;
  57804. /**
  57805. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  57806. * @param otherColor defines the second operand
  57807. * @param result defines Color3 object to store the result into
  57808. * @returns the unmodified current Color3
  57809. */
  57810. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57811. /**
  57812. * Copy the current object
  57813. * @returns a new Color3 copied the current one
  57814. */
  57815. clone(): Color3;
  57816. /**
  57817. * Copies the rgb values from the source in the current Color3
  57818. * @param source defines the source Color3 object
  57819. * @returns the updated Color3 object
  57820. */
  57821. copyFrom(source: DeepImmutable<Color3>): Color3;
  57822. /**
  57823. * Updates the Color3 rgb values from the given floats
  57824. * @param r defines the red component to read from
  57825. * @param g defines the green component to read from
  57826. * @param b defines the blue component to read from
  57827. * @returns the current Color3 object
  57828. */
  57829. copyFromFloats(r: number, g: number, b: number): Color3;
  57830. /**
  57831. * Updates the Color3 rgb values from the given floats
  57832. * @param r defines the red component to read from
  57833. * @param g defines the green component to read from
  57834. * @param b defines the blue component to read from
  57835. * @returns the current Color3 object
  57836. */
  57837. set(r: number, g: number, b: number): Color3;
  57838. /**
  57839. * Compute the Color3 hexadecimal code as a string
  57840. * @returns a string containing the hexadecimal representation of the Color3 object
  57841. */
  57842. toHexString(): string;
  57843. /**
  57844. * Computes a new Color3 converted from the current one to linear space
  57845. * @returns a new Color3 object
  57846. */
  57847. toLinearSpace(): Color3;
  57848. /**
  57849. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  57850. * @param convertedColor defines the Color3 object where to store the linear space version
  57851. * @returns the unmodified Color3
  57852. */
  57853. toLinearSpaceToRef(convertedColor: Color3): Color3;
  57854. /**
  57855. * Computes a new Color3 converted from the current one to gamma space
  57856. * @returns a new Color3 object
  57857. */
  57858. toGammaSpace(): Color3;
  57859. /**
  57860. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  57861. * @param convertedColor defines the Color3 object where to store the gamma space version
  57862. * @returns the unmodified Color3
  57863. */
  57864. toGammaSpaceToRef(convertedColor: Color3): Color3;
  57865. private static _BlackReadOnly;
  57866. /**
  57867. * Creates a new Color3 from the string containing valid hexadecimal values
  57868. * @param hex defines a string containing valid hexadecimal values
  57869. * @returns a new Color3 object
  57870. */
  57871. static FromHexString(hex: string): Color3;
  57872. /**
  57873. * Creates a new Vector3 from the starting index of the given array
  57874. * @param array defines the source array
  57875. * @param offset defines an offset in the source array
  57876. * @returns a new Color3 object
  57877. */
  57878. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  57879. /**
  57880. * Creates a new Color3 from integer values (< 256)
  57881. * @param r defines the red component to read from (value between 0 and 255)
  57882. * @param g defines the green component to read from (value between 0 and 255)
  57883. * @param b defines the blue component to read from (value between 0 and 255)
  57884. * @returns a new Color3 object
  57885. */
  57886. static FromInts(r: number, g: number, b: number): Color3;
  57887. /**
  57888. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57889. * @param start defines the start Color3 value
  57890. * @param end defines the end Color3 value
  57891. * @param amount defines the gradient value between start and end
  57892. * @returns a new Color3 object
  57893. */
  57894. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  57895. /**
  57896. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57897. * @param left defines the start value
  57898. * @param right defines the end value
  57899. * @param amount defines the gradient factor
  57900. * @param result defines the Color3 object where to store the result
  57901. */
  57902. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  57903. /**
  57904. * Returns a Color3 value containing a red color
  57905. * @returns a new Color3 object
  57906. */
  57907. static Red(): Color3;
  57908. /**
  57909. * Returns a Color3 value containing a green color
  57910. * @returns a new Color3 object
  57911. */
  57912. static Green(): Color3;
  57913. /**
  57914. * Returns a Color3 value containing a blue color
  57915. * @returns a new Color3 object
  57916. */
  57917. static Blue(): Color3;
  57918. /**
  57919. * Returns a Color3 value containing a black color
  57920. * @returns a new Color3 object
  57921. */
  57922. static Black(): Color3;
  57923. /**
  57924. * Gets a Color3 value containing a black color that must not be updated
  57925. */
  57926. static readonly BlackReadOnly: DeepImmutable<Color3>;
  57927. /**
  57928. * Returns a Color3 value containing a white color
  57929. * @returns a new Color3 object
  57930. */
  57931. static White(): Color3;
  57932. /**
  57933. * Returns a Color3 value containing a purple color
  57934. * @returns a new Color3 object
  57935. */
  57936. static Purple(): Color3;
  57937. /**
  57938. * Returns a Color3 value containing a magenta color
  57939. * @returns a new Color3 object
  57940. */
  57941. static Magenta(): Color3;
  57942. /**
  57943. * Returns a Color3 value containing a yellow color
  57944. * @returns a new Color3 object
  57945. */
  57946. static Yellow(): Color3;
  57947. /**
  57948. * Returns a Color3 value containing a gray color
  57949. * @returns a new Color3 object
  57950. */
  57951. static Gray(): Color3;
  57952. /**
  57953. * Returns a Color3 value containing a teal color
  57954. * @returns a new Color3 object
  57955. */
  57956. static Teal(): Color3;
  57957. /**
  57958. * Returns a Color3 value containing a random color
  57959. * @returns a new Color3 object
  57960. */
  57961. static Random(): Color3;
  57962. }
  57963. /**
  57964. * Class used to hold a RBGA color
  57965. */
  57966. export class Color4 {
  57967. /**
  57968. * Defines the red component (between 0 and 1, default is 0)
  57969. */
  57970. r: number;
  57971. /**
  57972. * Defines the green component (between 0 and 1, default is 0)
  57973. */
  57974. g: number;
  57975. /**
  57976. * Defines the blue component (between 0 and 1, default is 0)
  57977. */
  57978. b: number;
  57979. /**
  57980. * Defines the alpha component (between 0 and 1, default is 1)
  57981. */
  57982. a: number;
  57983. /**
  57984. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  57985. * @param r defines the red component (between 0 and 1, default is 0)
  57986. * @param g defines the green component (between 0 and 1, default is 0)
  57987. * @param b defines the blue component (between 0 and 1, default is 0)
  57988. * @param a defines the alpha component (between 0 and 1, default is 1)
  57989. */
  57990. constructor(
  57991. /**
  57992. * Defines the red component (between 0 and 1, default is 0)
  57993. */
  57994. r?: number,
  57995. /**
  57996. * Defines the green component (between 0 and 1, default is 0)
  57997. */
  57998. g?: number,
  57999. /**
  58000. * Defines the blue component (between 0 and 1, default is 0)
  58001. */
  58002. b?: number,
  58003. /**
  58004. * Defines the alpha component (between 0 and 1, default is 1)
  58005. */
  58006. a?: number);
  58007. /**
  58008. * Adds in place the given Color4 values to the current Color4 object
  58009. * @param right defines the second operand
  58010. * @returns the current updated Color4 object
  58011. */
  58012. addInPlace(right: DeepImmutable<Color4>): Color4;
  58013. /**
  58014. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58015. * @returns the new array
  58016. */
  58017. asArray(): number[];
  58018. /**
  58019. * Stores from the starting index in the given array the Color4 successive values
  58020. * @param array defines the array where to store the r,g,b components
  58021. * @param index defines an optional index in the target array to define where to start storing values
  58022. * @returns the current Color4 object
  58023. */
  58024. toArray(array: number[], index?: number): Color4;
  58025. /**
  58026. * Determines equality between Color4 objects
  58027. * @param otherColor defines the second operand
  58028. * @returns true if the rgba values are equal to the given ones
  58029. */
  58030. equals(otherColor: DeepImmutable<Color4>): boolean;
  58031. /**
  58032. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  58033. * @param right defines the second operand
  58034. * @returns a new Color4 object
  58035. */
  58036. add(right: DeepImmutable<Color4>): Color4;
  58037. /**
  58038. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  58039. * @param right defines the second operand
  58040. * @returns a new Color4 object
  58041. */
  58042. subtract(right: DeepImmutable<Color4>): Color4;
  58043. /**
  58044. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  58045. * @param right defines the second operand
  58046. * @param result defines the Color4 object where to store the result
  58047. * @returns the current Color4 object
  58048. */
  58049. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58050. /**
  58051. * Creates a new Color4 with the current Color4 values multiplied by scale
  58052. * @param scale defines the scaling factor to apply
  58053. * @returns a new Color4 object
  58054. */
  58055. scale(scale: number): Color4;
  58056. /**
  58057. * Multiplies the current Color4 values by scale and stores the result in "result"
  58058. * @param scale defines the scaling factor to apply
  58059. * @param result defines the Color4 object where to store the result
  58060. * @returns the current unmodified Color4
  58061. */
  58062. scaleToRef(scale: number, result: Color4): Color4;
  58063. /**
  58064. * Scale the current Color4 values by a factor and add the result to a given Color4
  58065. * @param scale defines the scale factor
  58066. * @param result defines the Color4 object where to store the result
  58067. * @returns the unmodified current Color4
  58068. */
  58069. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58070. /**
  58071. * Clamps the rgb values by the min and max values and stores the result into "result"
  58072. * @param min defines minimum clamping value (default is 0)
  58073. * @param max defines maximum clamping value (default is 1)
  58074. * @param result defines color to store the result into.
  58075. * @returns the cuurent Color4
  58076. */
  58077. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58078. /**
  58079. * Multipy an Color4 value by another and return a new Color4 object
  58080. * @param color defines the Color4 value to multiply by
  58081. * @returns a new Color4 object
  58082. */
  58083. multiply(color: Color4): Color4;
  58084. /**
  58085. * Multipy a Color4 value by another and push the result in a reference value
  58086. * @param color defines the Color4 value to multiply by
  58087. * @param result defines the Color4 to fill the result in
  58088. * @returns the result Color4
  58089. */
  58090. multiplyToRef(color: Color4, result: Color4): Color4;
  58091. /**
  58092. * Creates a string with the Color4 current values
  58093. * @returns the string representation of the Color4 object
  58094. */
  58095. toString(): string;
  58096. /**
  58097. * Returns the string "Color4"
  58098. * @returns "Color4"
  58099. */
  58100. getClassName(): string;
  58101. /**
  58102. * Compute the Color4 hash code
  58103. * @returns an unique number that can be used to hash Color4 objects
  58104. */
  58105. getHashCode(): number;
  58106. /**
  58107. * Creates a new Color4 copied from the current one
  58108. * @returns a new Color4 object
  58109. */
  58110. clone(): Color4;
  58111. /**
  58112. * Copies the given Color4 values into the current one
  58113. * @param source defines the source Color4 object
  58114. * @returns the current updated Color4 object
  58115. */
  58116. copyFrom(source: Color4): Color4;
  58117. /**
  58118. * Copies the given float values into the current one
  58119. * @param r defines the red component to read from
  58120. * @param g defines the green component to read from
  58121. * @param b defines the blue component to read from
  58122. * @param a defines the alpha component to read from
  58123. * @returns the current updated Color4 object
  58124. */
  58125. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58126. /**
  58127. * Copies the given float values into the current one
  58128. * @param r defines the red component to read from
  58129. * @param g defines the green component to read from
  58130. * @param b defines the blue component to read from
  58131. * @param a defines the alpha component to read from
  58132. * @returns the current updated Color4 object
  58133. */
  58134. set(r: number, g: number, b: number, a: number): Color4;
  58135. /**
  58136. * Compute the Color4 hexadecimal code as a string
  58137. * @returns a string containing the hexadecimal representation of the Color4 object
  58138. */
  58139. toHexString(): string;
  58140. /**
  58141. * Computes a new Color4 converted from the current one to linear space
  58142. * @returns a new Color4 object
  58143. */
  58144. toLinearSpace(): Color4;
  58145. /**
  58146. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58147. * @param convertedColor defines the Color4 object where to store the linear space version
  58148. * @returns the unmodified Color4
  58149. */
  58150. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58151. /**
  58152. * Computes a new Color4 converted from the current one to gamma space
  58153. * @returns a new Color4 object
  58154. */
  58155. toGammaSpace(): Color4;
  58156. /**
  58157. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58158. * @param convertedColor defines the Color4 object where to store the gamma space version
  58159. * @returns the unmodified Color4
  58160. */
  58161. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58162. /**
  58163. * Creates a new Color4 from the string containing valid hexadecimal values
  58164. * @param hex defines a string containing valid hexadecimal values
  58165. * @returns a new Color4 object
  58166. */
  58167. static FromHexString(hex: string): Color4;
  58168. /**
  58169. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58170. * @param left defines the start value
  58171. * @param right defines the end value
  58172. * @param amount defines the gradient factor
  58173. * @returns a new Color4 object
  58174. */
  58175. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58176. /**
  58177. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58178. * @param left defines the start value
  58179. * @param right defines the end value
  58180. * @param amount defines the gradient factor
  58181. * @param result defines the Color4 object where to store data
  58182. */
  58183. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58184. /**
  58185. * Creates a new Color4 from a Color3 and an alpha value
  58186. * @param color3 defines the source Color3 to read from
  58187. * @param alpha defines the alpha component (1.0 by default)
  58188. * @returns a new Color4 object
  58189. */
  58190. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58191. /**
  58192. * Creates a new Color4 from the starting index element of the given array
  58193. * @param array defines the source array to read from
  58194. * @param offset defines the offset in the source array
  58195. * @returns a new Color4 object
  58196. */
  58197. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58198. /**
  58199. * Creates a new Color3 from integer values (< 256)
  58200. * @param r defines the red component to read from (value between 0 and 255)
  58201. * @param g defines the green component to read from (value between 0 and 255)
  58202. * @param b defines the blue component to read from (value between 0 and 255)
  58203. * @param a defines the alpha component to read from (value between 0 and 255)
  58204. * @returns a new Color3 object
  58205. */
  58206. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58207. /**
  58208. * Check the content of a given array and convert it to an array containing RGBA data
  58209. * If the original array was already containing count * 4 values then it is returned directly
  58210. * @param colors defines the array to check
  58211. * @param count defines the number of RGBA data to expect
  58212. * @returns an array containing count * 4 values (RGBA)
  58213. */
  58214. static CheckColors4(colors: number[], count: number): number[];
  58215. }
  58216. /**
  58217. * Class representing a vector containing 2 coordinates
  58218. */
  58219. export class Vector2 {
  58220. /** defines the first coordinate */
  58221. x: number;
  58222. /** defines the second coordinate */
  58223. y: number;
  58224. /**
  58225. * Creates a new Vector2 from the given x and y coordinates
  58226. * @param x defines the first coordinate
  58227. * @param y defines the second coordinate
  58228. */
  58229. constructor(
  58230. /** defines the first coordinate */
  58231. x?: number,
  58232. /** defines the second coordinate */
  58233. y?: number);
  58234. /**
  58235. * Gets a string with the Vector2 coordinates
  58236. * @returns a string with the Vector2 coordinates
  58237. */
  58238. toString(): string;
  58239. /**
  58240. * Gets class name
  58241. * @returns the string "Vector2"
  58242. */
  58243. getClassName(): string;
  58244. /**
  58245. * Gets current vector hash code
  58246. * @returns the Vector2 hash code as a number
  58247. */
  58248. getHashCode(): number;
  58249. /**
  58250. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58251. * @param array defines the source array
  58252. * @param index defines the offset in source array
  58253. * @returns the current Vector2
  58254. */
  58255. toArray(array: FloatArray, index?: number): Vector2;
  58256. /**
  58257. * Copy the current vector to an array
  58258. * @returns a new array with 2 elements: the Vector2 coordinates.
  58259. */
  58260. asArray(): number[];
  58261. /**
  58262. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58263. * @param source defines the source Vector2
  58264. * @returns the current updated Vector2
  58265. */
  58266. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58267. /**
  58268. * Sets the Vector2 coordinates with the given floats
  58269. * @param x defines the first coordinate
  58270. * @param y defines the second coordinate
  58271. * @returns the current updated Vector2
  58272. */
  58273. copyFromFloats(x: number, y: number): Vector2;
  58274. /**
  58275. * Sets the Vector2 coordinates with the given floats
  58276. * @param x defines the first coordinate
  58277. * @param y defines the second coordinate
  58278. * @returns the current updated Vector2
  58279. */
  58280. set(x: number, y: number): Vector2;
  58281. /**
  58282. * Add another vector with the current one
  58283. * @param otherVector defines the other vector
  58284. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58285. */
  58286. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58287. /**
  58288. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58289. * @param otherVector defines the other vector
  58290. * @param result defines the target vector
  58291. * @returns the unmodified current Vector2
  58292. */
  58293. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58294. /**
  58295. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58296. * @param otherVector defines the other vector
  58297. * @returns the current updated Vector2
  58298. */
  58299. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58300. /**
  58301. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58302. * @param otherVector defines the other vector
  58303. * @returns a new Vector2
  58304. */
  58305. addVector3(otherVector: Vector3): Vector2;
  58306. /**
  58307. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58308. * @param otherVector defines the other vector
  58309. * @returns a new Vector2
  58310. */
  58311. subtract(otherVector: Vector2): Vector2;
  58312. /**
  58313. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58314. * @param otherVector defines the other vector
  58315. * @param result defines the target vector
  58316. * @returns the unmodified current Vector2
  58317. */
  58318. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58319. /**
  58320. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58321. * @param otherVector defines the other vector
  58322. * @returns the current updated Vector2
  58323. */
  58324. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58325. /**
  58326. * Multiplies in place the current Vector2 coordinates by the given ones
  58327. * @param otherVector defines the other vector
  58328. * @returns the current updated Vector2
  58329. */
  58330. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58331. /**
  58332. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58333. * @param otherVector defines the other vector
  58334. * @returns a new Vector2
  58335. */
  58336. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58337. /**
  58338. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58339. * @param otherVector defines the other vector
  58340. * @param result defines the target vector
  58341. * @returns the unmodified current Vector2
  58342. */
  58343. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58344. /**
  58345. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58346. * @param x defines the first coordinate
  58347. * @param y defines the second coordinate
  58348. * @returns a new Vector2
  58349. */
  58350. multiplyByFloats(x: number, y: number): Vector2;
  58351. /**
  58352. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58353. * @param otherVector defines the other vector
  58354. * @returns a new Vector2
  58355. */
  58356. divide(otherVector: Vector2): Vector2;
  58357. /**
  58358. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58359. * @param otherVector defines the other vector
  58360. * @param result defines the target vector
  58361. * @returns the unmodified current Vector2
  58362. */
  58363. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58364. /**
  58365. * Divides the current Vector2 coordinates by the given ones
  58366. * @param otherVector defines the other vector
  58367. * @returns the current updated Vector2
  58368. */
  58369. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58370. /**
  58371. * Gets a new Vector2 with current Vector2 negated coordinates
  58372. * @returns a new Vector2
  58373. */
  58374. negate(): Vector2;
  58375. /**
  58376. * Multiply the Vector2 coordinates by scale
  58377. * @param scale defines the scaling factor
  58378. * @returns the current updated Vector2
  58379. */
  58380. scaleInPlace(scale: number): Vector2;
  58381. /**
  58382. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58383. * @param scale defines the scaling factor
  58384. * @returns a new Vector2
  58385. */
  58386. scale(scale: number): Vector2;
  58387. /**
  58388. * Scale the current Vector2 values by a factor to a given Vector2
  58389. * @param scale defines the scale factor
  58390. * @param result defines the Vector2 object where to store the result
  58391. * @returns the unmodified current Vector2
  58392. */
  58393. scaleToRef(scale: number, result: Vector2): Vector2;
  58394. /**
  58395. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58396. * @param scale defines the scale factor
  58397. * @param result defines the Vector2 object where to store the result
  58398. * @returns the unmodified current Vector2
  58399. */
  58400. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58401. /**
  58402. * Gets a boolean if two vectors are equals
  58403. * @param otherVector defines the other vector
  58404. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58405. */
  58406. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58407. /**
  58408. * Gets a boolean if two vectors are equals (using an epsilon value)
  58409. * @param otherVector defines the other vector
  58410. * @param epsilon defines the minimal distance to consider equality
  58411. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58412. */
  58413. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58414. /**
  58415. * Gets a new Vector2 from current Vector2 floored values
  58416. * @returns a new Vector2
  58417. */
  58418. floor(): Vector2;
  58419. /**
  58420. * Gets a new Vector2 from current Vector2 floored values
  58421. * @returns a new Vector2
  58422. */
  58423. fract(): Vector2;
  58424. /**
  58425. * Gets the length of the vector
  58426. * @returns the vector length (float)
  58427. */
  58428. length(): number;
  58429. /**
  58430. * Gets the vector squared length
  58431. * @returns the vector squared length (float)
  58432. */
  58433. lengthSquared(): number;
  58434. /**
  58435. * Normalize the vector
  58436. * @returns the current updated Vector2
  58437. */
  58438. normalize(): Vector2;
  58439. /**
  58440. * Gets a new Vector2 copied from the Vector2
  58441. * @returns a new Vector2
  58442. */
  58443. clone(): Vector2;
  58444. /**
  58445. * Gets a new Vector2(0, 0)
  58446. * @returns a new Vector2
  58447. */
  58448. static Zero(): Vector2;
  58449. /**
  58450. * Gets a new Vector2(1, 1)
  58451. * @returns a new Vector2
  58452. */
  58453. static One(): Vector2;
  58454. /**
  58455. * Gets a new Vector2 set from the given index element of the given array
  58456. * @param array defines the data source
  58457. * @param offset defines the offset in the data source
  58458. * @returns a new Vector2
  58459. */
  58460. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58461. /**
  58462. * Sets "result" from the given index element of the given array
  58463. * @param array defines the data source
  58464. * @param offset defines the offset in the data source
  58465. * @param result defines the target vector
  58466. */
  58467. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58468. /**
  58469. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58470. * @param value1 defines 1st point of control
  58471. * @param value2 defines 2nd point of control
  58472. * @param value3 defines 3rd point of control
  58473. * @param value4 defines 4th point of control
  58474. * @param amount defines the interpolation factor
  58475. * @returns a new Vector2
  58476. */
  58477. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58478. /**
  58479. * 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".
  58480. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58481. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58482. * @param value defines the value to clamp
  58483. * @param min defines the lower limit
  58484. * @param max defines the upper limit
  58485. * @returns a new Vector2
  58486. */
  58487. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58488. /**
  58489. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58490. * @param value1 defines the 1st control point
  58491. * @param tangent1 defines the outgoing tangent
  58492. * @param value2 defines the 2nd control point
  58493. * @param tangent2 defines the incoming tangent
  58494. * @param amount defines the interpolation factor
  58495. * @returns a new Vector2
  58496. */
  58497. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58498. /**
  58499. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58500. * @param start defines the start vector
  58501. * @param end defines the end vector
  58502. * @param amount defines the interpolation factor
  58503. * @returns a new Vector2
  58504. */
  58505. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58506. /**
  58507. * Gets the dot product of the vector "left" and the vector "right"
  58508. * @param left defines first vector
  58509. * @param right defines second vector
  58510. * @returns the dot product (float)
  58511. */
  58512. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58513. /**
  58514. * Returns a new Vector2 equal to the normalized given vector
  58515. * @param vector defines the vector to normalize
  58516. * @returns a new Vector2
  58517. */
  58518. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58519. /**
  58520. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58521. * @param left defines 1st vector
  58522. * @param right defines 2nd vector
  58523. * @returns a new Vector2
  58524. */
  58525. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58526. /**
  58527. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58528. * @param left defines 1st vector
  58529. * @param right defines 2nd vector
  58530. * @returns a new Vector2
  58531. */
  58532. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58533. /**
  58534. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58535. * @param vector defines the vector to transform
  58536. * @param transformation defines the matrix to apply
  58537. * @returns a new Vector2
  58538. */
  58539. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58540. /**
  58541. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58542. * @param vector defines the vector to transform
  58543. * @param transformation defines the matrix to apply
  58544. * @param result defines the target vector
  58545. */
  58546. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58547. /**
  58548. * Determines if a given vector is included in a triangle
  58549. * @param p defines the vector to test
  58550. * @param p0 defines 1st triangle point
  58551. * @param p1 defines 2nd triangle point
  58552. * @param p2 defines 3rd triangle point
  58553. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58554. */
  58555. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58556. /**
  58557. * Gets the distance between the vectors "value1" and "value2"
  58558. * @param value1 defines first vector
  58559. * @param value2 defines second vector
  58560. * @returns the distance between vectors
  58561. */
  58562. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58563. /**
  58564. * Returns the squared distance between the vectors "value1" and "value2"
  58565. * @param value1 defines first vector
  58566. * @param value2 defines second vector
  58567. * @returns the squared distance between vectors
  58568. */
  58569. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58570. /**
  58571. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58572. * @param value1 defines first vector
  58573. * @param value2 defines second vector
  58574. * @returns a new Vector2
  58575. */
  58576. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58577. /**
  58578. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58579. * @param p defines the middle point
  58580. * @param segA defines one point of the segment
  58581. * @param segB defines the other point of the segment
  58582. * @returns the shortest distance
  58583. */
  58584. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58585. }
  58586. /**
  58587. * Classed used to store (x,y,z) vector representation
  58588. * A Vector3 is the main object used in 3D geometry
  58589. * It can represent etiher the coordinates of a point the space, either a direction
  58590. * Reminder: js uses a left handed forward facing system
  58591. */
  58592. export class Vector3 {
  58593. /**
  58594. * Defines the first coordinates (on X axis)
  58595. */
  58596. x: number;
  58597. /**
  58598. * Defines the second coordinates (on Y axis)
  58599. */
  58600. y: number;
  58601. /**
  58602. * Defines the third coordinates (on Z axis)
  58603. */
  58604. z: number;
  58605. private static _UpReadOnly;
  58606. /**
  58607. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58608. * @param x defines the first coordinates (on X axis)
  58609. * @param y defines the second coordinates (on Y axis)
  58610. * @param z defines the third coordinates (on Z axis)
  58611. */
  58612. constructor(
  58613. /**
  58614. * Defines the first coordinates (on X axis)
  58615. */
  58616. x?: number,
  58617. /**
  58618. * Defines the second coordinates (on Y axis)
  58619. */
  58620. y?: number,
  58621. /**
  58622. * Defines the third coordinates (on Z axis)
  58623. */
  58624. z?: number);
  58625. /**
  58626. * Creates a string representation of the Vector3
  58627. * @returns a string with the Vector3 coordinates.
  58628. */
  58629. toString(): string;
  58630. /**
  58631. * Gets the class name
  58632. * @returns the string "Vector3"
  58633. */
  58634. getClassName(): string;
  58635. /**
  58636. * Creates the Vector3 hash code
  58637. * @returns a number which tends to be unique between Vector3 instances
  58638. */
  58639. getHashCode(): number;
  58640. /**
  58641. * Creates an array containing three elements : the coordinates of the Vector3
  58642. * @returns a new array of numbers
  58643. */
  58644. asArray(): number[];
  58645. /**
  58646. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  58647. * @param array defines the destination array
  58648. * @param index defines the offset in the destination array
  58649. * @returns the current Vector3
  58650. */
  58651. toArray(array: FloatArray, index?: number): Vector3;
  58652. /**
  58653. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  58654. * @returns a new Quaternion object, computed from the Vector3 coordinates
  58655. */
  58656. toQuaternion(): Quaternion;
  58657. /**
  58658. * Adds the given vector to the current Vector3
  58659. * @param otherVector defines the second operand
  58660. * @returns the current updated Vector3
  58661. */
  58662. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58663. /**
  58664. * Adds the given coordinates to the current Vector3
  58665. * @param x defines the x coordinate of the operand
  58666. * @param y defines the y coordinate of the operand
  58667. * @param z defines the z coordinate of the operand
  58668. * @returns the current updated Vector3
  58669. */
  58670. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58671. /**
  58672. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  58673. * @param otherVector defines the second operand
  58674. * @returns the resulting Vector3
  58675. */
  58676. add(otherVector: DeepImmutable<Vector3>): Vector3;
  58677. /**
  58678. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  58679. * @param otherVector defines the second operand
  58680. * @param result defines the Vector3 object where to store the result
  58681. * @returns the current Vector3
  58682. */
  58683. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58684. /**
  58685. * Subtract the given vector from the current Vector3
  58686. * @param otherVector defines the second operand
  58687. * @returns the current updated Vector3
  58688. */
  58689. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58690. /**
  58691. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  58692. * @param otherVector defines the second operand
  58693. * @returns the resulting Vector3
  58694. */
  58695. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  58696. /**
  58697. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  58698. * @param otherVector defines the second operand
  58699. * @param result defines the Vector3 object where to store the result
  58700. * @returns the current Vector3
  58701. */
  58702. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58703. /**
  58704. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  58705. * @param x defines the x coordinate of the operand
  58706. * @param y defines the y coordinate of the operand
  58707. * @param z defines the z coordinate of the operand
  58708. * @returns the resulting Vector3
  58709. */
  58710. subtractFromFloats(x: number, y: number, z: number): Vector3;
  58711. /**
  58712. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  58713. * @param x defines the x coordinate of the operand
  58714. * @param y defines the y coordinate of the operand
  58715. * @param z defines the z coordinate of the operand
  58716. * @param result defines the Vector3 object where to store the result
  58717. * @returns the current Vector3
  58718. */
  58719. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  58720. /**
  58721. * Gets a new Vector3 set with the current Vector3 negated coordinates
  58722. * @returns a new Vector3
  58723. */
  58724. negate(): Vector3;
  58725. /**
  58726. * Multiplies the Vector3 coordinates by the float "scale"
  58727. * @param scale defines the multiplier factor
  58728. * @returns the current updated Vector3
  58729. */
  58730. scaleInPlace(scale: number): Vector3;
  58731. /**
  58732. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  58733. * @param scale defines the multiplier factor
  58734. * @returns a new Vector3
  58735. */
  58736. scale(scale: number): Vector3;
  58737. /**
  58738. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  58739. * @param scale defines the multiplier factor
  58740. * @param result defines the Vector3 object where to store the result
  58741. * @returns the current Vector3
  58742. */
  58743. scaleToRef(scale: number, result: Vector3): Vector3;
  58744. /**
  58745. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  58746. * @param scale defines the scale factor
  58747. * @param result defines the Vector3 object where to store the result
  58748. * @returns the unmodified current Vector3
  58749. */
  58750. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  58751. /**
  58752. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  58753. * @param otherVector defines the second operand
  58754. * @returns true if both vectors are equals
  58755. */
  58756. equals(otherVector: DeepImmutable<Vector3>): boolean;
  58757. /**
  58758. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  58759. * @param otherVector defines the second operand
  58760. * @param epsilon defines the minimal distance to define values as equals
  58761. * @returns true if both vectors are distant less than epsilon
  58762. */
  58763. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  58764. /**
  58765. * Returns true if the current Vector3 coordinates equals the given floats
  58766. * @param x defines the x coordinate of the operand
  58767. * @param y defines the y coordinate of the operand
  58768. * @param z defines the z coordinate of the operand
  58769. * @returns true if both vectors are equals
  58770. */
  58771. equalsToFloats(x: number, y: number, z: number): boolean;
  58772. /**
  58773. * Multiplies the current Vector3 coordinates by the given ones
  58774. * @param otherVector defines the second operand
  58775. * @returns the current updated Vector3
  58776. */
  58777. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58778. /**
  58779. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  58780. * @param otherVector defines the second operand
  58781. * @returns the new Vector3
  58782. */
  58783. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  58784. /**
  58785. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  58786. * @param otherVector defines the second operand
  58787. * @param result defines the Vector3 object where to store the result
  58788. * @returns the current Vector3
  58789. */
  58790. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58791. /**
  58792. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  58793. * @param x defines the x coordinate of the operand
  58794. * @param y defines the y coordinate of the operand
  58795. * @param z defines the z coordinate of the operand
  58796. * @returns the new Vector3
  58797. */
  58798. multiplyByFloats(x: number, y: number, z: number): Vector3;
  58799. /**
  58800. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  58801. * @param otherVector defines the second operand
  58802. * @returns the new Vector3
  58803. */
  58804. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  58805. /**
  58806. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  58807. * @param otherVector defines the second operand
  58808. * @param result defines the Vector3 object where to store the result
  58809. * @returns the current Vector3
  58810. */
  58811. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58812. /**
  58813. * Divides the current Vector3 coordinates by the given ones.
  58814. * @param otherVector defines the second operand
  58815. * @returns the current updated Vector3
  58816. */
  58817. divideInPlace(otherVector: Vector3): Vector3;
  58818. /**
  58819. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  58820. * @param other defines the second operand
  58821. * @returns the current updated Vector3
  58822. */
  58823. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58824. /**
  58825. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  58826. * @param other defines the second operand
  58827. * @returns the current updated Vector3
  58828. */
  58829. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58830. /**
  58831. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  58832. * @param x defines the x coordinate of the operand
  58833. * @param y defines the y coordinate of the operand
  58834. * @param z defines the z coordinate of the operand
  58835. * @returns the current updated Vector3
  58836. */
  58837. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58838. /**
  58839. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  58840. * @param x defines the x coordinate of the operand
  58841. * @param y defines the y coordinate of the operand
  58842. * @param z defines the z coordinate of the operand
  58843. * @returns the current updated Vector3
  58844. */
  58845. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58846. /**
  58847. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  58848. * Check if is non uniform within a certain amount of decimal places to account for this
  58849. * @param epsilon the amount the values can differ
  58850. * @returns if the the vector is non uniform to a certain number of decimal places
  58851. */
  58852. isNonUniformWithinEpsilon(epsilon: number): boolean;
  58853. /**
  58854. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  58855. */
  58856. readonly isNonUniform: boolean;
  58857. /**
  58858. * Gets a new Vector3 from current Vector3 floored values
  58859. * @returns a new Vector3
  58860. */
  58861. floor(): Vector3;
  58862. /**
  58863. * Gets a new Vector3 from current Vector3 floored values
  58864. * @returns a new Vector3
  58865. */
  58866. fract(): Vector3;
  58867. /**
  58868. * Gets the length of the Vector3
  58869. * @returns the length of the Vecto3
  58870. */
  58871. length(): number;
  58872. /**
  58873. * Gets the squared length of the Vector3
  58874. * @returns squared length of the Vector3
  58875. */
  58876. lengthSquared(): number;
  58877. /**
  58878. * Normalize the current Vector3.
  58879. * Please note that this is an in place operation.
  58880. * @returns the current updated Vector3
  58881. */
  58882. normalize(): Vector3;
  58883. /**
  58884. * Reorders the x y z properties of the vector in place
  58885. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  58886. * @returns the current updated vector
  58887. */
  58888. reorderInPlace(order: string): this;
  58889. /**
  58890. * Rotates the vector around 0,0,0 by a quaternion
  58891. * @param quaternion the rotation quaternion
  58892. * @param result vector to store the result
  58893. * @returns the resulting vector
  58894. */
  58895. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  58896. /**
  58897. * Rotates a vector around a given point
  58898. * @param quaternion the rotation quaternion
  58899. * @param point the point to rotate around
  58900. * @param result vector to store the result
  58901. * @returns the resulting vector
  58902. */
  58903. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  58904. /**
  58905. * Normalize the current Vector3 with the given input length.
  58906. * Please note that this is an in place operation.
  58907. * @param len the length of the vector
  58908. * @returns the current updated Vector3
  58909. */
  58910. normalizeFromLength(len: number): Vector3;
  58911. /**
  58912. * Normalize the current Vector3 to a new vector
  58913. * @returns the new Vector3
  58914. */
  58915. normalizeToNew(): Vector3;
  58916. /**
  58917. * Normalize the current Vector3 to the reference
  58918. * @param reference define the Vector3 to update
  58919. * @returns the updated Vector3
  58920. */
  58921. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  58922. /**
  58923. * Creates a new Vector3 copied from the current Vector3
  58924. * @returns the new Vector3
  58925. */
  58926. clone(): Vector3;
  58927. /**
  58928. * Copies the given vector coordinates to the current Vector3 ones
  58929. * @param source defines the source Vector3
  58930. * @returns the current updated Vector3
  58931. */
  58932. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  58933. /**
  58934. * Copies the given floats to the current Vector3 coordinates
  58935. * @param x defines the x coordinate of the operand
  58936. * @param y defines the y coordinate of the operand
  58937. * @param z defines the z coordinate of the operand
  58938. * @returns the current updated Vector3
  58939. */
  58940. copyFromFloats(x: number, y: number, z: number): Vector3;
  58941. /**
  58942. * Copies the given floats to the current Vector3 coordinates
  58943. * @param x defines the x coordinate of the operand
  58944. * @param y defines the y coordinate of the operand
  58945. * @param z defines the z coordinate of the operand
  58946. * @returns the current updated Vector3
  58947. */
  58948. set(x: number, y: number, z: number): Vector3;
  58949. /**
  58950. * Copies the given float to the current Vector3 coordinates
  58951. * @param v defines the x, y and z coordinates of the operand
  58952. * @returns the current updated Vector3
  58953. */
  58954. setAll(v: number): Vector3;
  58955. /**
  58956. * Get the clip factor between two vectors
  58957. * @param vector0 defines the first operand
  58958. * @param vector1 defines the second operand
  58959. * @param axis defines the axis to use
  58960. * @param size defines the size along the axis
  58961. * @returns the clip factor
  58962. */
  58963. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  58964. /**
  58965. * Get angle between two vectors
  58966. * @param vector0 angle between vector0 and vector1
  58967. * @param vector1 angle between vector0 and vector1
  58968. * @param normal direction of the normal
  58969. * @return the angle between vector0 and vector1
  58970. */
  58971. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  58972. /**
  58973. * Returns a new Vector3 set from the index "offset" of the given array
  58974. * @param array defines the source array
  58975. * @param offset defines the offset in the source array
  58976. * @returns the new Vector3
  58977. */
  58978. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  58979. /**
  58980. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  58981. * This function is deprecated. Use FromArray instead
  58982. * @param array defines the source array
  58983. * @param offset defines the offset in the source array
  58984. * @returns the new Vector3
  58985. */
  58986. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  58987. /**
  58988. * Sets the given vector "result" with the element values from the index "offset" of the given array
  58989. * @param array defines the source array
  58990. * @param offset defines the offset in the source array
  58991. * @param result defines the Vector3 where to store the result
  58992. */
  58993. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  58994. /**
  58995. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  58996. * This function is deprecated. Use FromArrayToRef instead.
  58997. * @param array defines the source array
  58998. * @param offset defines the offset in the source array
  58999. * @param result defines the Vector3 where to store the result
  59000. */
  59001. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59002. /**
  59003. * Sets the given vector "result" with the given floats.
  59004. * @param x defines the x coordinate of the source
  59005. * @param y defines the y coordinate of the source
  59006. * @param z defines the z coordinate of the source
  59007. * @param result defines the Vector3 where to store the result
  59008. */
  59009. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59010. /**
  59011. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59012. * @returns a new empty Vector3
  59013. */
  59014. static Zero(): Vector3;
  59015. /**
  59016. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59017. * @returns a new unit Vector3
  59018. */
  59019. static One(): Vector3;
  59020. /**
  59021. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59022. * @returns a new up Vector3
  59023. */
  59024. static Up(): Vector3;
  59025. /**
  59026. * Gets a up Vector3 that must not be updated
  59027. */
  59028. static readonly UpReadOnly: DeepImmutable<Vector3>;
  59029. /**
  59030. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  59031. * @returns a new down Vector3
  59032. */
  59033. static Down(): Vector3;
  59034. /**
  59035. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  59036. * @returns a new forward Vector3
  59037. */
  59038. static Forward(): Vector3;
  59039. /**
  59040. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  59041. * @returns a new forward Vector3
  59042. */
  59043. static Backward(): Vector3;
  59044. /**
  59045. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  59046. * @returns a new right Vector3
  59047. */
  59048. static Right(): Vector3;
  59049. /**
  59050. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59051. * @returns a new left Vector3
  59052. */
  59053. static Left(): Vector3;
  59054. /**
  59055. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59056. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59057. * @param vector defines the Vector3 to transform
  59058. * @param transformation defines the transformation matrix
  59059. * @returns the transformed Vector3
  59060. */
  59061. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59062. /**
  59063. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59064. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59065. * @param vector defines the Vector3 to transform
  59066. * @param transformation defines the transformation matrix
  59067. * @param result defines the Vector3 where to store the result
  59068. */
  59069. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59070. /**
  59071. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59072. * This method computes tranformed coordinates only, not transformed direction vectors
  59073. * @param x define the x coordinate of the source vector
  59074. * @param y define the y coordinate of the source vector
  59075. * @param z define the z coordinate of the source vector
  59076. * @param transformation defines the transformation matrix
  59077. * @param result defines the Vector3 where to store the result
  59078. */
  59079. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59080. /**
  59081. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59082. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59083. * @param vector defines the Vector3 to transform
  59084. * @param transformation defines the transformation matrix
  59085. * @returns the new Vector3
  59086. */
  59087. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59088. /**
  59089. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59090. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59091. * @param vector defines the Vector3 to transform
  59092. * @param transformation defines the transformation matrix
  59093. * @param result defines the Vector3 where to store the result
  59094. */
  59095. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59096. /**
  59097. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59098. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59099. * @param x define the x coordinate of the source vector
  59100. * @param y define the y coordinate of the source vector
  59101. * @param z define the z coordinate of the source vector
  59102. * @param transformation defines the transformation matrix
  59103. * @param result defines the Vector3 where to store the result
  59104. */
  59105. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59106. /**
  59107. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59108. * @param value1 defines the first control point
  59109. * @param value2 defines the second control point
  59110. * @param value3 defines the third control point
  59111. * @param value4 defines the fourth control point
  59112. * @param amount defines the amount on the spline to use
  59113. * @returns the new Vector3
  59114. */
  59115. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59116. /**
  59117. * 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"
  59118. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59119. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59120. * @param value defines the current value
  59121. * @param min defines the lower range value
  59122. * @param max defines the upper range value
  59123. * @returns the new Vector3
  59124. */
  59125. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59126. /**
  59127. * 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"
  59128. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59129. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59130. * @param value defines the current value
  59131. * @param min defines the lower range value
  59132. * @param max defines the upper range value
  59133. * @param result defines the Vector3 where to store the result
  59134. */
  59135. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59136. /**
  59137. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59138. * @param value1 defines the first control point
  59139. * @param tangent1 defines the first tangent vector
  59140. * @param value2 defines the second control point
  59141. * @param tangent2 defines the second tangent vector
  59142. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59143. * @returns the new Vector3
  59144. */
  59145. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59146. /**
  59147. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59148. * @param start defines the start value
  59149. * @param end defines the end value
  59150. * @param amount max defines amount between both (between 0 and 1)
  59151. * @returns the new Vector3
  59152. */
  59153. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59154. /**
  59155. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59156. * @param start defines the start value
  59157. * @param end defines the end value
  59158. * @param amount max defines amount between both (between 0 and 1)
  59159. * @param result defines the Vector3 where to store the result
  59160. */
  59161. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59162. /**
  59163. * Returns the dot product (float) between the vectors "left" and "right"
  59164. * @param left defines the left operand
  59165. * @param right defines the right operand
  59166. * @returns the dot product
  59167. */
  59168. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59169. /**
  59170. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59171. * The cross product is then orthogonal to both "left" and "right"
  59172. * @param left defines the left operand
  59173. * @param right defines the right operand
  59174. * @returns the cross product
  59175. */
  59176. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59177. /**
  59178. * Sets the given vector "result" with the cross product of "left" and "right"
  59179. * The cross product is then orthogonal to both "left" and "right"
  59180. * @param left defines the left operand
  59181. * @param right defines the right operand
  59182. * @param result defines the Vector3 where to store the result
  59183. */
  59184. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59185. /**
  59186. * Returns a new Vector3 as the normalization of the given vector
  59187. * @param vector defines the Vector3 to normalize
  59188. * @returns the new Vector3
  59189. */
  59190. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59191. /**
  59192. * Sets the given vector "result" with the normalization of the given first vector
  59193. * @param vector defines the Vector3 to normalize
  59194. * @param result defines the Vector3 where to store the result
  59195. */
  59196. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59197. /**
  59198. * Project a Vector3 onto screen space
  59199. * @param vector defines the Vector3 to project
  59200. * @param world defines the world matrix to use
  59201. * @param transform defines the transform (view x projection) matrix to use
  59202. * @param viewport defines the screen viewport to use
  59203. * @returns the new Vector3
  59204. */
  59205. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59206. /** @hidden */
  59207. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59208. /**
  59209. * Unproject from screen space to object space
  59210. * @param source defines the screen space Vector3 to use
  59211. * @param viewportWidth defines the current width of the viewport
  59212. * @param viewportHeight defines the current height of the viewport
  59213. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59214. * @param transform defines the transform (view x projection) matrix to use
  59215. * @returns the new Vector3
  59216. */
  59217. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59218. /**
  59219. * Unproject from screen space to object space
  59220. * @param source defines the screen space Vector3 to use
  59221. * @param viewportWidth defines the current width of the viewport
  59222. * @param viewportHeight defines the current height of the viewport
  59223. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59224. * @param view defines the view matrix to use
  59225. * @param projection defines the projection matrix to use
  59226. * @returns the new Vector3
  59227. */
  59228. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59229. /**
  59230. * Unproject from screen space to object space
  59231. * @param source defines the screen space Vector3 to use
  59232. * @param viewportWidth defines the current width of the viewport
  59233. * @param viewportHeight defines the current height of the viewport
  59234. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59235. * @param view defines the view matrix to use
  59236. * @param projection defines the projection matrix to use
  59237. * @param result defines the Vector3 where to store the result
  59238. */
  59239. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59240. /**
  59241. * Unproject from screen space to object space
  59242. * @param sourceX defines the screen space x coordinate to use
  59243. * @param sourceY defines the screen space y coordinate to use
  59244. * @param sourceZ defines the screen space z coordinate to use
  59245. * @param viewportWidth defines the current width of the viewport
  59246. * @param viewportHeight defines the current height of the viewport
  59247. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59248. * @param view defines the view matrix to use
  59249. * @param projection defines the projection matrix to use
  59250. * @param result defines the Vector3 where to store the result
  59251. */
  59252. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59253. /**
  59254. * Gets the minimal coordinate values between two Vector3
  59255. * @param left defines the first operand
  59256. * @param right defines the second operand
  59257. * @returns the new Vector3
  59258. */
  59259. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59260. /**
  59261. * Gets the maximal coordinate values between two Vector3
  59262. * @param left defines the first operand
  59263. * @param right defines the second operand
  59264. * @returns the new Vector3
  59265. */
  59266. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59267. /**
  59268. * Returns the distance between the vectors "value1" and "value2"
  59269. * @param value1 defines the first operand
  59270. * @param value2 defines the second operand
  59271. * @returns the distance
  59272. */
  59273. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59274. /**
  59275. * Returns the squared distance between the vectors "value1" and "value2"
  59276. * @param value1 defines the first operand
  59277. * @param value2 defines the second operand
  59278. * @returns the squared distance
  59279. */
  59280. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59281. /**
  59282. * Returns a new Vector3 located at the center between "value1" and "value2"
  59283. * @param value1 defines the first operand
  59284. * @param value2 defines the second operand
  59285. * @returns the new Vector3
  59286. */
  59287. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59288. /**
  59289. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59290. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59291. * to something in order to rotate it from its local system to the given target system
  59292. * Note: axis1, axis2 and axis3 are normalized during this operation
  59293. * @param axis1 defines the first axis
  59294. * @param axis2 defines the second axis
  59295. * @param axis3 defines the third axis
  59296. * @returns a new Vector3
  59297. */
  59298. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59299. /**
  59300. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59301. * @param axis1 defines the first axis
  59302. * @param axis2 defines the second axis
  59303. * @param axis3 defines the third axis
  59304. * @param ref defines the Vector3 where to store the result
  59305. */
  59306. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59307. }
  59308. /**
  59309. * Vector4 class created for EulerAngle class conversion to Quaternion
  59310. */
  59311. export class Vector4 {
  59312. /** x value of the vector */
  59313. x: number;
  59314. /** y value of the vector */
  59315. y: number;
  59316. /** z value of the vector */
  59317. z: number;
  59318. /** w value of the vector */
  59319. w: number;
  59320. /**
  59321. * Creates a Vector4 object from the given floats.
  59322. * @param x x value of the vector
  59323. * @param y y value of the vector
  59324. * @param z z value of the vector
  59325. * @param w w value of the vector
  59326. */
  59327. constructor(
  59328. /** x value of the vector */
  59329. x: number,
  59330. /** y value of the vector */
  59331. y: number,
  59332. /** z value of the vector */
  59333. z: number,
  59334. /** w value of the vector */
  59335. w: number);
  59336. /**
  59337. * Returns the string with the Vector4 coordinates.
  59338. * @returns a string containing all the vector values
  59339. */
  59340. toString(): string;
  59341. /**
  59342. * Returns the string "Vector4".
  59343. * @returns "Vector4"
  59344. */
  59345. getClassName(): string;
  59346. /**
  59347. * Returns the Vector4 hash code.
  59348. * @returns a unique hash code
  59349. */
  59350. getHashCode(): number;
  59351. /**
  59352. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59353. * @returns the resulting array
  59354. */
  59355. asArray(): number[];
  59356. /**
  59357. * Populates the given array from the given index with the Vector4 coordinates.
  59358. * @param array array to populate
  59359. * @param index index of the array to start at (default: 0)
  59360. * @returns the Vector4.
  59361. */
  59362. toArray(array: FloatArray, index?: number): Vector4;
  59363. /**
  59364. * Adds the given vector to the current Vector4.
  59365. * @param otherVector the vector to add
  59366. * @returns the updated Vector4.
  59367. */
  59368. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59369. /**
  59370. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59371. * @param otherVector the vector to add
  59372. * @returns the resulting vector
  59373. */
  59374. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59375. /**
  59376. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59377. * @param otherVector the vector to add
  59378. * @param result the vector to store the result
  59379. * @returns the current Vector4.
  59380. */
  59381. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59382. /**
  59383. * Subtract in place the given vector from the current Vector4.
  59384. * @param otherVector the vector to subtract
  59385. * @returns the updated Vector4.
  59386. */
  59387. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59388. /**
  59389. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59390. * @param otherVector the vector to add
  59391. * @returns the new vector with the result
  59392. */
  59393. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59394. /**
  59395. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59396. * @param otherVector the vector to subtract
  59397. * @param result the vector to store the result
  59398. * @returns the current Vector4.
  59399. */
  59400. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59401. /**
  59402. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59403. */
  59404. /**
  59405. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59406. * @param x value to subtract
  59407. * @param y value to subtract
  59408. * @param z value to subtract
  59409. * @param w value to subtract
  59410. * @returns new vector containing the result
  59411. */
  59412. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59413. /**
  59414. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59415. * @param x value to subtract
  59416. * @param y value to subtract
  59417. * @param z value to subtract
  59418. * @param w value to subtract
  59419. * @param result the vector to store the result in
  59420. * @returns the current Vector4.
  59421. */
  59422. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59423. /**
  59424. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59425. * @returns a new vector with the negated values
  59426. */
  59427. negate(): Vector4;
  59428. /**
  59429. * Multiplies the current Vector4 coordinates by scale (float).
  59430. * @param scale the number to scale with
  59431. * @returns the updated Vector4.
  59432. */
  59433. scaleInPlace(scale: number): Vector4;
  59434. /**
  59435. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59436. * @param scale the number to scale with
  59437. * @returns a new vector with the result
  59438. */
  59439. scale(scale: number): Vector4;
  59440. /**
  59441. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59442. * @param scale the number to scale with
  59443. * @param result a vector to store the result in
  59444. * @returns the current Vector4.
  59445. */
  59446. scaleToRef(scale: number, result: Vector4): Vector4;
  59447. /**
  59448. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59449. * @param scale defines the scale factor
  59450. * @param result defines the Vector4 object where to store the result
  59451. * @returns the unmodified current Vector4
  59452. */
  59453. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59454. /**
  59455. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59456. * @param otherVector the vector to compare against
  59457. * @returns true if they are equal
  59458. */
  59459. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59460. /**
  59461. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59462. * @param otherVector vector to compare against
  59463. * @param epsilon (Default: very small number)
  59464. * @returns true if they are equal
  59465. */
  59466. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59467. /**
  59468. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59469. * @param x x value to compare against
  59470. * @param y y value to compare against
  59471. * @param z z value to compare against
  59472. * @param w w value to compare against
  59473. * @returns true if equal
  59474. */
  59475. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59476. /**
  59477. * Multiplies in place the current Vector4 by the given one.
  59478. * @param otherVector vector to multiple with
  59479. * @returns the updated Vector4.
  59480. */
  59481. multiplyInPlace(otherVector: Vector4): Vector4;
  59482. /**
  59483. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59484. * @param otherVector vector to multiple with
  59485. * @returns resulting new vector
  59486. */
  59487. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59488. /**
  59489. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59490. * @param otherVector vector to multiple with
  59491. * @param result vector to store the result
  59492. * @returns the current Vector4.
  59493. */
  59494. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59495. /**
  59496. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59497. * @param x x value multiply with
  59498. * @param y y value multiply with
  59499. * @param z z value multiply with
  59500. * @param w w value multiply with
  59501. * @returns resulting new vector
  59502. */
  59503. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59504. /**
  59505. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59506. * @param otherVector vector to devide with
  59507. * @returns resulting new vector
  59508. */
  59509. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59510. /**
  59511. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59512. * @param otherVector vector to devide with
  59513. * @param result vector to store the result
  59514. * @returns the current Vector4.
  59515. */
  59516. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59517. /**
  59518. * Divides the current Vector3 coordinates by the given ones.
  59519. * @param otherVector vector to devide with
  59520. * @returns the updated Vector3.
  59521. */
  59522. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59523. /**
  59524. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59525. * @param other defines the second operand
  59526. * @returns the current updated Vector4
  59527. */
  59528. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59529. /**
  59530. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59531. * @param other defines the second operand
  59532. * @returns the current updated Vector4
  59533. */
  59534. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59535. /**
  59536. * Gets a new Vector4 from current Vector4 floored values
  59537. * @returns a new Vector4
  59538. */
  59539. floor(): Vector4;
  59540. /**
  59541. * Gets a new Vector4 from current Vector3 floored values
  59542. * @returns a new Vector4
  59543. */
  59544. fract(): Vector4;
  59545. /**
  59546. * Returns the Vector4 length (float).
  59547. * @returns the length
  59548. */
  59549. length(): number;
  59550. /**
  59551. * Returns the Vector4 squared length (float).
  59552. * @returns the length squared
  59553. */
  59554. lengthSquared(): number;
  59555. /**
  59556. * Normalizes in place the Vector4.
  59557. * @returns the updated Vector4.
  59558. */
  59559. normalize(): Vector4;
  59560. /**
  59561. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59562. * @returns this converted to a new vector3
  59563. */
  59564. toVector3(): Vector3;
  59565. /**
  59566. * Returns a new Vector4 copied from the current one.
  59567. * @returns the new cloned vector
  59568. */
  59569. clone(): Vector4;
  59570. /**
  59571. * Updates the current Vector4 with the given one coordinates.
  59572. * @param source the source vector to copy from
  59573. * @returns the updated Vector4.
  59574. */
  59575. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59576. /**
  59577. * Updates the current Vector4 coordinates with the given floats.
  59578. * @param x float to copy from
  59579. * @param y float to copy from
  59580. * @param z float to copy from
  59581. * @param w float to copy from
  59582. * @returns the updated Vector4.
  59583. */
  59584. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59585. /**
  59586. * Updates the current Vector4 coordinates with the given floats.
  59587. * @param x float to set from
  59588. * @param y float to set from
  59589. * @param z float to set from
  59590. * @param w float to set from
  59591. * @returns the updated Vector4.
  59592. */
  59593. set(x: number, y: number, z: number, w: number): Vector4;
  59594. /**
  59595. * Copies the given float to the current Vector3 coordinates
  59596. * @param v defines the x, y, z and w coordinates of the operand
  59597. * @returns the current updated Vector3
  59598. */
  59599. setAll(v: number): Vector4;
  59600. /**
  59601. * Returns a new Vector4 set from the starting index of the given array.
  59602. * @param array the array to pull values from
  59603. * @param offset the offset into the array to start at
  59604. * @returns the new vector
  59605. */
  59606. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59607. /**
  59608. * Updates the given vector "result" from the starting index of the given array.
  59609. * @param array the array to pull values from
  59610. * @param offset the offset into the array to start at
  59611. * @param result the vector to store the result in
  59612. */
  59613. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59614. /**
  59615. * Updates the given vector "result" from the starting index of the given Float32Array.
  59616. * @param array the array to pull values from
  59617. * @param offset the offset into the array to start at
  59618. * @param result the vector to store the result in
  59619. */
  59620. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59621. /**
  59622. * Updates the given vector "result" coordinates from the given floats.
  59623. * @param x float to set from
  59624. * @param y float to set from
  59625. * @param z float to set from
  59626. * @param w float to set from
  59627. * @param result the vector to the floats in
  59628. */
  59629. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  59630. /**
  59631. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  59632. * @returns the new vector
  59633. */
  59634. static Zero(): Vector4;
  59635. /**
  59636. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  59637. * @returns the new vector
  59638. */
  59639. static One(): Vector4;
  59640. /**
  59641. * Returns a new normalized Vector4 from the given one.
  59642. * @param vector the vector to normalize
  59643. * @returns the vector
  59644. */
  59645. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  59646. /**
  59647. * Updates the given vector "result" from the normalization of the given one.
  59648. * @param vector the vector to normalize
  59649. * @param result the vector to store the result in
  59650. */
  59651. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  59652. /**
  59653. * Returns a vector with the minimum values from the left and right vectors
  59654. * @param left left vector to minimize
  59655. * @param right right vector to minimize
  59656. * @returns a new vector with the minimum of the left and right vector values
  59657. */
  59658. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59659. /**
  59660. * Returns a vector with the maximum values from the left and right vectors
  59661. * @param left left vector to maximize
  59662. * @param right right vector to maximize
  59663. * @returns a new vector with the maximum of the left and right vector values
  59664. */
  59665. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59666. /**
  59667. * Returns the distance (float) between the vectors "value1" and "value2".
  59668. * @param value1 value to calulate the distance between
  59669. * @param value2 value to calulate the distance between
  59670. * @return the distance between the two vectors
  59671. */
  59672. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59673. /**
  59674. * Returns the squared distance (float) between the vectors "value1" and "value2".
  59675. * @param value1 value to calulate the distance between
  59676. * @param value2 value to calulate the distance between
  59677. * @return the distance between the two vectors squared
  59678. */
  59679. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59680. /**
  59681. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  59682. * @param value1 value to calulate the center between
  59683. * @param value2 value to calulate the center between
  59684. * @return the center between the two vectors
  59685. */
  59686. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  59687. /**
  59688. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  59689. * This methods computes transformed normalized direction vectors only.
  59690. * @param vector the vector to transform
  59691. * @param transformation the transformation matrix to apply
  59692. * @returns the new vector
  59693. */
  59694. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  59695. /**
  59696. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  59697. * This methods computes transformed normalized direction vectors only.
  59698. * @param vector the vector to transform
  59699. * @param transformation the transformation matrix to apply
  59700. * @param result the vector to store the result in
  59701. */
  59702. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59703. /**
  59704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  59705. * This methods computes transformed normalized direction vectors only.
  59706. * @param x value to transform
  59707. * @param y value to transform
  59708. * @param z value to transform
  59709. * @param w value to transform
  59710. * @param transformation the transformation matrix to apply
  59711. * @param result the vector to store the results in
  59712. */
  59713. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59714. /**
  59715. * Creates a new Vector4 from a Vector3
  59716. * @param source defines the source data
  59717. * @param w defines the 4th component (default is 0)
  59718. * @returns a new Vector4
  59719. */
  59720. static FromVector3(source: Vector3, w?: number): Vector4;
  59721. }
  59722. /**
  59723. * Interface for the size containing width and height
  59724. */
  59725. export interface ISize {
  59726. /**
  59727. * Width
  59728. */
  59729. width: number;
  59730. /**
  59731. * Heighht
  59732. */
  59733. height: number;
  59734. }
  59735. /**
  59736. * Size containing widht and height
  59737. */
  59738. export class Size implements ISize {
  59739. /**
  59740. * Width
  59741. */
  59742. width: number;
  59743. /**
  59744. * Height
  59745. */
  59746. height: number;
  59747. /**
  59748. * Creates a Size object from the given width and height (floats).
  59749. * @param width width of the new size
  59750. * @param height height of the new size
  59751. */
  59752. constructor(width: number, height: number);
  59753. /**
  59754. * Returns a string with the Size width and height
  59755. * @returns a string with the Size width and height
  59756. */
  59757. toString(): string;
  59758. /**
  59759. * "Size"
  59760. * @returns the string "Size"
  59761. */
  59762. getClassName(): string;
  59763. /**
  59764. * Returns the Size hash code.
  59765. * @returns a hash code for a unique width and height
  59766. */
  59767. getHashCode(): number;
  59768. /**
  59769. * Updates the current size from the given one.
  59770. * @param src the given size
  59771. */
  59772. copyFrom(src: Size): void;
  59773. /**
  59774. * Updates in place the current Size from the given floats.
  59775. * @param width width of the new size
  59776. * @param height height of the new size
  59777. * @returns the updated Size.
  59778. */
  59779. copyFromFloats(width: number, height: number): Size;
  59780. /**
  59781. * Updates in place the current Size from the given floats.
  59782. * @param width width to set
  59783. * @param height height to set
  59784. * @returns the updated Size.
  59785. */
  59786. set(width: number, height: number): Size;
  59787. /**
  59788. * Multiplies the width and height by numbers
  59789. * @param w factor to multiple the width by
  59790. * @param h factor to multiple the height by
  59791. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  59792. */
  59793. multiplyByFloats(w: number, h: number): Size;
  59794. /**
  59795. * Clones the size
  59796. * @returns a new Size copied from the given one.
  59797. */
  59798. clone(): Size;
  59799. /**
  59800. * True if the current Size and the given one width and height are strictly equal.
  59801. * @param other the other size to compare against
  59802. * @returns True if the current Size and the given one width and height are strictly equal.
  59803. */
  59804. equals(other: Size): boolean;
  59805. /**
  59806. * The surface of the Size : width * height (float).
  59807. */
  59808. readonly surface: number;
  59809. /**
  59810. * Create a new size of zero
  59811. * @returns a new Size set to (0.0, 0.0)
  59812. */
  59813. static Zero(): Size;
  59814. /**
  59815. * Sums the width and height of two sizes
  59816. * @param otherSize size to add to this size
  59817. * @returns a new Size set as the addition result of the current Size and the given one.
  59818. */
  59819. add(otherSize: Size): Size;
  59820. /**
  59821. * Subtracts the width and height of two
  59822. * @param otherSize size to subtract to this size
  59823. * @returns a new Size set as the subtraction result of the given one from the current Size.
  59824. */
  59825. subtract(otherSize: Size): Size;
  59826. /**
  59827. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  59828. * @param start starting size to lerp between
  59829. * @param end end size to lerp between
  59830. * @param amount amount to lerp between the start and end values
  59831. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  59832. */
  59833. static Lerp(start: Size, end: Size, amount: number): Size;
  59834. }
  59835. /**
  59836. * Class used to store quaternion data
  59837. * @see https://en.wikipedia.org/wiki/Quaternion
  59838. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  59839. */
  59840. export class Quaternion {
  59841. /** defines the first component (0 by default) */
  59842. x: number;
  59843. /** defines the second component (0 by default) */
  59844. y: number;
  59845. /** defines the third component (0 by default) */
  59846. z: number;
  59847. /** defines the fourth component (1.0 by default) */
  59848. w: number;
  59849. /**
  59850. * Creates a new Quaternion from the given floats
  59851. * @param x defines the first component (0 by default)
  59852. * @param y defines the second component (0 by default)
  59853. * @param z defines the third component (0 by default)
  59854. * @param w defines the fourth component (1.0 by default)
  59855. */
  59856. constructor(
  59857. /** defines the first component (0 by default) */
  59858. x?: number,
  59859. /** defines the second component (0 by default) */
  59860. y?: number,
  59861. /** defines the third component (0 by default) */
  59862. z?: number,
  59863. /** defines the fourth component (1.0 by default) */
  59864. w?: number);
  59865. /**
  59866. * Gets a string representation for the current quaternion
  59867. * @returns a string with the Quaternion coordinates
  59868. */
  59869. toString(): string;
  59870. /**
  59871. * Gets the class name of the quaternion
  59872. * @returns the string "Quaternion"
  59873. */
  59874. getClassName(): string;
  59875. /**
  59876. * Gets a hash code for this quaternion
  59877. * @returns the quaternion hash code
  59878. */
  59879. getHashCode(): number;
  59880. /**
  59881. * Copy the quaternion to an array
  59882. * @returns a new array populated with 4 elements from the quaternion coordinates
  59883. */
  59884. asArray(): number[];
  59885. /**
  59886. * Check if two quaternions are equals
  59887. * @param otherQuaternion defines the second operand
  59888. * @return true if the current quaternion and the given one coordinates are strictly equals
  59889. */
  59890. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  59891. /**
  59892. * Clone the current quaternion
  59893. * @returns a new quaternion copied from the current one
  59894. */
  59895. clone(): Quaternion;
  59896. /**
  59897. * Copy a quaternion to the current one
  59898. * @param other defines the other quaternion
  59899. * @returns the updated current quaternion
  59900. */
  59901. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  59902. /**
  59903. * Updates the current quaternion with the given float coordinates
  59904. * @param x defines the x coordinate
  59905. * @param y defines the y coordinate
  59906. * @param z defines the z coordinate
  59907. * @param w defines the w coordinate
  59908. * @returns the updated current quaternion
  59909. */
  59910. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  59911. /**
  59912. * Updates the current quaternion from the given float coordinates
  59913. * @param x defines the x coordinate
  59914. * @param y defines the y coordinate
  59915. * @param z defines the z coordinate
  59916. * @param w defines the w coordinate
  59917. * @returns the updated current quaternion
  59918. */
  59919. set(x: number, y: number, z: number, w: number): Quaternion;
  59920. /**
  59921. * Adds two quaternions
  59922. * @param other defines the second operand
  59923. * @returns a new quaternion as the addition result of the given one and the current quaternion
  59924. */
  59925. add(other: DeepImmutable<Quaternion>): Quaternion;
  59926. /**
  59927. * Add a quaternion to the current one
  59928. * @param other defines the quaternion to add
  59929. * @returns the current quaternion
  59930. */
  59931. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  59932. /**
  59933. * Subtract two quaternions
  59934. * @param other defines the second operand
  59935. * @returns a new quaternion as the subtraction result of the given one from the current one
  59936. */
  59937. subtract(other: Quaternion): Quaternion;
  59938. /**
  59939. * Multiplies the current quaternion by a scale factor
  59940. * @param value defines the scale factor
  59941. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  59942. */
  59943. scale(value: number): Quaternion;
  59944. /**
  59945. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  59946. * @param scale defines the scale factor
  59947. * @param result defines the Quaternion object where to store the result
  59948. * @returns the unmodified current quaternion
  59949. */
  59950. scaleToRef(scale: number, result: Quaternion): Quaternion;
  59951. /**
  59952. * Multiplies in place the current quaternion by a scale factor
  59953. * @param value defines the scale factor
  59954. * @returns the current modified quaternion
  59955. */
  59956. scaleInPlace(value: number): Quaternion;
  59957. /**
  59958. * Scale the current quaternion values by a factor and add the result to a given quaternion
  59959. * @param scale defines the scale factor
  59960. * @param result defines the Quaternion object where to store the result
  59961. * @returns the unmodified current quaternion
  59962. */
  59963. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  59964. /**
  59965. * Multiplies two quaternions
  59966. * @param q1 defines the second operand
  59967. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  59968. */
  59969. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  59970. /**
  59971. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  59972. * @param q1 defines the second operand
  59973. * @param result defines the target quaternion
  59974. * @returns the current quaternion
  59975. */
  59976. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  59977. /**
  59978. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  59979. * @param q1 defines the second operand
  59980. * @returns the currentupdated quaternion
  59981. */
  59982. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  59983. /**
  59984. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  59985. * @param ref defines the target quaternion
  59986. * @returns the current quaternion
  59987. */
  59988. conjugateToRef(ref: Quaternion): Quaternion;
  59989. /**
  59990. * Conjugates in place (1-q) the current quaternion
  59991. * @returns the current updated quaternion
  59992. */
  59993. conjugateInPlace(): Quaternion;
  59994. /**
  59995. * Conjugates in place (1-q) the current quaternion
  59996. * @returns a new quaternion
  59997. */
  59998. conjugate(): Quaternion;
  59999. /**
  60000. * Gets length of current quaternion
  60001. * @returns the quaternion length (float)
  60002. */
  60003. length(): number;
  60004. /**
  60005. * Normalize in place the current quaternion
  60006. * @returns the current updated quaternion
  60007. */
  60008. normalize(): Quaternion;
  60009. /**
  60010. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60011. * @param order is a reserved parameter and is ignore for now
  60012. * @returns a new Vector3 containing the Euler angles
  60013. */
  60014. toEulerAngles(order?: string): Vector3;
  60015. /**
  60016. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60017. * @param result defines the vector which will be filled with the Euler angles
  60018. * @param order is a reserved parameter and is ignore for now
  60019. * @returns the current unchanged quaternion
  60020. */
  60021. toEulerAnglesToRef(result: Vector3): Quaternion;
  60022. /**
  60023. * Updates the given rotation matrix with the current quaternion values
  60024. * @param result defines the target matrix
  60025. * @returns the current unchanged quaternion
  60026. */
  60027. toRotationMatrix(result: Matrix): Quaternion;
  60028. /**
  60029. * Updates the current quaternion from the given rotation matrix values
  60030. * @param matrix defines the source matrix
  60031. * @returns the current updated quaternion
  60032. */
  60033. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60034. /**
  60035. * Creates a new quaternion from a rotation matrix
  60036. * @param matrix defines the source matrix
  60037. * @returns a new quaternion created from the given rotation matrix values
  60038. */
  60039. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60040. /**
  60041. * Updates the given quaternion with the given rotation matrix values
  60042. * @param matrix defines the source matrix
  60043. * @param result defines the target quaternion
  60044. */
  60045. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  60046. /**
  60047. * Returns the dot product (float) between the quaternions "left" and "right"
  60048. * @param left defines the left operand
  60049. * @param right defines the right operand
  60050. * @returns the dot product
  60051. */
  60052. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60053. /**
  60054. * Checks if the two quaternions are close to each other
  60055. * @param quat0 defines the first quaternion to check
  60056. * @param quat1 defines the second quaternion to check
  60057. * @returns true if the two quaternions are close to each other
  60058. */
  60059. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60060. /**
  60061. * Creates an empty quaternion
  60062. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60063. */
  60064. static Zero(): Quaternion;
  60065. /**
  60066. * Inverse a given quaternion
  60067. * @param q defines the source quaternion
  60068. * @returns a new quaternion as the inverted current quaternion
  60069. */
  60070. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60071. /**
  60072. * Inverse a given quaternion
  60073. * @param q defines the source quaternion
  60074. * @param result the quaternion the result will be stored in
  60075. * @returns the result quaternion
  60076. */
  60077. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60078. /**
  60079. * Creates an identity quaternion
  60080. * @returns the identity quaternion
  60081. */
  60082. static Identity(): Quaternion;
  60083. /**
  60084. * Gets a boolean indicating if the given quaternion is identity
  60085. * @param quaternion defines the quaternion to check
  60086. * @returns true if the quaternion is identity
  60087. */
  60088. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60089. /**
  60090. * Creates a quaternion from a rotation around an axis
  60091. * @param axis defines the axis to use
  60092. * @param angle defines the angle to use
  60093. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60094. */
  60095. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60096. /**
  60097. * Creates a rotation around an axis and stores it into the given quaternion
  60098. * @param axis defines the axis to use
  60099. * @param angle defines the angle to use
  60100. * @param result defines the target quaternion
  60101. * @returns the target quaternion
  60102. */
  60103. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60104. /**
  60105. * Creates a new quaternion from data stored into an array
  60106. * @param array defines the data source
  60107. * @param offset defines the offset in the source array where the data starts
  60108. * @returns a new quaternion
  60109. */
  60110. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60111. /**
  60112. * Create a quaternion from Euler rotation angles
  60113. * @param x Pitch
  60114. * @param y Yaw
  60115. * @param z Roll
  60116. * @returns the new Quaternion
  60117. */
  60118. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60119. /**
  60120. * Updates a quaternion from Euler rotation angles
  60121. * @param x Pitch
  60122. * @param y Yaw
  60123. * @param z Roll
  60124. * @param result the quaternion to store the result
  60125. * @returns the updated quaternion
  60126. */
  60127. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60128. /**
  60129. * Create a quaternion from Euler rotation vector
  60130. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60131. * @returns the new Quaternion
  60132. */
  60133. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60134. /**
  60135. * Updates a quaternion from Euler rotation vector
  60136. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60137. * @param result the quaternion to store the result
  60138. * @returns the updated quaternion
  60139. */
  60140. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60141. /**
  60142. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60143. * @param yaw defines the rotation around Y axis
  60144. * @param pitch defines the rotation around X axis
  60145. * @param roll defines the rotation around Z axis
  60146. * @returns the new quaternion
  60147. */
  60148. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60149. /**
  60150. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60151. * @param yaw defines the rotation around Y axis
  60152. * @param pitch defines the rotation around X axis
  60153. * @param roll defines the rotation around Z axis
  60154. * @param result defines the target quaternion
  60155. */
  60156. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60157. /**
  60158. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60159. * @param alpha defines the rotation around first axis
  60160. * @param beta defines the rotation around second axis
  60161. * @param gamma defines the rotation around third axis
  60162. * @returns the new quaternion
  60163. */
  60164. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60165. /**
  60166. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60167. * @param alpha defines the rotation around first axis
  60168. * @param beta defines the rotation around second axis
  60169. * @param gamma defines the rotation around third axis
  60170. * @param result defines the target quaternion
  60171. */
  60172. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60173. /**
  60174. * 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)
  60175. * @param axis1 defines the first axis
  60176. * @param axis2 defines the second axis
  60177. * @param axis3 defines the third axis
  60178. * @returns the new quaternion
  60179. */
  60180. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60181. /**
  60182. * 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
  60183. * @param axis1 defines the first axis
  60184. * @param axis2 defines the second axis
  60185. * @param axis3 defines the third axis
  60186. * @param ref defines the target quaternion
  60187. */
  60188. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60189. /**
  60190. * Interpolates between two quaternions
  60191. * @param left defines first quaternion
  60192. * @param right defines second quaternion
  60193. * @param amount defines the gradient to use
  60194. * @returns the new interpolated quaternion
  60195. */
  60196. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60197. /**
  60198. * Interpolates between two quaternions and stores it into a target quaternion
  60199. * @param left defines first quaternion
  60200. * @param right defines second quaternion
  60201. * @param amount defines the gradient to use
  60202. * @param result defines the target quaternion
  60203. */
  60204. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60205. /**
  60206. * Interpolate between two quaternions using Hermite interpolation
  60207. * @param value1 defines first quaternion
  60208. * @param tangent1 defines the incoming tangent
  60209. * @param value2 defines second quaternion
  60210. * @param tangent2 defines the outgoing tangent
  60211. * @param amount defines the target quaternion
  60212. * @returns the new interpolated quaternion
  60213. */
  60214. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60215. }
  60216. /**
  60217. * Class used to store matrix data (4x4)
  60218. */
  60219. export class Matrix {
  60220. private static _updateFlagSeed;
  60221. private static _identityReadOnly;
  60222. private _isIdentity;
  60223. private _isIdentityDirty;
  60224. private _isIdentity3x2;
  60225. private _isIdentity3x2Dirty;
  60226. /**
  60227. * Gets the update flag of the matrix which is an unique number for the matrix.
  60228. * It will be incremented every time the matrix data change.
  60229. * You can use it to speed the comparison between two versions of the same matrix.
  60230. */
  60231. updateFlag: number;
  60232. private readonly _m;
  60233. /**
  60234. * Gets the internal data of the matrix
  60235. */
  60236. readonly m: DeepImmutable<Float32Array>;
  60237. /** @hidden */
  60238. _markAsUpdated(): void;
  60239. /** @hidden */
  60240. private _updateIdentityStatus;
  60241. /**
  60242. * Creates an empty matrix (filled with zeros)
  60243. */
  60244. constructor();
  60245. /**
  60246. * Check if the current matrix is identity
  60247. * @returns true is the matrix is the identity matrix
  60248. */
  60249. isIdentity(): boolean;
  60250. /**
  60251. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60252. * @returns true is the matrix is the identity matrix
  60253. */
  60254. isIdentityAs3x2(): boolean;
  60255. /**
  60256. * Gets the determinant of the matrix
  60257. * @returns the matrix determinant
  60258. */
  60259. determinant(): number;
  60260. /**
  60261. * Returns the matrix as a Float32Array
  60262. * @returns the matrix underlying array
  60263. */
  60264. toArray(): DeepImmutable<Float32Array>;
  60265. /**
  60266. * Returns the matrix as a Float32Array
  60267. * @returns the matrix underlying array.
  60268. */
  60269. asArray(): DeepImmutable<Float32Array>;
  60270. /**
  60271. * Inverts the current matrix in place
  60272. * @returns the current inverted matrix
  60273. */
  60274. invert(): Matrix;
  60275. /**
  60276. * Sets all the matrix elements to zero
  60277. * @returns the current matrix
  60278. */
  60279. reset(): Matrix;
  60280. /**
  60281. * Adds the current matrix with a second one
  60282. * @param other defines the matrix to add
  60283. * @returns a new matrix as the addition of the current matrix and the given one
  60284. */
  60285. add(other: DeepImmutable<Matrix>): Matrix;
  60286. /**
  60287. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60288. * @param other defines the matrix to add
  60289. * @param result defines the target matrix
  60290. * @returns the current matrix
  60291. */
  60292. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60293. /**
  60294. * Adds in place the given matrix to the current matrix
  60295. * @param other defines the second operand
  60296. * @returns the current updated matrix
  60297. */
  60298. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60299. /**
  60300. * Sets the given matrix to the current inverted Matrix
  60301. * @param other defines the target matrix
  60302. * @returns the unmodified current matrix
  60303. */
  60304. invertToRef(other: Matrix): Matrix;
  60305. /**
  60306. * add a value at the specified position in the current Matrix
  60307. * @param index the index of the value within the matrix. between 0 and 15.
  60308. * @param value the value to be added
  60309. * @returns the current updated matrix
  60310. */
  60311. addAtIndex(index: number, value: number): Matrix;
  60312. /**
  60313. * mutiply the specified position in the current Matrix by a value
  60314. * @param index the index of the value within the matrix. between 0 and 15.
  60315. * @param value the value to be added
  60316. * @returns the current updated matrix
  60317. */
  60318. multiplyAtIndex(index: number, value: number): Matrix;
  60319. /**
  60320. * Inserts the translation vector (using 3 floats) in the current matrix
  60321. * @param x defines the 1st component of the translation
  60322. * @param y defines the 2nd component of the translation
  60323. * @param z defines the 3rd component of the translation
  60324. * @returns the current updated matrix
  60325. */
  60326. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60327. /**
  60328. * Inserts the translation vector in the current matrix
  60329. * @param vector3 defines the translation to insert
  60330. * @returns the current updated matrix
  60331. */
  60332. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60333. /**
  60334. * Gets the translation value of the current matrix
  60335. * @returns a new Vector3 as the extracted translation from the matrix
  60336. */
  60337. getTranslation(): Vector3;
  60338. /**
  60339. * Fill a Vector3 with the extracted translation from the matrix
  60340. * @param result defines the Vector3 where to store the translation
  60341. * @returns the current matrix
  60342. */
  60343. getTranslationToRef(result: Vector3): Matrix;
  60344. /**
  60345. * Remove rotation and scaling part from the matrix
  60346. * @returns the updated matrix
  60347. */
  60348. removeRotationAndScaling(): Matrix;
  60349. /**
  60350. * Multiply two matrices
  60351. * @param other defines the second operand
  60352. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60353. */
  60354. multiply(other: DeepImmutable<Matrix>): Matrix;
  60355. /**
  60356. * Copy the current matrix from the given one
  60357. * @param other defines the source matrix
  60358. * @returns the current updated matrix
  60359. */
  60360. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60361. /**
  60362. * Populates the given array from the starting index with the current matrix values
  60363. * @param array defines the target array
  60364. * @param offset defines the offset in the target array where to start storing values
  60365. * @returns the current matrix
  60366. */
  60367. copyToArray(array: Float32Array, offset?: number): Matrix;
  60368. /**
  60369. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60370. * @param other defines the second operand
  60371. * @param result defines the matrix where to store the multiplication
  60372. * @returns the current matrix
  60373. */
  60374. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60375. /**
  60376. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60377. * @param other defines the second operand
  60378. * @param result defines the array where to store the multiplication
  60379. * @param offset defines the offset in the target array where to start storing values
  60380. * @returns the current matrix
  60381. */
  60382. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60383. /**
  60384. * Check equality between this matrix and a second one
  60385. * @param value defines the second matrix to compare
  60386. * @returns true is the current matrix and the given one values are strictly equal
  60387. */
  60388. equals(value: DeepImmutable<Matrix>): boolean;
  60389. /**
  60390. * Clone the current matrix
  60391. * @returns a new matrix from the current matrix
  60392. */
  60393. clone(): Matrix;
  60394. /**
  60395. * Returns the name of the current matrix class
  60396. * @returns the string "Matrix"
  60397. */
  60398. getClassName(): string;
  60399. /**
  60400. * Gets the hash code of the current matrix
  60401. * @returns the hash code
  60402. */
  60403. getHashCode(): number;
  60404. /**
  60405. * Decomposes the current Matrix into a translation, rotation and scaling components
  60406. * @param scale defines the scale vector3 given as a reference to update
  60407. * @param rotation defines the rotation quaternion given as a reference to update
  60408. * @param translation defines the translation vector3 given as a reference to update
  60409. * @returns true if operation was successful
  60410. */
  60411. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60412. /**
  60413. * Gets specific row of the matrix
  60414. * @param index defines the number of the row to get
  60415. * @returns the index-th row of the current matrix as a new Vector4
  60416. */
  60417. getRow(index: number): Nullable<Vector4>;
  60418. /**
  60419. * Sets the index-th row of the current matrix to the vector4 values
  60420. * @param index defines the number of the row to set
  60421. * @param row defines the target vector4
  60422. * @returns the updated current matrix
  60423. */
  60424. setRow(index: number, row: Vector4): Matrix;
  60425. /**
  60426. * Compute the transpose of the matrix
  60427. * @returns the new transposed matrix
  60428. */
  60429. transpose(): Matrix;
  60430. /**
  60431. * Compute the transpose of the matrix and store it in a given matrix
  60432. * @param result defines the target matrix
  60433. * @returns the current matrix
  60434. */
  60435. transposeToRef(result: Matrix): Matrix;
  60436. /**
  60437. * Sets the index-th row of the current matrix with the given 4 x float values
  60438. * @param index defines the row index
  60439. * @param x defines the x component to set
  60440. * @param y defines the y component to set
  60441. * @param z defines the z component to set
  60442. * @param w defines the w component to set
  60443. * @returns the updated current matrix
  60444. */
  60445. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60446. /**
  60447. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60448. * @param scale defines the scale factor
  60449. * @returns a new matrix
  60450. */
  60451. scale(scale: number): Matrix;
  60452. /**
  60453. * Scale the current matrix values by a factor to a given result matrix
  60454. * @param scale defines the scale factor
  60455. * @param result defines the matrix to store the result
  60456. * @returns the current matrix
  60457. */
  60458. scaleToRef(scale: number, result: Matrix): Matrix;
  60459. /**
  60460. * Scale the current matrix values by a factor and add the result to a given matrix
  60461. * @param scale defines the scale factor
  60462. * @param result defines the Matrix to store the result
  60463. * @returns the current matrix
  60464. */
  60465. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60466. /**
  60467. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60468. * @param ref matrix to store the result
  60469. */
  60470. toNormalMatrix(ref: Matrix): void;
  60471. /**
  60472. * Gets only rotation part of the current matrix
  60473. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60474. */
  60475. getRotationMatrix(): Matrix;
  60476. /**
  60477. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60478. * @param result defines the target matrix to store data to
  60479. * @returns the current matrix
  60480. */
  60481. getRotationMatrixToRef(result: Matrix): Matrix;
  60482. /**
  60483. * Toggles model matrix from being right handed to left handed in place and vice versa
  60484. */
  60485. toggleModelMatrixHandInPlace(): void;
  60486. /**
  60487. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60488. */
  60489. toggleProjectionMatrixHandInPlace(): void;
  60490. /**
  60491. * Creates a matrix from an array
  60492. * @param array defines the source array
  60493. * @param offset defines an offset in the source array
  60494. * @returns a new Matrix set from the starting index of the given array
  60495. */
  60496. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60497. /**
  60498. * Copy the content of an array into a given matrix
  60499. * @param array defines the source array
  60500. * @param offset defines an offset in the source array
  60501. * @param result defines the target matrix
  60502. */
  60503. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60504. /**
  60505. * Stores an array into a matrix after having multiplied each component by a given factor
  60506. * @param array defines the source array
  60507. * @param offset defines the offset in the source array
  60508. * @param scale defines the scaling factor
  60509. * @param result defines the target matrix
  60510. */
  60511. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60512. /**
  60513. * Gets an identity matrix that must not be updated
  60514. */
  60515. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60516. /**
  60517. * Stores a list of values (16) inside a given matrix
  60518. * @param initialM11 defines 1st value of 1st row
  60519. * @param initialM12 defines 2nd value of 1st row
  60520. * @param initialM13 defines 3rd value of 1st row
  60521. * @param initialM14 defines 4th value of 1st row
  60522. * @param initialM21 defines 1st value of 2nd row
  60523. * @param initialM22 defines 2nd value of 2nd row
  60524. * @param initialM23 defines 3rd value of 2nd row
  60525. * @param initialM24 defines 4th value of 2nd row
  60526. * @param initialM31 defines 1st value of 3rd row
  60527. * @param initialM32 defines 2nd value of 3rd row
  60528. * @param initialM33 defines 3rd value of 3rd row
  60529. * @param initialM34 defines 4th value of 3rd row
  60530. * @param initialM41 defines 1st value of 4th row
  60531. * @param initialM42 defines 2nd value of 4th row
  60532. * @param initialM43 defines 3rd value of 4th row
  60533. * @param initialM44 defines 4th value of 4th row
  60534. * @param result defines the target matrix
  60535. */
  60536. 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;
  60537. /**
  60538. * Creates new matrix from a list of values (16)
  60539. * @param initialM11 defines 1st value of 1st row
  60540. * @param initialM12 defines 2nd value of 1st row
  60541. * @param initialM13 defines 3rd value of 1st row
  60542. * @param initialM14 defines 4th value of 1st row
  60543. * @param initialM21 defines 1st value of 2nd row
  60544. * @param initialM22 defines 2nd value of 2nd row
  60545. * @param initialM23 defines 3rd value of 2nd row
  60546. * @param initialM24 defines 4th value of 2nd row
  60547. * @param initialM31 defines 1st value of 3rd row
  60548. * @param initialM32 defines 2nd value of 3rd row
  60549. * @param initialM33 defines 3rd value of 3rd row
  60550. * @param initialM34 defines 4th value of 3rd row
  60551. * @param initialM41 defines 1st value of 4th row
  60552. * @param initialM42 defines 2nd value of 4th row
  60553. * @param initialM43 defines 3rd value of 4th row
  60554. * @param initialM44 defines 4th value of 4th row
  60555. * @returns the new matrix
  60556. */
  60557. 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;
  60558. /**
  60559. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60560. * @param scale defines the scale vector3
  60561. * @param rotation defines the rotation quaternion
  60562. * @param translation defines the translation vector3
  60563. * @returns a new matrix
  60564. */
  60565. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60566. /**
  60567. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60568. * @param scale defines the scale vector3
  60569. * @param rotation defines the rotation quaternion
  60570. * @param translation defines the translation vector3
  60571. * @param result defines the target matrix
  60572. */
  60573. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60574. /**
  60575. * Creates a new identity matrix
  60576. * @returns a new identity matrix
  60577. */
  60578. static Identity(): Matrix;
  60579. /**
  60580. * Creates a new identity matrix and stores the result in a given matrix
  60581. * @param result defines the target matrix
  60582. */
  60583. static IdentityToRef(result: Matrix): void;
  60584. /**
  60585. * Creates a new zero matrix
  60586. * @returns a new zero matrix
  60587. */
  60588. static Zero(): Matrix;
  60589. /**
  60590. * Creates a new rotation matrix for "angle" radians around the X axis
  60591. * @param angle defines the angle (in radians) to use
  60592. * @return the new matrix
  60593. */
  60594. static RotationX(angle: number): Matrix;
  60595. /**
  60596. * Creates a new matrix as the invert of a given matrix
  60597. * @param source defines the source matrix
  60598. * @returns the new matrix
  60599. */
  60600. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60601. /**
  60602. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60603. * @param angle defines the angle (in radians) to use
  60604. * @param result defines the target matrix
  60605. */
  60606. static RotationXToRef(angle: number, result: Matrix): void;
  60607. /**
  60608. * Creates a new rotation matrix for "angle" radians around the Y axis
  60609. * @param angle defines the angle (in radians) to use
  60610. * @return the new matrix
  60611. */
  60612. static RotationY(angle: number): Matrix;
  60613. /**
  60614. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60615. * @param angle defines the angle (in radians) to use
  60616. * @param result defines the target matrix
  60617. */
  60618. static RotationYToRef(angle: number, result: Matrix): void;
  60619. /**
  60620. * Creates a new rotation matrix for "angle" radians around the Z axis
  60621. * @param angle defines the angle (in radians) to use
  60622. * @return the new matrix
  60623. */
  60624. static RotationZ(angle: number): Matrix;
  60625. /**
  60626. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  60627. * @param angle defines the angle (in radians) to use
  60628. * @param result defines the target matrix
  60629. */
  60630. static RotationZToRef(angle: number, result: Matrix): void;
  60631. /**
  60632. * Creates a new rotation matrix for "angle" radians around the given axis
  60633. * @param axis defines the axis to use
  60634. * @param angle defines the angle (in radians) to use
  60635. * @return the new matrix
  60636. */
  60637. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  60638. /**
  60639. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  60640. * @param axis defines the axis to use
  60641. * @param angle defines the angle (in radians) to use
  60642. * @param result defines the target matrix
  60643. */
  60644. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  60645. /**
  60646. * Creates a rotation matrix
  60647. * @param yaw defines the yaw angle in radians (Y axis)
  60648. * @param pitch defines the pitch angle in radians (X axis)
  60649. * @param roll defines the roll angle in radians (X axis)
  60650. * @returns the new rotation matrix
  60651. */
  60652. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  60653. /**
  60654. * Creates a rotation matrix and stores it in a given matrix
  60655. * @param yaw defines the yaw angle in radians (Y axis)
  60656. * @param pitch defines the pitch angle in radians (X axis)
  60657. * @param roll defines the roll angle in radians (X axis)
  60658. * @param result defines the target matrix
  60659. */
  60660. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  60661. /**
  60662. * Creates a scaling matrix
  60663. * @param x defines the scale factor on X axis
  60664. * @param y defines the scale factor on Y axis
  60665. * @param z defines the scale factor on Z axis
  60666. * @returns the new matrix
  60667. */
  60668. static Scaling(x: number, y: number, z: number): Matrix;
  60669. /**
  60670. * Creates a scaling matrix and stores it in a given matrix
  60671. * @param x defines the scale factor on X axis
  60672. * @param y defines the scale factor on Y axis
  60673. * @param z defines the scale factor on Z axis
  60674. * @param result defines the target matrix
  60675. */
  60676. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  60677. /**
  60678. * Creates a translation matrix
  60679. * @param x defines the translation on X axis
  60680. * @param y defines the translation on Y axis
  60681. * @param z defines the translationon Z axis
  60682. * @returns the new matrix
  60683. */
  60684. static Translation(x: number, y: number, z: number): Matrix;
  60685. /**
  60686. * Creates a translation matrix and stores it in a given matrix
  60687. * @param x defines the translation on X axis
  60688. * @param y defines the translation on Y axis
  60689. * @param z defines the translationon Z axis
  60690. * @param result defines the target matrix
  60691. */
  60692. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  60693. /**
  60694. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60695. * @param startValue defines the start value
  60696. * @param endValue defines the end value
  60697. * @param gradient defines the gradient factor
  60698. * @returns the new matrix
  60699. */
  60700. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60701. /**
  60702. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60703. * @param startValue defines the start value
  60704. * @param endValue defines the end value
  60705. * @param gradient defines the gradient factor
  60706. * @param result defines the Matrix object where to store data
  60707. */
  60708. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60709. /**
  60710. * Builds a new matrix whose values are computed by:
  60711. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60712. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60713. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60714. * @param startValue defines the first matrix
  60715. * @param endValue defines the second matrix
  60716. * @param gradient defines the gradient between the two matrices
  60717. * @returns the new matrix
  60718. */
  60719. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60720. /**
  60721. * Update a matrix to values which are computed by:
  60722. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60723. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60724. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60725. * @param startValue defines the first matrix
  60726. * @param endValue defines the second matrix
  60727. * @param gradient defines the gradient between the two matrices
  60728. * @param result defines the target matrix
  60729. */
  60730. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60731. /**
  60732. * 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"
  60733. * This function works in left handed mode
  60734. * @param eye defines the final position of the entity
  60735. * @param target defines where the entity should look at
  60736. * @param up defines the up vector for the entity
  60737. * @returns the new matrix
  60738. */
  60739. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60740. /**
  60741. * 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".
  60742. * This function works in left handed mode
  60743. * @param eye defines the final position of the entity
  60744. * @param target defines where the entity should look at
  60745. * @param up defines the up vector for the entity
  60746. * @param result defines the target matrix
  60747. */
  60748. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60749. /**
  60750. * 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"
  60751. * This function works in right handed mode
  60752. * @param eye defines the final position of the entity
  60753. * @param target defines where the entity should look at
  60754. * @param up defines the up vector for the entity
  60755. * @returns the new matrix
  60756. */
  60757. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60758. /**
  60759. * 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".
  60760. * This function works in right handed mode
  60761. * @param eye defines the final position of the entity
  60762. * @param target defines where the entity should look at
  60763. * @param up defines the up vector for the entity
  60764. * @param result defines the target matrix
  60765. */
  60766. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60767. /**
  60768. * Create a left-handed orthographic projection matrix
  60769. * @param width defines the viewport width
  60770. * @param height defines the viewport height
  60771. * @param znear defines the near clip plane
  60772. * @param zfar defines the far clip plane
  60773. * @returns a new matrix as a left-handed orthographic projection matrix
  60774. */
  60775. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60776. /**
  60777. * Store a left-handed orthographic projection to a given matrix
  60778. * @param width defines the viewport width
  60779. * @param height defines the viewport height
  60780. * @param znear defines the near clip plane
  60781. * @param zfar defines the far clip plane
  60782. * @param result defines the target matrix
  60783. */
  60784. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  60785. /**
  60786. * Create a left-handed orthographic projection matrix
  60787. * @param left defines the viewport left coordinate
  60788. * @param right defines the viewport right coordinate
  60789. * @param bottom defines the viewport bottom coordinate
  60790. * @param top defines the viewport top coordinate
  60791. * @param znear defines the near clip plane
  60792. * @param zfar defines the far clip plane
  60793. * @returns a new matrix as a left-handed orthographic projection matrix
  60794. */
  60795. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60796. /**
  60797. * Stores a left-handed orthographic projection into a given matrix
  60798. * @param left defines the viewport left coordinate
  60799. * @param right defines the viewport right coordinate
  60800. * @param bottom defines the viewport bottom coordinate
  60801. * @param top defines the viewport top coordinate
  60802. * @param znear defines the near clip plane
  60803. * @param zfar defines the far clip plane
  60804. * @param result defines the target matrix
  60805. */
  60806. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60807. /**
  60808. * Creates a right-handed orthographic projection matrix
  60809. * @param left defines the viewport left coordinate
  60810. * @param right defines the viewport right coordinate
  60811. * @param bottom defines the viewport bottom coordinate
  60812. * @param top defines the viewport top coordinate
  60813. * @param znear defines the near clip plane
  60814. * @param zfar defines the far clip plane
  60815. * @returns a new matrix as a right-handed orthographic projection matrix
  60816. */
  60817. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60818. /**
  60819. * Stores a right-handed orthographic projection into a given matrix
  60820. * @param left defines the viewport left coordinate
  60821. * @param right defines the viewport right coordinate
  60822. * @param bottom defines the viewport bottom coordinate
  60823. * @param top defines the viewport top coordinate
  60824. * @param znear defines the near clip plane
  60825. * @param zfar defines the far clip plane
  60826. * @param result defines the target matrix
  60827. */
  60828. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60829. /**
  60830. * Creates a left-handed perspective projection matrix
  60831. * @param width defines the viewport width
  60832. * @param height defines the viewport height
  60833. * @param znear defines the near clip plane
  60834. * @param zfar defines the far clip plane
  60835. * @returns a new matrix as a left-handed perspective projection matrix
  60836. */
  60837. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60838. /**
  60839. * Creates a left-handed perspective projection matrix
  60840. * @param fov defines the horizontal field of view
  60841. * @param aspect defines the aspect ratio
  60842. * @param znear defines the near clip plane
  60843. * @param zfar defines the far clip plane
  60844. * @returns a new matrix as a left-handed perspective projection matrix
  60845. */
  60846. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60847. /**
  60848. * Stores a left-handed perspective projection into a given matrix
  60849. * @param fov defines the horizontal field of view
  60850. * @param aspect defines the aspect ratio
  60851. * @param znear defines the near clip plane
  60852. * @param zfar defines the far clip plane
  60853. * @param result defines the target matrix
  60854. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60855. */
  60856. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60857. /**
  60858. * Creates a right-handed perspective projection matrix
  60859. * @param fov defines the horizontal field of view
  60860. * @param aspect defines the aspect ratio
  60861. * @param znear defines the near clip plane
  60862. * @param zfar defines the far clip plane
  60863. * @returns a new matrix as a right-handed perspective projection matrix
  60864. */
  60865. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60866. /**
  60867. * Stores a right-handed perspective projection into a given matrix
  60868. * @param fov defines the horizontal field of view
  60869. * @param aspect defines the aspect ratio
  60870. * @param znear defines the near clip plane
  60871. * @param zfar defines the far clip plane
  60872. * @param result defines the target matrix
  60873. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60874. */
  60875. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60876. /**
  60877. * Stores a perspective projection for WebVR info a given matrix
  60878. * @param fov defines the field of view
  60879. * @param znear defines the near clip plane
  60880. * @param zfar defines the far clip plane
  60881. * @param result defines the target matrix
  60882. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  60883. */
  60884. static PerspectiveFovWebVRToRef(fov: {
  60885. upDegrees: number;
  60886. downDegrees: number;
  60887. leftDegrees: number;
  60888. rightDegrees: number;
  60889. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  60890. /**
  60891. * Computes a complete transformation matrix
  60892. * @param viewport defines the viewport to use
  60893. * @param world defines the world matrix
  60894. * @param view defines the view matrix
  60895. * @param projection defines the projection matrix
  60896. * @param zmin defines the near clip plane
  60897. * @param zmax defines the far clip plane
  60898. * @returns the transformation matrix
  60899. */
  60900. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  60901. /**
  60902. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  60903. * @param matrix defines the matrix to use
  60904. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  60905. */
  60906. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  60907. /**
  60908. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  60909. * @param matrix defines the matrix to use
  60910. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  60911. */
  60912. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  60913. /**
  60914. * Compute the transpose of a given matrix
  60915. * @param matrix defines the matrix to transpose
  60916. * @returns the new matrix
  60917. */
  60918. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  60919. /**
  60920. * Compute the transpose of a matrix and store it in a target matrix
  60921. * @param matrix defines the matrix to transpose
  60922. * @param result defines the target matrix
  60923. */
  60924. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  60925. /**
  60926. * Computes a reflection matrix from a plane
  60927. * @param plane defines the reflection plane
  60928. * @returns a new matrix
  60929. */
  60930. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  60931. /**
  60932. * Computes a reflection matrix from a plane
  60933. * @param plane defines the reflection plane
  60934. * @param result defines the target matrix
  60935. */
  60936. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  60937. /**
  60938. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  60939. * @param xaxis defines the value of the 1st axis
  60940. * @param yaxis defines the value of the 2nd axis
  60941. * @param zaxis defines the value of the 3rd axis
  60942. * @param result defines the target matrix
  60943. */
  60944. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  60945. /**
  60946. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  60947. * @param quat defines the quaternion to use
  60948. * @param result defines the target matrix
  60949. */
  60950. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  60951. }
  60952. /**
  60953. * Represens a plane by the equation ax + by + cz + d = 0
  60954. */
  60955. export class Plane {
  60956. /**
  60957. * Normal of the plane (a,b,c)
  60958. */
  60959. normal: Vector3;
  60960. /**
  60961. * d component of the plane
  60962. */
  60963. d: number;
  60964. /**
  60965. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  60966. * @param a a component of the plane
  60967. * @param b b component of the plane
  60968. * @param c c component of the plane
  60969. * @param d d component of the plane
  60970. */
  60971. constructor(a: number, b: number, c: number, d: number);
  60972. /**
  60973. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  60974. */
  60975. asArray(): number[];
  60976. /**
  60977. * @returns a new plane copied from the current Plane.
  60978. */
  60979. clone(): Plane;
  60980. /**
  60981. * @returns the string "Plane".
  60982. */
  60983. getClassName(): string;
  60984. /**
  60985. * @returns the Plane hash code.
  60986. */
  60987. getHashCode(): number;
  60988. /**
  60989. * Normalize the current Plane in place.
  60990. * @returns the updated Plane.
  60991. */
  60992. normalize(): Plane;
  60993. /**
  60994. * Applies a transformation the plane and returns the result
  60995. * @param transformation the transformation matrix to be applied to the plane
  60996. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  60997. */
  60998. transform(transformation: DeepImmutable<Matrix>): Plane;
  60999. /**
  61000. * Calcualtte the dot product between the point and the plane normal
  61001. * @param point point to calculate the dot product with
  61002. * @returns the dot product (float) of the point coordinates and the plane normal.
  61003. */
  61004. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61005. /**
  61006. * Updates the current Plane from the plane defined by the three given points.
  61007. * @param point1 one of the points used to contruct the plane
  61008. * @param point2 one of the points used to contruct the plane
  61009. * @param point3 one of the points used to contruct the plane
  61010. * @returns the updated Plane.
  61011. */
  61012. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61013. /**
  61014. * Checks if the plane is facing a given direction
  61015. * @param direction the direction to check if the plane is facing
  61016. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61017. * @returns True is the vector "direction" is the same side than the plane normal.
  61018. */
  61019. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61020. /**
  61021. * Calculates the distance to a point
  61022. * @param point point to calculate distance to
  61023. * @returns the signed distance (float) from the given point to the Plane.
  61024. */
  61025. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61026. /**
  61027. * Creates a plane from an array
  61028. * @param array the array to create a plane from
  61029. * @returns a new Plane from the given array.
  61030. */
  61031. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  61032. /**
  61033. * Creates a plane from three points
  61034. * @param point1 point used to create the plane
  61035. * @param point2 point used to create the plane
  61036. * @param point3 point used to create the plane
  61037. * @returns a new Plane defined by the three given points.
  61038. */
  61039. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61040. /**
  61041. * Creates a plane from an origin point and a normal
  61042. * @param origin origin of the plane to be constructed
  61043. * @param normal normal of the plane to be constructed
  61044. * @returns a new Plane the normal vector to this plane at the given origin point.
  61045. * Note : the vector "normal" is updated because normalized.
  61046. */
  61047. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  61048. /**
  61049. * Calculates the distance from a plane and a point
  61050. * @param origin origin of the plane to be constructed
  61051. * @param normal normal of the plane to be constructed
  61052. * @param point point to calculate distance to
  61053. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61054. */
  61055. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61056. }
  61057. /**
  61058. * Class used to represent a viewport on screen
  61059. */
  61060. export class Viewport {
  61061. /** viewport left coordinate */
  61062. x: number;
  61063. /** viewport top coordinate */
  61064. y: number;
  61065. /**viewport width */
  61066. width: number;
  61067. /** viewport height */
  61068. height: number;
  61069. /**
  61070. * Creates a Viewport object located at (x, y) and sized (width, height)
  61071. * @param x defines viewport left coordinate
  61072. * @param y defines viewport top coordinate
  61073. * @param width defines the viewport width
  61074. * @param height defines the viewport height
  61075. */
  61076. constructor(
  61077. /** viewport left coordinate */
  61078. x: number,
  61079. /** viewport top coordinate */
  61080. y: number,
  61081. /**viewport width */
  61082. width: number,
  61083. /** viewport height */
  61084. height: number);
  61085. /**
  61086. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61087. * @param renderWidth defines the rendering width
  61088. * @param renderHeight defines the rendering height
  61089. * @returns a new Viewport
  61090. */
  61091. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61092. /**
  61093. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61094. * @param renderWidth defines the rendering width
  61095. * @param renderHeight defines the rendering height
  61096. * @param ref defines the target viewport
  61097. * @returns the current viewport
  61098. */
  61099. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61100. /**
  61101. * Returns a new Viewport copied from the current one
  61102. * @returns a new Viewport
  61103. */
  61104. clone(): Viewport;
  61105. }
  61106. /**
  61107. * Reprasents a camera frustum
  61108. */
  61109. export class Frustum {
  61110. /**
  61111. * Gets the planes representing the frustum
  61112. * @param transform matrix to be applied to the returned planes
  61113. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61114. */
  61115. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61116. /**
  61117. * Gets the near frustum plane transformed by the transform matrix
  61118. * @param transform transformation matrix to be applied to the resulting frustum plane
  61119. * @param frustumPlane the resuling frustum plane
  61120. */
  61121. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61122. /**
  61123. * Gets the far frustum plane transformed by the transform matrix
  61124. * @param transform transformation matrix to be applied to the resulting frustum plane
  61125. * @param frustumPlane the resuling frustum plane
  61126. */
  61127. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61128. /**
  61129. * Gets the left frustum plane transformed by the transform matrix
  61130. * @param transform transformation matrix to be applied to the resulting frustum plane
  61131. * @param frustumPlane the resuling frustum plane
  61132. */
  61133. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61134. /**
  61135. * Gets the right frustum plane transformed by the transform matrix
  61136. * @param transform transformation matrix to be applied to the resulting frustum plane
  61137. * @param frustumPlane the resuling frustum plane
  61138. */
  61139. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61140. /**
  61141. * Gets the top frustum plane transformed by the transform matrix
  61142. * @param transform transformation matrix to be applied to the resulting frustum plane
  61143. * @param frustumPlane the resuling frustum plane
  61144. */
  61145. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61146. /**
  61147. * Gets the bottom frustum plane transformed by the transform matrix
  61148. * @param transform transformation matrix to be applied to the resulting frustum plane
  61149. * @param frustumPlane the resuling frustum plane
  61150. */
  61151. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61152. /**
  61153. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61154. * @param transform transformation matrix to be applied to the resulting frustum planes
  61155. * @param frustumPlanes the resuling frustum planes
  61156. */
  61157. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61158. }
  61159. /** Defines supported spaces */
  61160. export enum Space {
  61161. /** Local (object) space */
  61162. LOCAL = 0,
  61163. /** World space */
  61164. WORLD = 1,
  61165. /** Bone space */
  61166. BONE = 2
  61167. }
  61168. /** Defines the 3 main axes */
  61169. export class Axis {
  61170. /** X axis */
  61171. static X: Vector3;
  61172. /** Y axis */
  61173. static Y: Vector3;
  61174. /** Z axis */
  61175. static Z: Vector3;
  61176. }
  61177. /** Class used to represent a Bezier curve */
  61178. export class BezierCurve {
  61179. /**
  61180. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61181. * @param t defines the time
  61182. * @param x1 defines the left coordinate on X axis
  61183. * @param y1 defines the left coordinate on Y axis
  61184. * @param x2 defines the right coordinate on X axis
  61185. * @param y2 defines the right coordinate on Y axis
  61186. * @returns the interpolated value
  61187. */
  61188. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61189. }
  61190. /**
  61191. * Defines potential orientation for back face culling
  61192. */
  61193. export enum Orientation {
  61194. /**
  61195. * Clockwise
  61196. */
  61197. CW = 0,
  61198. /** Counter clockwise */
  61199. CCW = 1
  61200. }
  61201. /**
  61202. * Defines angle representation
  61203. */
  61204. export class Angle {
  61205. private _radians;
  61206. /**
  61207. * Creates an Angle object of "radians" radians (float).
  61208. * @param radians the angle in radians
  61209. */
  61210. constructor(radians: number);
  61211. /**
  61212. * Get value in degrees
  61213. * @returns the Angle value in degrees (float)
  61214. */
  61215. degrees(): number;
  61216. /**
  61217. * Get value in radians
  61218. * @returns the Angle value in radians (float)
  61219. */
  61220. radians(): number;
  61221. /**
  61222. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61223. * @param a defines first vector
  61224. * @param b defines second vector
  61225. * @returns a new Angle
  61226. */
  61227. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61228. /**
  61229. * Gets a new Angle object from the given float in radians
  61230. * @param radians defines the angle value in radians
  61231. * @returns a new Angle
  61232. */
  61233. static FromRadians(radians: number): Angle;
  61234. /**
  61235. * Gets a new Angle object from the given float in degrees
  61236. * @param degrees defines the angle value in degrees
  61237. * @returns a new Angle
  61238. */
  61239. static FromDegrees(degrees: number): Angle;
  61240. }
  61241. /**
  61242. * This represents an arc in a 2d space.
  61243. */
  61244. export class Arc2 {
  61245. /** Defines the start point of the arc */
  61246. startPoint: Vector2;
  61247. /** Defines the mid point of the arc */
  61248. midPoint: Vector2;
  61249. /** Defines the end point of the arc */
  61250. endPoint: Vector2;
  61251. /**
  61252. * Defines the center point of the arc.
  61253. */
  61254. centerPoint: Vector2;
  61255. /**
  61256. * Defines the radius of the arc.
  61257. */
  61258. radius: number;
  61259. /**
  61260. * Defines the angle of the arc (from mid point to end point).
  61261. */
  61262. angle: Angle;
  61263. /**
  61264. * Defines the start angle of the arc (from start point to middle point).
  61265. */
  61266. startAngle: Angle;
  61267. /**
  61268. * Defines the orientation of the arc (clock wise/counter clock wise).
  61269. */
  61270. orientation: Orientation;
  61271. /**
  61272. * Creates an Arc object from the three given points : start, middle and end.
  61273. * @param startPoint Defines the start point of the arc
  61274. * @param midPoint Defines the midlle point of the arc
  61275. * @param endPoint Defines the end point of the arc
  61276. */
  61277. constructor(
  61278. /** Defines the start point of the arc */
  61279. startPoint: Vector2,
  61280. /** Defines the mid point of the arc */
  61281. midPoint: Vector2,
  61282. /** Defines the end point of the arc */
  61283. endPoint: Vector2);
  61284. }
  61285. /**
  61286. * Represents a 2D path made up of multiple 2D points
  61287. */
  61288. export class Path2 {
  61289. private _points;
  61290. private _length;
  61291. /**
  61292. * If the path start and end point are the same
  61293. */
  61294. closed: boolean;
  61295. /**
  61296. * Creates a Path2 object from the starting 2D coordinates x and y.
  61297. * @param x the starting points x value
  61298. * @param y the starting points y value
  61299. */
  61300. constructor(x: number, y: number);
  61301. /**
  61302. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61303. * @param x the added points x value
  61304. * @param y the added points y value
  61305. * @returns the updated Path2.
  61306. */
  61307. addLineTo(x: number, y: number): Path2;
  61308. /**
  61309. * 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.
  61310. * @param midX middle point x value
  61311. * @param midY middle point y value
  61312. * @param endX end point x value
  61313. * @param endY end point y value
  61314. * @param numberOfSegments (default: 36)
  61315. * @returns the updated Path2.
  61316. */
  61317. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61318. /**
  61319. * Closes the Path2.
  61320. * @returns the Path2.
  61321. */
  61322. close(): Path2;
  61323. /**
  61324. * Gets the sum of the distance between each sequential point in the path
  61325. * @returns the Path2 total length (float).
  61326. */
  61327. length(): number;
  61328. /**
  61329. * Gets the points which construct the path
  61330. * @returns the Path2 internal array of points.
  61331. */
  61332. getPoints(): Vector2[];
  61333. /**
  61334. * Retreives the point at the distance aways from the starting point
  61335. * @param normalizedLengthPosition the length along the path to retreive the point from
  61336. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61337. */
  61338. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61339. /**
  61340. * Creates a new path starting from an x and y position
  61341. * @param x starting x value
  61342. * @param y starting y value
  61343. * @returns a new Path2 starting at the coordinates (x, y).
  61344. */
  61345. static StartingAt(x: number, y: number): Path2;
  61346. }
  61347. /**
  61348. * Represents a 3D path made up of multiple 3D points
  61349. */
  61350. export class Path3D {
  61351. /**
  61352. * an array of Vector3, the curve axis of the Path3D
  61353. */
  61354. path: Vector3[];
  61355. private _curve;
  61356. private _distances;
  61357. private _tangents;
  61358. private _normals;
  61359. private _binormals;
  61360. private _raw;
  61361. /**
  61362. * new Path3D(path, normal, raw)
  61363. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61364. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61365. * @param path an array of Vector3, the curve axis of the Path3D
  61366. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61367. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61368. */
  61369. constructor(
  61370. /**
  61371. * an array of Vector3, the curve axis of the Path3D
  61372. */
  61373. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61374. /**
  61375. * Returns the Path3D array of successive Vector3 designing its curve.
  61376. * @returns the Path3D array of successive Vector3 designing its curve.
  61377. */
  61378. getCurve(): Vector3[];
  61379. /**
  61380. * Returns an array populated with tangent vectors on each Path3D curve point.
  61381. * @returns an array populated with tangent vectors on each Path3D curve point.
  61382. */
  61383. getTangents(): Vector3[];
  61384. /**
  61385. * Returns an array populated with normal vectors on each Path3D curve point.
  61386. * @returns an array populated with normal vectors on each Path3D curve point.
  61387. */
  61388. getNormals(): Vector3[];
  61389. /**
  61390. * Returns an array populated with binormal vectors on each Path3D curve point.
  61391. * @returns an array populated with binormal vectors on each Path3D curve point.
  61392. */
  61393. getBinormals(): Vector3[];
  61394. /**
  61395. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61396. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61397. */
  61398. getDistances(): number[];
  61399. /**
  61400. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61401. * @param path path which all values are copied into the curves points
  61402. * @param firstNormal which should be projected onto the curve
  61403. * @returns the same object updated.
  61404. */
  61405. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61406. private _compute;
  61407. private _getFirstNonNullVector;
  61408. private _getLastNonNullVector;
  61409. private _normalVector;
  61410. }
  61411. /**
  61412. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61413. * A Curve3 is designed from a series of successive Vector3.
  61414. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61415. */
  61416. export class Curve3 {
  61417. private _points;
  61418. private _length;
  61419. /**
  61420. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61421. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61422. * @param v1 (Vector3) the control point
  61423. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61424. * @param nbPoints (integer) the wanted number of points in the curve
  61425. * @returns the created Curve3
  61426. */
  61427. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61428. /**
  61429. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61430. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61431. * @param v1 (Vector3) the first control point
  61432. * @param v2 (Vector3) the second control point
  61433. * @param v3 (Vector3) the end point of the Cubic Bezier
  61434. * @param nbPoints (integer) the wanted number of points in the curve
  61435. * @returns the created Curve3
  61436. */
  61437. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61438. /**
  61439. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61440. * @param p1 (Vector3) the origin point of the Hermite Spline
  61441. * @param t1 (Vector3) the tangent vector at the origin point
  61442. * @param p2 (Vector3) the end point of the Hermite Spline
  61443. * @param t2 (Vector3) the tangent vector at the end point
  61444. * @param nbPoints (integer) the wanted number of points in the curve
  61445. * @returns the created Curve3
  61446. */
  61447. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61448. /**
  61449. * Returns a Curve3 object along a CatmullRom Spline curve :
  61450. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61451. * @param nbPoints (integer) the wanted number of points between each curve control points
  61452. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61453. * @returns the created Curve3
  61454. */
  61455. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61456. /**
  61457. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61458. * A Curve3 is designed from a series of successive Vector3.
  61459. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61460. * @param points points which make up the curve
  61461. */
  61462. constructor(points: Vector3[]);
  61463. /**
  61464. * @returns the Curve3 stored array of successive Vector3
  61465. */
  61466. getPoints(): Vector3[];
  61467. /**
  61468. * @returns the computed length (float) of the curve.
  61469. */
  61470. length(): number;
  61471. /**
  61472. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61473. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61474. * curveA and curveB keep unchanged.
  61475. * @param curve the curve to continue from this curve
  61476. * @returns the newly constructed curve
  61477. */
  61478. continue(curve: DeepImmutable<Curve3>): Curve3;
  61479. private _computeLength;
  61480. }
  61481. /**
  61482. * Contains position and normal vectors for a vertex
  61483. */
  61484. export class PositionNormalVertex {
  61485. /** the position of the vertex (defaut: 0,0,0) */
  61486. position: Vector3;
  61487. /** the normal of the vertex (defaut: 0,1,0) */
  61488. normal: Vector3;
  61489. /**
  61490. * Creates a PositionNormalVertex
  61491. * @param position the position of the vertex (defaut: 0,0,0)
  61492. * @param normal the normal of the vertex (defaut: 0,1,0)
  61493. */
  61494. constructor(
  61495. /** the position of the vertex (defaut: 0,0,0) */
  61496. position?: Vector3,
  61497. /** the normal of the vertex (defaut: 0,1,0) */
  61498. normal?: Vector3);
  61499. /**
  61500. * Clones the PositionNormalVertex
  61501. * @returns the cloned PositionNormalVertex
  61502. */
  61503. clone(): PositionNormalVertex;
  61504. }
  61505. /**
  61506. * Contains position, normal and uv vectors for a vertex
  61507. */
  61508. export class PositionNormalTextureVertex {
  61509. /** the position of the vertex (defaut: 0,0,0) */
  61510. position: Vector3;
  61511. /** the normal of the vertex (defaut: 0,1,0) */
  61512. normal: Vector3;
  61513. /** the uv of the vertex (default: 0,0) */
  61514. uv: Vector2;
  61515. /**
  61516. * Creates a PositionNormalTextureVertex
  61517. * @param position the position of the vertex (defaut: 0,0,0)
  61518. * @param normal the normal of the vertex (defaut: 0,1,0)
  61519. * @param uv the uv of the vertex (default: 0,0)
  61520. */
  61521. constructor(
  61522. /** the position of the vertex (defaut: 0,0,0) */
  61523. position?: Vector3,
  61524. /** the normal of the vertex (defaut: 0,1,0) */
  61525. normal?: Vector3,
  61526. /** the uv of the vertex (default: 0,0) */
  61527. uv?: Vector2);
  61528. /**
  61529. * Clones the PositionNormalTextureVertex
  61530. * @returns the cloned PositionNormalTextureVertex
  61531. */
  61532. clone(): PositionNormalTextureVertex;
  61533. }
  61534. /**
  61535. * @hidden
  61536. */
  61537. export class Tmp {
  61538. static Color3: Color3[];
  61539. static Color4: Color4[];
  61540. static Vector2: Vector2[];
  61541. static Vector3: Vector3[];
  61542. static Vector4: Vector4[];
  61543. static Quaternion: Quaternion[];
  61544. static Matrix: Matrix[];
  61545. }
  61546. }
  61547. declare module BABYLON {
  61548. /**
  61549. * Class used to enable access to offline support
  61550. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61551. */
  61552. export interface IOfflineProvider {
  61553. /**
  61554. * Gets a boolean indicating if scene must be saved in the database
  61555. */
  61556. enableSceneOffline: boolean;
  61557. /**
  61558. * Gets a boolean indicating if textures must be saved in the database
  61559. */
  61560. enableTexturesOffline: boolean;
  61561. /**
  61562. * Open the offline support and make it available
  61563. * @param successCallback defines the callback to call on success
  61564. * @param errorCallback defines the callback to call on error
  61565. */
  61566. open(successCallback: () => void, errorCallback: () => void): void;
  61567. /**
  61568. * Loads an image from the offline support
  61569. * @param url defines the url to load from
  61570. * @param image defines the target DOM image
  61571. */
  61572. loadImage(url: string, image: HTMLImageElement): void;
  61573. /**
  61574. * Loads a file from offline support
  61575. * @param url defines the URL to load from
  61576. * @param sceneLoaded defines a callback to call on success
  61577. * @param progressCallBack defines a callback to call when progress changed
  61578. * @param errorCallback defines a callback to call on error
  61579. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61580. */
  61581. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61582. }
  61583. }
  61584. declare module BABYLON {
  61585. /**
  61586. * A class serves as a medium between the observable and its observers
  61587. */
  61588. export class EventState {
  61589. /**
  61590. * Create a new EventState
  61591. * @param mask defines the mask associated with this state
  61592. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61593. * @param target defines the original target of the state
  61594. * @param currentTarget defines the current target of the state
  61595. */
  61596. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61597. /**
  61598. * Initialize the current event state
  61599. * @param mask defines the mask associated with this state
  61600. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61601. * @param target defines the original target of the state
  61602. * @param currentTarget defines the current target of the state
  61603. * @returns the current event state
  61604. */
  61605. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61606. /**
  61607. * An Observer can set this property to true to prevent subsequent observers of being notified
  61608. */
  61609. skipNextObservers: boolean;
  61610. /**
  61611. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61612. */
  61613. mask: number;
  61614. /**
  61615. * The object that originally notified the event
  61616. */
  61617. target?: any;
  61618. /**
  61619. * The current object in the bubbling phase
  61620. */
  61621. currentTarget?: any;
  61622. /**
  61623. * This will be populated with the return value of the last function that was executed.
  61624. * If it is the first function in the callback chain it will be the event data.
  61625. */
  61626. lastReturnValue?: any;
  61627. }
  61628. /**
  61629. * Represent an Observer registered to a given Observable object.
  61630. */
  61631. export class Observer<T> {
  61632. /**
  61633. * Defines the callback to call when the observer is notified
  61634. */
  61635. callback: (eventData: T, eventState: EventState) => void;
  61636. /**
  61637. * Defines the mask of the observer (used to filter notifications)
  61638. */
  61639. mask: number;
  61640. /**
  61641. * Defines the current scope used to restore the JS context
  61642. */
  61643. scope: any;
  61644. /** @hidden */
  61645. _willBeUnregistered: boolean;
  61646. /**
  61647. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  61648. */
  61649. unregisterOnNextCall: boolean;
  61650. /**
  61651. * Creates a new observer
  61652. * @param callback defines the callback to call when the observer is notified
  61653. * @param mask defines the mask of the observer (used to filter notifications)
  61654. * @param scope defines the current scope used to restore the JS context
  61655. */
  61656. constructor(
  61657. /**
  61658. * Defines the callback to call when the observer is notified
  61659. */
  61660. callback: (eventData: T, eventState: EventState) => void,
  61661. /**
  61662. * Defines the mask of the observer (used to filter notifications)
  61663. */
  61664. mask: number,
  61665. /**
  61666. * Defines the current scope used to restore the JS context
  61667. */
  61668. scope?: any);
  61669. }
  61670. /**
  61671. * Represent a list of observers registered to multiple Observables object.
  61672. */
  61673. export class MultiObserver<T> {
  61674. private _observers;
  61675. private _observables;
  61676. /**
  61677. * Release associated resources
  61678. */
  61679. dispose(): void;
  61680. /**
  61681. * Raise a callback when one of the observable will notify
  61682. * @param observables defines a list of observables to watch
  61683. * @param callback defines the callback to call on notification
  61684. * @param mask defines the mask used to filter notifications
  61685. * @param scope defines the current scope used to restore the JS context
  61686. * @returns the new MultiObserver
  61687. */
  61688. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  61689. }
  61690. /**
  61691. * The Observable class is a simple implementation of the Observable pattern.
  61692. *
  61693. * 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.
  61694. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  61695. * 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).
  61696. * 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.
  61697. */
  61698. export class Observable<T> {
  61699. private _observers;
  61700. private _eventState;
  61701. private _onObserverAdded;
  61702. /**
  61703. * Creates a new observable
  61704. * @param onObserverAdded defines a callback to call when a new observer is added
  61705. */
  61706. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  61707. /**
  61708. * Create a new Observer with the specified callback
  61709. * @param callback the callback that will be executed for that Observer
  61710. * @param mask the mask used to filter observers
  61711. * @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.
  61712. * @param scope optional scope for the callback to be called from
  61713. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  61714. * @returns the new observer created for the callback
  61715. */
  61716. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  61717. /**
  61718. * Create a new Observer with the specified callback and unregisters after the next notification
  61719. * @param callback the callback that will be executed for that Observer
  61720. * @returns the new observer created for the callback
  61721. */
  61722. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  61723. /**
  61724. * Remove an Observer from the Observable object
  61725. * @param observer the instance of the Observer to remove
  61726. * @returns false if it doesn't belong to this Observable
  61727. */
  61728. remove(observer: Nullable<Observer<T>>): boolean;
  61729. /**
  61730. * Remove a callback from the Observable object
  61731. * @param callback the callback to remove
  61732. * @param scope optional scope. If used only the callbacks with this scope will be removed
  61733. * @returns false if it doesn't belong to this Observable
  61734. */
  61735. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  61736. private _deferUnregister;
  61737. private _remove;
  61738. /**
  61739. * Notify all Observers by calling their respective callback with the given data
  61740. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  61741. * @param eventData defines the data to send to all observers
  61742. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  61743. * @param target defines the original target of the state
  61744. * @param currentTarget defines the current target of the state
  61745. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  61746. */
  61747. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  61748. /**
  61749. * Calling this will execute each callback, expecting it to be a promise or return a value.
  61750. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  61751. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  61752. * and it is crucial that all callbacks will be executed.
  61753. * The order of the callbacks is kept, callbacks are not executed parallel.
  61754. *
  61755. * @param eventData The data to be sent to each callback
  61756. * @param mask is used to filter observers defaults to -1
  61757. * @param target defines the callback target (see EventState)
  61758. * @param currentTarget defines he current object in the bubbling phase
  61759. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  61760. */
  61761. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  61762. /**
  61763. * Notify a specific observer
  61764. * @param observer defines the observer to notify
  61765. * @param eventData defines the data to be sent to each callback
  61766. * @param mask is used to filter observers defaults to -1
  61767. */
  61768. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  61769. /**
  61770. * Gets a boolean indicating if the observable has at least one observer
  61771. * @returns true is the Observable has at least one Observer registered
  61772. */
  61773. hasObservers(): boolean;
  61774. /**
  61775. * Clear the list of observers
  61776. */
  61777. clear(): void;
  61778. /**
  61779. * Clone the current observable
  61780. * @returns a new observable
  61781. */
  61782. clone(): Observable<T>;
  61783. /**
  61784. * Does this observable handles observer registered with a given mask
  61785. * @param mask defines the mask to be tested
  61786. * @return whether or not one observer registered with the given mask is handeled
  61787. **/
  61788. hasSpecificMask(mask?: number): boolean;
  61789. }
  61790. }
  61791. declare module BABYLON {
  61792. /**
  61793. * Class used to help managing file picking and drag'n'drop
  61794. * File Storage
  61795. */
  61796. export class FilesInputStore {
  61797. /**
  61798. * List of files ready to be loaded
  61799. */
  61800. static FilesToLoad: {
  61801. [key: string]: File;
  61802. };
  61803. }
  61804. }
  61805. declare module BABYLON {
  61806. /** Defines the cross module used constants to avoid circular dependncies */
  61807. export class Constants {
  61808. /** Defines that alpha blending is disabled */
  61809. static readonly ALPHA_DISABLE: number;
  61810. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  61811. static readonly ALPHA_ADD: number;
  61812. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  61813. static readonly ALPHA_COMBINE: number;
  61814. /** Defines that alpha blending to DEST - SRC * DEST */
  61815. static readonly ALPHA_SUBTRACT: number;
  61816. /** Defines that alpha blending to SRC * DEST */
  61817. static readonly ALPHA_MULTIPLY: number;
  61818. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  61819. static readonly ALPHA_MAXIMIZED: number;
  61820. /** Defines that alpha blending to SRC + DEST */
  61821. static readonly ALPHA_ONEONE: number;
  61822. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  61823. static readonly ALPHA_PREMULTIPLIED: number;
  61824. /**
  61825. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  61826. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  61827. */
  61828. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  61829. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  61830. static readonly ALPHA_INTERPOLATE: number;
  61831. /**
  61832. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  61833. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  61834. */
  61835. static readonly ALPHA_SCREENMODE: number;
  61836. /** Defines that the ressource is not delayed*/
  61837. static readonly DELAYLOADSTATE_NONE: number;
  61838. /** Defines that the ressource was successfully delay loaded */
  61839. static readonly DELAYLOADSTATE_LOADED: number;
  61840. /** Defines that the ressource is currently delay loading */
  61841. static readonly DELAYLOADSTATE_LOADING: number;
  61842. /** Defines that the ressource is delayed and has not started loading */
  61843. static readonly DELAYLOADSTATE_NOTLOADED: number;
  61844. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  61845. static readonly NEVER: number;
  61846. /** 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 */
  61847. static readonly ALWAYS: number;
  61848. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  61849. static readonly LESS: number;
  61850. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  61851. static readonly EQUAL: number;
  61852. /** 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 */
  61853. static readonly LEQUAL: number;
  61854. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  61855. static readonly GREATER: number;
  61856. /** 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 */
  61857. static readonly GEQUAL: number;
  61858. /** 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 */
  61859. static readonly NOTEQUAL: number;
  61860. /** Passed to stencilOperation to specify that stencil value must be kept */
  61861. static readonly KEEP: number;
  61862. /** Passed to stencilOperation to specify that stencil value must be replaced */
  61863. static readonly REPLACE: number;
  61864. /** Passed to stencilOperation to specify that stencil value must be incremented */
  61865. static readonly INCR: number;
  61866. /** Passed to stencilOperation to specify that stencil value must be decremented */
  61867. static readonly DECR: number;
  61868. /** Passed to stencilOperation to specify that stencil value must be inverted */
  61869. static readonly INVERT: number;
  61870. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  61871. static readonly INCR_WRAP: number;
  61872. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  61873. static readonly DECR_WRAP: number;
  61874. /** Texture is not repeating outside of 0..1 UVs */
  61875. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  61876. /** Texture is repeating outside of 0..1 UVs */
  61877. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  61878. /** Texture is repeating and mirrored */
  61879. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  61880. /** ALPHA */
  61881. static readonly TEXTUREFORMAT_ALPHA: number;
  61882. /** LUMINANCE */
  61883. static readonly TEXTUREFORMAT_LUMINANCE: number;
  61884. /** LUMINANCE_ALPHA */
  61885. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  61886. /** RGB */
  61887. static readonly TEXTUREFORMAT_RGB: number;
  61888. /** RGBA */
  61889. static readonly TEXTUREFORMAT_RGBA: number;
  61890. /** RED */
  61891. static readonly TEXTUREFORMAT_RED: number;
  61892. /** RED (2nd reference) */
  61893. static readonly TEXTUREFORMAT_R: number;
  61894. /** RG */
  61895. static readonly TEXTUREFORMAT_RG: number;
  61896. /** RED_INTEGER */
  61897. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  61898. /** RED_INTEGER (2nd reference) */
  61899. static readonly TEXTUREFORMAT_R_INTEGER: number;
  61900. /** RG_INTEGER */
  61901. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  61902. /** RGB_INTEGER */
  61903. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  61904. /** RGBA_INTEGER */
  61905. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  61906. /** UNSIGNED_BYTE */
  61907. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  61908. /** UNSIGNED_BYTE (2nd reference) */
  61909. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  61910. /** FLOAT */
  61911. static readonly TEXTURETYPE_FLOAT: number;
  61912. /** HALF_FLOAT */
  61913. static readonly TEXTURETYPE_HALF_FLOAT: number;
  61914. /** BYTE */
  61915. static readonly TEXTURETYPE_BYTE: number;
  61916. /** SHORT */
  61917. static readonly TEXTURETYPE_SHORT: number;
  61918. /** UNSIGNED_SHORT */
  61919. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  61920. /** INT */
  61921. static readonly TEXTURETYPE_INT: number;
  61922. /** UNSIGNED_INT */
  61923. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  61924. /** UNSIGNED_SHORT_4_4_4_4 */
  61925. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  61926. /** UNSIGNED_SHORT_5_5_5_1 */
  61927. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  61928. /** UNSIGNED_SHORT_5_6_5 */
  61929. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  61930. /** UNSIGNED_INT_2_10_10_10_REV */
  61931. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  61932. /** UNSIGNED_INT_24_8 */
  61933. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  61934. /** UNSIGNED_INT_10F_11F_11F_REV */
  61935. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  61936. /** UNSIGNED_INT_5_9_9_9_REV */
  61937. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  61938. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  61939. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61940. /** nearest is mag = nearest and min = nearest and mip = linear */
  61941. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  61942. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61943. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  61944. /** Trilinear is mag = linear and min = linear and mip = linear */
  61945. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  61946. /** nearest is mag = nearest and min = nearest and mip = linear */
  61947. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  61948. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61949. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  61950. /** Trilinear is mag = linear and min = linear and mip = linear */
  61951. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  61952. /** mag = nearest and min = nearest and mip = nearest */
  61953. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  61954. /** mag = nearest and min = linear and mip = nearest */
  61955. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  61956. /** mag = nearest and min = linear and mip = linear */
  61957. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  61958. /** mag = nearest and min = linear and mip = none */
  61959. static readonly TEXTURE_NEAREST_LINEAR: number;
  61960. /** mag = nearest and min = nearest and mip = none */
  61961. static readonly TEXTURE_NEAREST_NEAREST: number;
  61962. /** mag = linear and min = nearest and mip = nearest */
  61963. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  61964. /** mag = linear and min = nearest and mip = linear */
  61965. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  61966. /** mag = linear and min = linear and mip = none */
  61967. static readonly TEXTURE_LINEAR_LINEAR: number;
  61968. /** mag = linear and min = nearest and mip = none */
  61969. static readonly TEXTURE_LINEAR_NEAREST: number;
  61970. /** Explicit coordinates mode */
  61971. static readonly TEXTURE_EXPLICIT_MODE: number;
  61972. /** Spherical coordinates mode */
  61973. static readonly TEXTURE_SPHERICAL_MODE: number;
  61974. /** Planar coordinates mode */
  61975. static readonly TEXTURE_PLANAR_MODE: number;
  61976. /** Cubic coordinates mode */
  61977. static readonly TEXTURE_CUBIC_MODE: number;
  61978. /** Projection coordinates mode */
  61979. static readonly TEXTURE_PROJECTION_MODE: number;
  61980. /** Skybox coordinates mode */
  61981. static readonly TEXTURE_SKYBOX_MODE: number;
  61982. /** Inverse Cubic coordinates mode */
  61983. static readonly TEXTURE_INVCUBIC_MODE: number;
  61984. /** Equirectangular coordinates mode */
  61985. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  61986. /** Equirectangular Fixed coordinates mode */
  61987. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  61988. /** Equirectangular Fixed Mirrored coordinates mode */
  61989. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  61990. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  61991. static readonly SCALEMODE_FLOOR: number;
  61992. /** Defines that texture rescaling will look for the nearest power of 2 size */
  61993. static readonly SCALEMODE_NEAREST: number;
  61994. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  61995. static readonly SCALEMODE_CEILING: number;
  61996. /**
  61997. * The dirty texture flag value
  61998. */
  61999. static readonly MATERIAL_TextureDirtyFlag: number;
  62000. /**
  62001. * The dirty light flag value
  62002. */
  62003. static readonly MATERIAL_LightDirtyFlag: number;
  62004. /**
  62005. * The dirty fresnel flag value
  62006. */
  62007. static readonly MATERIAL_FresnelDirtyFlag: number;
  62008. /**
  62009. * The dirty attribute flag value
  62010. */
  62011. static readonly MATERIAL_AttributesDirtyFlag: number;
  62012. /**
  62013. * The dirty misc flag value
  62014. */
  62015. static readonly MATERIAL_MiscDirtyFlag: number;
  62016. /**
  62017. * The all dirty flag value
  62018. */
  62019. static readonly MATERIAL_AllDirtyFlag: number;
  62020. /**
  62021. * Returns the triangle fill mode
  62022. */
  62023. static readonly MATERIAL_TriangleFillMode: number;
  62024. /**
  62025. * Returns the wireframe mode
  62026. */
  62027. static readonly MATERIAL_WireFrameFillMode: number;
  62028. /**
  62029. * Returns the point fill mode
  62030. */
  62031. static readonly MATERIAL_PointFillMode: number;
  62032. /**
  62033. * Returns the point list draw mode
  62034. */
  62035. static readonly MATERIAL_PointListDrawMode: number;
  62036. /**
  62037. * Returns the line list draw mode
  62038. */
  62039. static readonly MATERIAL_LineListDrawMode: number;
  62040. /**
  62041. * Returns the line loop draw mode
  62042. */
  62043. static readonly MATERIAL_LineLoopDrawMode: number;
  62044. /**
  62045. * Returns the line strip draw mode
  62046. */
  62047. static readonly MATERIAL_LineStripDrawMode: number;
  62048. /**
  62049. * Returns the triangle strip draw mode
  62050. */
  62051. static readonly MATERIAL_TriangleStripDrawMode: number;
  62052. /**
  62053. * Returns the triangle fan draw mode
  62054. */
  62055. static readonly MATERIAL_TriangleFanDrawMode: number;
  62056. /**
  62057. * Stores the clock-wise side orientation
  62058. */
  62059. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62060. /**
  62061. * Stores the counter clock-wise side orientation
  62062. */
  62063. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62064. /**
  62065. * Nothing
  62066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62067. */
  62068. static readonly ACTION_NothingTrigger: number;
  62069. /**
  62070. * On pick
  62071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62072. */
  62073. static readonly ACTION_OnPickTrigger: number;
  62074. /**
  62075. * On left pick
  62076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62077. */
  62078. static readonly ACTION_OnLeftPickTrigger: number;
  62079. /**
  62080. * On right pick
  62081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62082. */
  62083. static readonly ACTION_OnRightPickTrigger: number;
  62084. /**
  62085. * On center pick
  62086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62087. */
  62088. static readonly ACTION_OnCenterPickTrigger: number;
  62089. /**
  62090. * On pick down
  62091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62092. */
  62093. static readonly ACTION_OnPickDownTrigger: number;
  62094. /**
  62095. * On double pick
  62096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62097. */
  62098. static readonly ACTION_OnDoublePickTrigger: number;
  62099. /**
  62100. * On pick up
  62101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62102. */
  62103. static readonly ACTION_OnPickUpTrigger: number;
  62104. /**
  62105. * On pick out.
  62106. * This trigger will only be raised if you also declared a OnPickDown
  62107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62108. */
  62109. static readonly ACTION_OnPickOutTrigger: number;
  62110. /**
  62111. * On long press
  62112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62113. */
  62114. static readonly ACTION_OnLongPressTrigger: number;
  62115. /**
  62116. * On pointer over
  62117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62118. */
  62119. static readonly ACTION_OnPointerOverTrigger: number;
  62120. /**
  62121. * On pointer out
  62122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62123. */
  62124. static readonly ACTION_OnPointerOutTrigger: number;
  62125. /**
  62126. * On every frame
  62127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62128. */
  62129. static readonly ACTION_OnEveryFrameTrigger: number;
  62130. /**
  62131. * On intersection enter
  62132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62133. */
  62134. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62135. /**
  62136. * On intersection exit
  62137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62138. */
  62139. static readonly ACTION_OnIntersectionExitTrigger: number;
  62140. /**
  62141. * On key down
  62142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62143. */
  62144. static readonly ACTION_OnKeyDownTrigger: number;
  62145. /**
  62146. * On key up
  62147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62148. */
  62149. static readonly ACTION_OnKeyUpTrigger: number;
  62150. /**
  62151. * Billboard mode will only apply to Y axis
  62152. */
  62153. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62154. /**
  62155. * Billboard mode will apply to all axes
  62156. */
  62157. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62158. /**
  62159. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62160. */
  62161. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62162. /**
  62163. * Gets or sets base Assets URL
  62164. */
  62165. static readonly PARTICLES_BaseAssetsUrl: string;
  62166. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62167. * Test order :
  62168. * Is the bounding sphere outside the frustum ?
  62169. * If not, are the bounding box vertices outside the frustum ?
  62170. * It not, then the cullable object is in the frustum.
  62171. */
  62172. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62173. /** Culling strategy : Bounding Sphere Only.
  62174. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62175. * It's also less accurate than the standard because some not visible objects can still be selected.
  62176. * Test : is the bounding sphere outside the frustum ?
  62177. * If not, then the cullable object is in the frustum.
  62178. */
  62179. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62180. /** Culling strategy : Optimistic Inclusion.
  62181. * This in an inclusion test first, then the standard exclusion test.
  62182. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62183. * 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.
  62184. * Anyway, it's as accurate as the standard strategy.
  62185. * Test :
  62186. * Is the cullable object bounding sphere center in the frustum ?
  62187. * If not, apply the default culling strategy.
  62188. */
  62189. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62190. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62191. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62192. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62193. * 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.
  62194. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62195. * Test :
  62196. * Is the cullable object bounding sphere center in the frustum ?
  62197. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62198. */
  62199. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62200. /**
  62201. * No logging while loading
  62202. */
  62203. static readonly SCENELOADER_NO_LOGGING: number;
  62204. /**
  62205. * Minimal logging while loading
  62206. */
  62207. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62208. /**
  62209. * Summary logging while loading
  62210. */
  62211. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62212. /**
  62213. * Detailled logging while loading
  62214. */
  62215. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62216. }
  62217. }
  62218. declare module BABYLON {
  62219. /**
  62220. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62221. * Babylon.js
  62222. */
  62223. export class DomManagement {
  62224. /**
  62225. * Checks if the window object exists
  62226. * @returns true if the window object exists
  62227. */
  62228. static IsWindowObjectExist(): boolean;
  62229. /**
  62230. * Extracts text content from a DOM element hierarchy
  62231. * @param element defines the root element
  62232. * @returns a string
  62233. */
  62234. static GetDOMTextContent(element: HTMLElement): string;
  62235. }
  62236. }
  62237. declare module BABYLON {
  62238. /**
  62239. * Logger used througouht the application to allow configuration of
  62240. * the log level required for the messages.
  62241. */
  62242. export class Logger {
  62243. /**
  62244. * No log
  62245. */
  62246. static readonly NoneLogLevel: number;
  62247. /**
  62248. * Only message logs
  62249. */
  62250. static readonly MessageLogLevel: number;
  62251. /**
  62252. * Only warning logs
  62253. */
  62254. static readonly WarningLogLevel: number;
  62255. /**
  62256. * Only error logs
  62257. */
  62258. static readonly ErrorLogLevel: number;
  62259. /**
  62260. * All logs
  62261. */
  62262. static readonly AllLogLevel: number;
  62263. private static _LogCache;
  62264. /**
  62265. * Gets a value indicating the number of loading errors
  62266. * @ignorenaming
  62267. */
  62268. static errorsCount: number;
  62269. /**
  62270. * Callback called when a new log is added
  62271. */
  62272. static OnNewCacheEntry: (entry: string) => void;
  62273. private static _AddLogEntry;
  62274. private static _FormatMessage;
  62275. private static _LogDisabled;
  62276. private static _LogEnabled;
  62277. private static _WarnDisabled;
  62278. private static _WarnEnabled;
  62279. private static _ErrorDisabled;
  62280. private static _ErrorEnabled;
  62281. /**
  62282. * Log a message to the console
  62283. */
  62284. static Log: (message: string) => void;
  62285. /**
  62286. * Write a warning message to the console
  62287. */
  62288. static Warn: (message: string) => void;
  62289. /**
  62290. * Write an error message to the console
  62291. */
  62292. static Error: (message: string) => void;
  62293. /**
  62294. * Gets current log cache (list of logs)
  62295. */
  62296. static readonly LogCache: string;
  62297. /**
  62298. * Clears the log cache
  62299. */
  62300. static ClearLogCache(): void;
  62301. /**
  62302. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62303. */
  62304. static LogLevels: number;
  62305. }
  62306. }
  62307. declare module BABYLON {
  62308. /** @hidden */
  62309. export class _TypeStore {
  62310. /** @hidden */
  62311. static RegisteredTypes: {
  62312. [key: string]: Object;
  62313. };
  62314. /** @hidden */
  62315. static GetClass(fqdn: string): any;
  62316. }
  62317. }
  62318. declare module BABYLON {
  62319. /**
  62320. * Class containing a set of static utilities functions for deep copy.
  62321. */
  62322. export class DeepCopier {
  62323. /**
  62324. * Tries to copy an object by duplicating every property
  62325. * @param source defines the source object
  62326. * @param destination defines the target object
  62327. * @param doNotCopyList defines a list of properties to avoid
  62328. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62329. */
  62330. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62331. }
  62332. }
  62333. declare module BABYLON {
  62334. /**
  62335. * Class containing a set of static utilities functions for precision date
  62336. */
  62337. export class PrecisionDate {
  62338. /**
  62339. * Gets either window.performance.now() if supported or Date.now() else
  62340. */
  62341. static readonly Now: number;
  62342. }
  62343. }
  62344. declare module BABYLON {
  62345. /** @hidden */
  62346. export class _DevTools {
  62347. static WarnImport(name: string): string;
  62348. }
  62349. }
  62350. declare module BABYLON {
  62351. /**
  62352. * Class used to evalaute queries containing `and` and `or` operators
  62353. */
  62354. export class AndOrNotEvaluator {
  62355. /**
  62356. * Evaluate a query
  62357. * @param query defines the query to evaluate
  62358. * @param evaluateCallback defines the callback used to filter result
  62359. * @returns true if the query matches
  62360. */
  62361. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62362. private static _HandleParenthesisContent;
  62363. private static _SimplifyNegation;
  62364. }
  62365. }
  62366. declare module BABYLON {
  62367. /**
  62368. * Class used to store custom tags
  62369. */
  62370. export class Tags {
  62371. /**
  62372. * Adds support for tags on the given object
  62373. * @param obj defines the object to use
  62374. */
  62375. static EnableFor(obj: any): void;
  62376. /**
  62377. * Removes tags support
  62378. * @param obj defines the object to use
  62379. */
  62380. static DisableFor(obj: any): void;
  62381. /**
  62382. * Gets a boolean indicating if the given object has tags
  62383. * @param obj defines the object to use
  62384. * @returns a boolean
  62385. */
  62386. static HasTags(obj: any): boolean;
  62387. /**
  62388. * Gets the tags available on a given object
  62389. * @param obj defines the object to use
  62390. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62391. * @returns the tags
  62392. */
  62393. static GetTags(obj: any, asString?: boolean): any;
  62394. /**
  62395. * Adds tags to an object
  62396. * @param obj defines the object to use
  62397. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62398. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62399. */
  62400. static AddTagsTo(obj: any, tagsString: string): void;
  62401. /**
  62402. * @hidden
  62403. */
  62404. static _AddTagTo(obj: any, tag: string): void;
  62405. /**
  62406. * Removes specific tags from a specific object
  62407. * @param obj defines the object to use
  62408. * @param tagsString defines the tags to remove
  62409. */
  62410. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62411. /**
  62412. * @hidden
  62413. */
  62414. static _RemoveTagFrom(obj: any, tag: string): void;
  62415. /**
  62416. * Defines if tags hosted on an object match a given query
  62417. * @param obj defines the object to use
  62418. * @param tagsQuery defines the tag query
  62419. * @returns a boolean
  62420. */
  62421. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  62422. }
  62423. }
  62424. declare module BABYLON {
  62425. /**
  62426. * Manages the defines for the Material
  62427. */
  62428. export class MaterialDefines {
  62429. private _keys;
  62430. private _isDirty;
  62431. /** @hidden */
  62432. _renderId: number;
  62433. /** @hidden */
  62434. _areLightsDirty: boolean;
  62435. /** @hidden */
  62436. _areAttributesDirty: boolean;
  62437. /** @hidden */
  62438. _areTexturesDirty: boolean;
  62439. /** @hidden */
  62440. _areFresnelDirty: boolean;
  62441. /** @hidden */
  62442. _areMiscDirty: boolean;
  62443. /** @hidden */
  62444. _areImageProcessingDirty: boolean;
  62445. /** @hidden */
  62446. _normals: boolean;
  62447. /** @hidden */
  62448. _uvs: boolean;
  62449. /** @hidden */
  62450. _needNormals: boolean;
  62451. /** @hidden */
  62452. _needUVs: boolean;
  62453. /**
  62454. * Specifies if the material needs to be re-calculated
  62455. */
  62456. readonly isDirty: boolean;
  62457. /**
  62458. * Marks the material to indicate that it has been re-calculated
  62459. */
  62460. markAsProcessed(): void;
  62461. /**
  62462. * Marks the material to indicate that it needs to be re-calculated
  62463. */
  62464. markAsUnprocessed(): void;
  62465. /**
  62466. * Marks the material to indicate all of its defines need to be re-calculated
  62467. */
  62468. markAllAsDirty(): void;
  62469. /**
  62470. * Marks the material to indicate that image processing needs to be re-calculated
  62471. */
  62472. markAsImageProcessingDirty(): void;
  62473. /**
  62474. * Marks the material to indicate the lights need to be re-calculated
  62475. */
  62476. markAsLightDirty(): void;
  62477. /**
  62478. * Marks the attribute state as changed
  62479. */
  62480. markAsAttributesDirty(): void;
  62481. /**
  62482. * Marks the texture state as changed
  62483. */
  62484. markAsTexturesDirty(): void;
  62485. /**
  62486. * Marks the fresnel state as changed
  62487. */
  62488. markAsFresnelDirty(): void;
  62489. /**
  62490. * Marks the misc state as changed
  62491. */
  62492. markAsMiscDirty(): void;
  62493. /**
  62494. * Rebuilds the material defines
  62495. */
  62496. rebuild(): void;
  62497. /**
  62498. * Specifies if two material defines are equal
  62499. * @param other - A material define instance to compare to
  62500. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62501. */
  62502. isEqual(other: MaterialDefines): boolean;
  62503. /**
  62504. * Clones this instance's defines to another instance
  62505. * @param other - material defines to clone values to
  62506. */
  62507. cloneTo(other: MaterialDefines): void;
  62508. /**
  62509. * Resets the material define values
  62510. */
  62511. reset(): void;
  62512. /**
  62513. * Converts the material define values to a string
  62514. * @returns - String of material define information
  62515. */
  62516. toString(): string;
  62517. }
  62518. }
  62519. declare module BABYLON {
  62520. /**
  62521. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62522. */
  62523. export class PerformanceMonitor {
  62524. private _enabled;
  62525. private _rollingFrameTime;
  62526. private _lastFrameTimeMs;
  62527. /**
  62528. * constructor
  62529. * @param frameSampleSize The number of samples required to saturate the sliding window
  62530. */
  62531. constructor(frameSampleSize?: number);
  62532. /**
  62533. * Samples current frame
  62534. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62535. */
  62536. sampleFrame(timeMs?: number): void;
  62537. /**
  62538. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62539. */
  62540. readonly averageFrameTime: number;
  62541. /**
  62542. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62543. */
  62544. readonly averageFrameTimeVariance: number;
  62545. /**
  62546. * Returns the frame time of the most recent frame
  62547. */
  62548. readonly instantaneousFrameTime: number;
  62549. /**
  62550. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  62551. */
  62552. readonly averageFPS: number;
  62553. /**
  62554. * Returns the average framerate in frames per second using the most recent frame time
  62555. */
  62556. readonly instantaneousFPS: number;
  62557. /**
  62558. * Returns true if enough samples have been taken to completely fill the sliding window
  62559. */
  62560. readonly isSaturated: boolean;
  62561. /**
  62562. * Enables contributions to the sliding window sample set
  62563. */
  62564. enable(): void;
  62565. /**
  62566. * Disables contributions to the sliding window sample set
  62567. * Samples will not be interpolated over the disabled period
  62568. */
  62569. disable(): void;
  62570. /**
  62571. * Returns true if sampling is enabled
  62572. */
  62573. readonly isEnabled: boolean;
  62574. /**
  62575. * Resets performance monitor
  62576. */
  62577. reset(): void;
  62578. }
  62579. /**
  62580. * RollingAverage
  62581. *
  62582. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  62583. */
  62584. export class RollingAverage {
  62585. /**
  62586. * Current average
  62587. */
  62588. average: number;
  62589. /**
  62590. * Current variance
  62591. */
  62592. variance: number;
  62593. protected _samples: Array<number>;
  62594. protected _sampleCount: number;
  62595. protected _pos: number;
  62596. protected _m2: number;
  62597. /**
  62598. * constructor
  62599. * @param length The number of samples required to saturate the sliding window
  62600. */
  62601. constructor(length: number);
  62602. /**
  62603. * Adds a sample to the sample set
  62604. * @param v The sample value
  62605. */
  62606. add(v: number): void;
  62607. /**
  62608. * Returns previously added values or null if outside of history or outside the sliding window domain
  62609. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  62610. * @return Value previously recorded with add() or null if outside of range
  62611. */
  62612. history(i: number): number;
  62613. /**
  62614. * Returns true if enough samples have been taken to completely fill the sliding window
  62615. * @return true if sample-set saturated
  62616. */
  62617. isSaturated(): boolean;
  62618. /**
  62619. * Resets the rolling average (equivalent to 0 samples taken so far)
  62620. */
  62621. reset(): void;
  62622. /**
  62623. * Wraps a value around the sample range boundaries
  62624. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  62625. * @return Wrapped position in sample range
  62626. */
  62627. protected _wrapPosition(i: number): number;
  62628. }
  62629. }
  62630. declare module BABYLON {
  62631. /**
  62632. * This class implement a typical dictionary using a string as key and the generic type T as value.
  62633. * The underlying implementation relies on an associative array to ensure the best performances.
  62634. * The value can be anything including 'null' but except 'undefined'
  62635. */
  62636. export class StringDictionary<T> {
  62637. /**
  62638. * This will clear this dictionary and copy the content from the 'source' one.
  62639. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  62640. * @param source the dictionary to take the content from and copy to this dictionary
  62641. */
  62642. copyFrom(source: StringDictionary<T>): void;
  62643. /**
  62644. * Get a value based from its key
  62645. * @param key the given key to get the matching value from
  62646. * @return the value if found, otherwise undefined is returned
  62647. */
  62648. get(key: string): T | undefined;
  62649. /**
  62650. * Get a value from its key or add it if it doesn't exist.
  62651. * This method will ensure you that a given key/data will be present in the dictionary.
  62652. * @param key the given key to get the matching value from
  62653. * @param factory the factory that will create the value if the key is not present in the dictionary.
  62654. * The factory will only be invoked if there's no data for the given key.
  62655. * @return the value corresponding to the key.
  62656. */
  62657. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  62658. /**
  62659. * Get a value from its key if present in the dictionary otherwise add it
  62660. * @param key the key to get the value from
  62661. * @param val if there's no such key/value pair in the dictionary add it with this value
  62662. * @return the value corresponding to the key
  62663. */
  62664. getOrAdd(key: string, val: T): T;
  62665. /**
  62666. * Check if there's a given key in the dictionary
  62667. * @param key the key to check for
  62668. * @return true if the key is present, false otherwise
  62669. */
  62670. contains(key: string): boolean;
  62671. /**
  62672. * Add a new key and its corresponding value
  62673. * @param key the key to add
  62674. * @param value the value corresponding to the key
  62675. * @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
  62676. */
  62677. add(key: string, value: T): boolean;
  62678. /**
  62679. * Update a specific value associated to a key
  62680. * @param key defines the key to use
  62681. * @param value defines the value to store
  62682. * @returns true if the value was updated (or false if the key was not found)
  62683. */
  62684. set(key: string, value: T): boolean;
  62685. /**
  62686. * Get the element of the given key and remove it from the dictionary
  62687. * @param key defines the key to search
  62688. * @returns the value associated with the key or null if not found
  62689. */
  62690. getAndRemove(key: string): Nullable<T>;
  62691. /**
  62692. * Remove a key/value from the dictionary.
  62693. * @param key the key to remove
  62694. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  62695. */
  62696. remove(key: string): boolean;
  62697. /**
  62698. * Clear the whole content of the dictionary
  62699. */
  62700. clear(): void;
  62701. /**
  62702. * Gets the current count
  62703. */
  62704. readonly count: number;
  62705. /**
  62706. * Execute a callback on each key/val of the dictionary.
  62707. * Note that you can remove any element in this dictionary in the callback implementation
  62708. * @param callback the callback to execute on a given key/value pair
  62709. */
  62710. forEach(callback: (key: string, val: T) => void): void;
  62711. /**
  62712. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  62713. * If the callback returns null or undefined the method will iterate to the next key/value pair
  62714. * Note that you can remove any element in this dictionary in the callback implementation
  62715. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  62716. * @returns the first item
  62717. */
  62718. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  62719. private _count;
  62720. private _data;
  62721. }
  62722. }
  62723. declare module BABYLON {
  62724. /**
  62725. * Helper class that provides a small promise polyfill
  62726. */
  62727. export class PromisePolyfill {
  62728. /**
  62729. * Static function used to check if the polyfill is required
  62730. * If this is the case then the function will inject the polyfill to window.Promise
  62731. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  62732. */
  62733. static Apply(force?: boolean): void;
  62734. }
  62735. }
  62736. declare module BABYLON {
  62737. /**
  62738. * Class used to store data that will be store in GPU memory
  62739. */
  62740. export class Buffer {
  62741. private _engine;
  62742. private _buffer;
  62743. /** @hidden */
  62744. _data: Nullable<DataArray>;
  62745. private _updatable;
  62746. private _instanced;
  62747. /**
  62748. * Gets the byte stride.
  62749. */
  62750. readonly byteStride: number;
  62751. /**
  62752. * Constructor
  62753. * @param engine the engine
  62754. * @param data the data to use for this buffer
  62755. * @param updatable whether the data is updatable
  62756. * @param stride the stride (optional)
  62757. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62758. * @param instanced whether the buffer is instanced (optional)
  62759. * @param useBytes set to true if the stride in in bytes (optional)
  62760. */
  62761. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  62762. /**
  62763. * Create a new VertexBuffer based on the current buffer
  62764. * @param kind defines the vertex buffer kind (position, normal, etc.)
  62765. * @param offset defines offset in the buffer (0 by default)
  62766. * @param size defines the size in floats of attributes (position is 3 for instance)
  62767. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  62768. * @param instanced defines if the vertex buffer contains indexed data
  62769. * @param useBytes defines if the offset and stride are in bytes
  62770. * @returns the new vertex buffer
  62771. */
  62772. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  62773. /**
  62774. * Gets a boolean indicating if the Buffer is updatable?
  62775. * @returns true if the buffer is updatable
  62776. */
  62777. isUpdatable(): boolean;
  62778. /**
  62779. * Gets current buffer's data
  62780. * @returns a DataArray or null
  62781. */
  62782. getData(): Nullable<DataArray>;
  62783. /**
  62784. * Gets underlying native buffer
  62785. * @returns underlying native buffer
  62786. */
  62787. getBuffer(): Nullable<WebGLBuffer>;
  62788. /**
  62789. * Gets the stride in float32 units (i.e. byte stride / 4).
  62790. * May not be an integer if the byte stride is not divisible by 4.
  62791. * DEPRECATED. Use byteStride instead.
  62792. * @returns the stride in float32 units
  62793. */
  62794. getStrideSize(): number;
  62795. /**
  62796. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62797. * @param data defines the data to store
  62798. */
  62799. create(data?: Nullable<DataArray>): void;
  62800. /** @hidden */
  62801. _rebuild(): void;
  62802. /**
  62803. * Update current buffer data
  62804. * @param data defines the data to store
  62805. */
  62806. update(data: DataArray): void;
  62807. /**
  62808. * Updates the data directly.
  62809. * @param data the new data
  62810. * @param offset the new offset
  62811. * @param vertexCount the vertex count (optional)
  62812. * @param useBytes set to true if the offset is in bytes
  62813. */
  62814. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  62815. /**
  62816. * Release all resources
  62817. */
  62818. dispose(): void;
  62819. }
  62820. /**
  62821. * Specialized buffer used to store vertex data
  62822. */
  62823. export class VertexBuffer {
  62824. /** @hidden */
  62825. _buffer: Buffer;
  62826. private _kind;
  62827. private _size;
  62828. private _ownsBuffer;
  62829. private _instanced;
  62830. private _instanceDivisor;
  62831. /**
  62832. * The byte type.
  62833. */
  62834. static readonly BYTE: number;
  62835. /**
  62836. * The unsigned byte type.
  62837. */
  62838. static readonly UNSIGNED_BYTE: number;
  62839. /**
  62840. * The short type.
  62841. */
  62842. static readonly SHORT: number;
  62843. /**
  62844. * The unsigned short type.
  62845. */
  62846. static readonly UNSIGNED_SHORT: number;
  62847. /**
  62848. * The integer type.
  62849. */
  62850. static readonly INT: number;
  62851. /**
  62852. * The unsigned integer type.
  62853. */
  62854. static readonly UNSIGNED_INT: number;
  62855. /**
  62856. * The float type.
  62857. */
  62858. static readonly FLOAT: number;
  62859. /**
  62860. * Gets or sets the instance divisor when in instanced mode
  62861. */
  62862. instanceDivisor: number;
  62863. /**
  62864. * Gets the byte stride.
  62865. */
  62866. readonly byteStride: number;
  62867. /**
  62868. * Gets the byte offset.
  62869. */
  62870. readonly byteOffset: number;
  62871. /**
  62872. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  62873. */
  62874. readonly normalized: boolean;
  62875. /**
  62876. * Gets the data type of each component in the array.
  62877. */
  62878. readonly type: number;
  62879. /**
  62880. * Constructor
  62881. * @param engine the engine
  62882. * @param data the data to use for this vertex buffer
  62883. * @param kind the vertex buffer kind
  62884. * @param updatable whether the data is updatable
  62885. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62886. * @param stride the stride (optional)
  62887. * @param instanced whether the buffer is instanced (optional)
  62888. * @param offset the offset of the data (optional)
  62889. * @param size the number of components (optional)
  62890. * @param type the type of the component (optional)
  62891. * @param normalized whether the data contains normalized data (optional)
  62892. * @param useBytes set to true if stride and offset are in bytes (optional)
  62893. */
  62894. 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);
  62895. /** @hidden */
  62896. _rebuild(): void;
  62897. /**
  62898. * Returns the kind of the VertexBuffer (string)
  62899. * @returns a string
  62900. */
  62901. getKind(): string;
  62902. /**
  62903. * Gets a boolean indicating if the VertexBuffer is updatable?
  62904. * @returns true if the buffer is updatable
  62905. */
  62906. isUpdatable(): boolean;
  62907. /**
  62908. * Gets current buffer's data
  62909. * @returns a DataArray or null
  62910. */
  62911. getData(): Nullable<DataArray>;
  62912. /**
  62913. * Gets underlying native buffer
  62914. * @returns underlying native buffer
  62915. */
  62916. getBuffer(): Nullable<WebGLBuffer>;
  62917. /**
  62918. * Gets the stride in float32 units (i.e. byte stride / 4).
  62919. * May not be an integer if the byte stride is not divisible by 4.
  62920. * DEPRECATED. Use byteStride instead.
  62921. * @returns the stride in float32 units
  62922. */
  62923. getStrideSize(): number;
  62924. /**
  62925. * Returns the offset as a multiple of the type byte length.
  62926. * DEPRECATED. Use byteOffset instead.
  62927. * @returns the offset in bytes
  62928. */
  62929. getOffset(): number;
  62930. /**
  62931. * Returns the number of components per vertex attribute (integer)
  62932. * @returns the size in float
  62933. */
  62934. getSize(): number;
  62935. /**
  62936. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  62937. * @returns true if this buffer is instanced
  62938. */
  62939. getIsInstanced(): boolean;
  62940. /**
  62941. * Returns the instancing divisor, zero for non-instanced (integer).
  62942. * @returns a number
  62943. */
  62944. getInstanceDivisor(): number;
  62945. /**
  62946. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62947. * @param data defines the data to store
  62948. */
  62949. create(data?: DataArray): void;
  62950. /**
  62951. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  62952. * This function will create a new buffer if the current one is not updatable
  62953. * @param data defines the data to store
  62954. */
  62955. update(data: DataArray): void;
  62956. /**
  62957. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  62958. * Returns the directly updated WebGLBuffer.
  62959. * @param data the new data
  62960. * @param offset the new offset
  62961. * @param useBytes set to true if the offset is in bytes
  62962. */
  62963. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  62964. /**
  62965. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  62966. */
  62967. dispose(): void;
  62968. /**
  62969. * Enumerates each value of this vertex buffer as numbers.
  62970. * @param count the number of values to enumerate
  62971. * @param callback the callback function called for each value
  62972. */
  62973. forEach(count: number, callback: (value: number, index: number) => void): void;
  62974. /**
  62975. * Positions
  62976. */
  62977. static readonly PositionKind: string;
  62978. /**
  62979. * Normals
  62980. */
  62981. static readonly NormalKind: string;
  62982. /**
  62983. * Tangents
  62984. */
  62985. static readonly TangentKind: string;
  62986. /**
  62987. * Texture coordinates
  62988. */
  62989. static readonly UVKind: string;
  62990. /**
  62991. * Texture coordinates 2
  62992. */
  62993. static readonly UV2Kind: string;
  62994. /**
  62995. * Texture coordinates 3
  62996. */
  62997. static readonly UV3Kind: string;
  62998. /**
  62999. * Texture coordinates 4
  63000. */
  63001. static readonly UV4Kind: string;
  63002. /**
  63003. * Texture coordinates 5
  63004. */
  63005. static readonly UV5Kind: string;
  63006. /**
  63007. * Texture coordinates 6
  63008. */
  63009. static readonly UV6Kind: string;
  63010. /**
  63011. * Colors
  63012. */
  63013. static readonly ColorKind: string;
  63014. /**
  63015. * Matrix indices (for bones)
  63016. */
  63017. static readonly MatricesIndicesKind: string;
  63018. /**
  63019. * Matrix weights (for bones)
  63020. */
  63021. static readonly MatricesWeightsKind: string;
  63022. /**
  63023. * Additional matrix indices (for bones)
  63024. */
  63025. static readonly MatricesIndicesExtraKind: string;
  63026. /**
  63027. * Additional matrix weights (for bones)
  63028. */
  63029. static readonly MatricesWeightsExtraKind: string;
  63030. /**
  63031. * Deduces the stride given a kind.
  63032. * @param kind The kind string to deduce
  63033. * @returns The deduced stride
  63034. */
  63035. static DeduceStride(kind: string): number;
  63036. /**
  63037. * Gets the byte length of the given type.
  63038. * @param type the type
  63039. * @returns the number of bytes
  63040. */
  63041. static GetTypeByteLength(type: number): number;
  63042. /**
  63043. * Enumerates each value of the given parameters as numbers.
  63044. * @param data the data to enumerate
  63045. * @param byteOffset the byte offset of the data
  63046. * @param byteStride the byte stride of the data
  63047. * @param componentCount the number of components per element
  63048. * @param componentType the type of the component
  63049. * @param count the total number of components
  63050. * @param normalized whether the data is normalized
  63051. * @param callback the callback function called for each value
  63052. */
  63053. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63054. private static _GetFloatValue;
  63055. }
  63056. }
  63057. declare module BABYLON {
  63058. /**
  63059. * Class representing spherical polynomial coefficients to the 3rd degree
  63060. */
  63061. export class SphericalPolynomial {
  63062. /**
  63063. * The x coefficients of the spherical polynomial
  63064. */
  63065. x: Vector3;
  63066. /**
  63067. * The y coefficients of the spherical polynomial
  63068. */
  63069. y: Vector3;
  63070. /**
  63071. * The z coefficients of the spherical polynomial
  63072. */
  63073. z: Vector3;
  63074. /**
  63075. * The xx coefficients of the spherical polynomial
  63076. */
  63077. xx: Vector3;
  63078. /**
  63079. * The yy coefficients of the spherical polynomial
  63080. */
  63081. yy: Vector3;
  63082. /**
  63083. * The zz coefficients of the spherical polynomial
  63084. */
  63085. zz: Vector3;
  63086. /**
  63087. * The xy coefficients of the spherical polynomial
  63088. */
  63089. xy: Vector3;
  63090. /**
  63091. * The yz coefficients of the spherical polynomial
  63092. */
  63093. yz: Vector3;
  63094. /**
  63095. * The zx coefficients of the spherical polynomial
  63096. */
  63097. zx: Vector3;
  63098. /**
  63099. * Adds an ambient color to the spherical polynomial
  63100. * @param color the color to add
  63101. */
  63102. addAmbient(color: Color3): void;
  63103. /**
  63104. * Scales the spherical polynomial by the given amount
  63105. * @param scale the amount to scale
  63106. */
  63107. scale(scale: number): void;
  63108. /**
  63109. * Gets the spherical polynomial from harmonics
  63110. * @param harmonics the spherical harmonics
  63111. * @returns the spherical polynomial
  63112. */
  63113. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63114. /**
  63115. * Constructs a spherical polynomial from an array.
  63116. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63117. * @returns the spherical polynomial
  63118. */
  63119. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63120. }
  63121. /**
  63122. * Class representing spherical harmonics coefficients to the 3rd degree
  63123. */
  63124. export class SphericalHarmonics {
  63125. /**
  63126. * The l0,0 coefficients of the spherical harmonics
  63127. */
  63128. l00: Vector3;
  63129. /**
  63130. * The l1,-1 coefficients of the spherical harmonics
  63131. */
  63132. l1_1: Vector3;
  63133. /**
  63134. * The l1,0 coefficients of the spherical harmonics
  63135. */
  63136. l10: Vector3;
  63137. /**
  63138. * The l1,1 coefficients of the spherical harmonics
  63139. */
  63140. l11: Vector3;
  63141. /**
  63142. * The l2,-2 coefficients of the spherical harmonics
  63143. */
  63144. l2_2: Vector3;
  63145. /**
  63146. * The l2,-1 coefficients of the spherical harmonics
  63147. */
  63148. l2_1: Vector3;
  63149. /**
  63150. * The l2,0 coefficients of the spherical harmonics
  63151. */
  63152. l20: Vector3;
  63153. /**
  63154. * The l2,1 coefficients of the spherical harmonics
  63155. */
  63156. l21: Vector3;
  63157. /**
  63158. * The l2,2 coefficients of the spherical harmonics
  63159. */
  63160. lL22: Vector3;
  63161. /**
  63162. * Adds a light to the spherical harmonics
  63163. * @param direction the direction of the light
  63164. * @param color the color of the light
  63165. * @param deltaSolidAngle the delta solid angle of the light
  63166. */
  63167. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63168. /**
  63169. * Scales the spherical harmonics by the given amount
  63170. * @param scale the amount to scale
  63171. */
  63172. scale(scale: number): void;
  63173. /**
  63174. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63175. *
  63176. * ```
  63177. * E_lm = A_l * L_lm
  63178. * ```
  63179. *
  63180. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63181. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63182. * the scaling factors are given in equation 9.
  63183. */
  63184. convertIncidentRadianceToIrradiance(): void;
  63185. /**
  63186. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63187. *
  63188. * ```
  63189. * L = (1/pi) * E * rho
  63190. * ```
  63191. *
  63192. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63193. */
  63194. convertIrradianceToLambertianRadiance(): void;
  63195. /**
  63196. * Gets the spherical harmonics from polynomial
  63197. * @param polynomial the spherical polynomial
  63198. * @returns the spherical harmonics
  63199. */
  63200. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63201. /**
  63202. * Constructs a spherical harmonics from an array.
  63203. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63204. * @returns the spherical harmonics
  63205. */
  63206. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63207. }
  63208. }
  63209. declare module BABYLON {
  63210. /**
  63211. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63212. */
  63213. export interface CubeMapInfo {
  63214. /**
  63215. * The pixel array for the front face.
  63216. * This is stored in format, left to right, up to down format.
  63217. */
  63218. front: Nullable<ArrayBufferView>;
  63219. /**
  63220. * The pixel array for the back face.
  63221. * This is stored in format, left to right, up to down format.
  63222. */
  63223. back: Nullable<ArrayBufferView>;
  63224. /**
  63225. * The pixel array for the left face.
  63226. * This is stored in format, left to right, up to down format.
  63227. */
  63228. left: Nullable<ArrayBufferView>;
  63229. /**
  63230. * The pixel array for the right face.
  63231. * This is stored in format, left to right, up to down format.
  63232. */
  63233. right: Nullable<ArrayBufferView>;
  63234. /**
  63235. * The pixel array for the up face.
  63236. * This is stored in format, left to right, up to down format.
  63237. */
  63238. up: Nullable<ArrayBufferView>;
  63239. /**
  63240. * The pixel array for the down face.
  63241. * This is stored in format, left to right, up to down format.
  63242. */
  63243. down: Nullable<ArrayBufferView>;
  63244. /**
  63245. * The size of the cubemap stored.
  63246. *
  63247. * Each faces will be size * size pixels.
  63248. */
  63249. size: number;
  63250. /**
  63251. * The format of the texture.
  63252. *
  63253. * RGBA, RGB.
  63254. */
  63255. format: number;
  63256. /**
  63257. * The type of the texture data.
  63258. *
  63259. * UNSIGNED_INT, FLOAT.
  63260. */
  63261. type: number;
  63262. /**
  63263. * Specifies whether the texture is in gamma space.
  63264. */
  63265. gammaSpace: boolean;
  63266. }
  63267. /**
  63268. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63269. */
  63270. export class PanoramaToCubeMapTools {
  63271. private static FACE_FRONT;
  63272. private static FACE_BACK;
  63273. private static FACE_RIGHT;
  63274. private static FACE_LEFT;
  63275. private static FACE_DOWN;
  63276. private static FACE_UP;
  63277. /**
  63278. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63279. *
  63280. * @param float32Array The source data.
  63281. * @param inputWidth The width of the input panorama.
  63282. * @param inputHeight The height of the input panorama.
  63283. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63284. * @return The cubemap data
  63285. */
  63286. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63287. private static CreateCubemapTexture;
  63288. private static CalcProjectionSpherical;
  63289. }
  63290. }
  63291. declare module BABYLON {
  63292. /**
  63293. * Helper class dealing with the extraction of spherical polynomial dataArray
  63294. * from a cube map.
  63295. */
  63296. export class CubeMapToSphericalPolynomialTools {
  63297. private static FileFaces;
  63298. /**
  63299. * Converts a texture to the according Spherical Polynomial data.
  63300. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63301. *
  63302. * @param texture The texture to extract the information from.
  63303. * @return The Spherical Polynomial data.
  63304. */
  63305. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63306. /**
  63307. * Converts a cubemap to the according Spherical Polynomial data.
  63308. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63309. *
  63310. * @param cubeInfo The Cube map to extract the information from.
  63311. * @return The Spherical Polynomial data.
  63312. */
  63313. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63314. }
  63315. }
  63316. declare module BABYLON {
  63317. /**
  63318. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63319. * during the life time of the application.
  63320. */
  63321. export class EngineStore {
  63322. /** Gets the list of created engines */
  63323. static Instances: Engine[];
  63324. /**
  63325. * Gets the latest created engine
  63326. */
  63327. static readonly LastCreatedEngine: Nullable<Engine>;
  63328. /**
  63329. * Gets the latest created scene
  63330. */
  63331. static readonly LastCreatedScene: Nullable<Scene>;
  63332. }
  63333. }
  63334. declare module BABYLON {
  63335. /**
  63336. * Define options used to create a render target texture
  63337. */
  63338. export class RenderTargetCreationOptions {
  63339. /**
  63340. * Specifies is mipmaps must be generated
  63341. */
  63342. generateMipMaps?: boolean;
  63343. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63344. generateDepthBuffer?: boolean;
  63345. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63346. generateStencilBuffer?: boolean;
  63347. /** Defines texture type (int by default) */
  63348. type?: number;
  63349. /** Defines sampling mode (trilinear by default) */
  63350. samplingMode?: number;
  63351. /** Defines format (RGBA by default) */
  63352. format?: number;
  63353. }
  63354. }
  63355. declare module BABYLON {
  63356. /**
  63357. * @hidden
  63358. **/
  63359. export class _AlphaState {
  63360. private _isAlphaBlendDirty;
  63361. private _isBlendFunctionParametersDirty;
  63362. private _isBlendEquationParametersDirty;
  63363. private _isBlendConstantsDirty;
  63364. private _alphaBlend;
  63365. private _blendFunctionParameters;
  63366. private _blendEquationParameters;
  63367. private _blendConstants;
  63368. /**
  63369. * Initializes the state.
  63370. */
  63371. constructor();
  63372. readonly isDirty: boolean;
  63373. alphaBlend: boolean;
  63374. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63375. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63376. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63377. reset(): void;
  63378. apply(gl: WebGLRenderingContext): void;
  63379. }
  63380. }
  63381. declare module BABYLON {
  63382. /**
  63383. * @hidden
  63384. **/
  63385. export class _DepthCullingState {
  63386. private _isDepthTestDirty;
  63387. private _isDepthMaskDirty;
  63388. private _isDepthFuncDirty;
  63389. private _isCullFaceDirty;
  63390. private _isCullDirty;
  63391. private _isZOffsetDirty;
  63392. private _isFrontFaceDirty;
  63393. private _depthTest;
  63394. private _depthMask;
  63395. private _depthFunc;
  63396. private _cull;
  63397. private _cullFace;
  63398. private _zOffset;
  63399. private _frontFace;
  63400. /**
  63401. * Initializes the state.
  63402. */
  63403. constructor();
  63404. readonly isDirty: boolean;
  63405. zOffset: number;
  63406. cullFace: Nullable<number>;
  63407. cull: Nullable<boolean>;
  63408. depthFunc: Nullable<number>;
  63409. depthMask: boolean;
  63410. depthTest: boolean;
  63411. frontFace: Nullable<number>;
  63412. reset(): void;
  63413. apply(gl: WebGLRenderingContext): void;
  63414. }
  63415. }
  63416. declare module BABYLON {
  63417. /**
  63418. * @hidden
  63419. **/
  63420. export class _StencilState {
  63421. /** 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 */
  63422. static readonly ALWAYS: number;
  63423. /** Passed to stencilOperation to specify that stencil value must be kept */
  63424. static readonly KEEP: number;
  63425. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63426. static readonly REPLACE: number;
  63427. private _isStencilTestDirty;
  63428. private _isStencilMaskDirty;
  63429. private _isStencilFuncDirty;
  63430. private _isStencilOpDirty;
  63431. private _stencilTest;
  63432. private _stencilMask;
  63433. private _stencilFunc;
  63434. private _stencilFuncRef;
  63435. private _stencilFuncMask;
  63436. private _stencilOpStencilFail;
  63437. private _stencilOpDepthFail;
  63438. private _stencilOpStencilDepthPass;
  63439. readonly isDirty: boolean;
  63440. stencilFunc: number;
  63441. stencilFuncRef: number;
  63442. stencilFuncMask: number;
  63443. stencilOpStencilFail: number;
  63444. stencilOpDepthFail: number;
  63445. stencilOpStencilDepthPass: number;
  63446. stencilMask: number;
  63447. stencilTest: boolean;
  63448. constructor();
  63449. reset(): void;
  63450. apply(gl: WebGLRenderingContext): void;
  63451. }
  63452. }
  63453. declare module BABYLON {
  63454. /**
  63455. * @hidden
  63456. **/
  63457. export class _TimeToken {
  63458. _startTimeQuery: Nullable<WebGLQuery>;
  63459. _endTimeQuery: Nullable<WebGLQuery>;
  63460. _timeElapsedQuery: Nullable<WebGLQuery>;
  63461. _timeElapsedQueryEnded: boolean;
  63462. }
  63463. }
  63464. declare module BABYLON {
  63465. /**
  63466. * Internal interface used to track InternalTexture already bound to the GL context
  63467. */
  63468. export interface IInternalTextureTracker {
  63469. /**
  63470. * Gets or set the previous tracker in the list
  63471. */
  63472. previous: Nullable<IInternalTextureTracker>;
  63473. /**
  63474. * Gets or set the next tracker in the list
  63475. */
  63476. next: Nullable<IInternalTextureTracker>;
  63477. }
  63478. /**
  63479. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63480. */
  63481. export class DummyInternalTextureTracker {
  63482. /**
  63483. * Gets or set the previous tracker in the list
  63484. */
  63485. previous: Nullable<IInternalTextureTracker>;
  63486. /**
  63487. * Gets or set the next tracker in the list
  63488. */
  63489. next: Nullable<IInternalTextureTracker>;
  63490. }
  63491. }
  63492. declare module BABYLON {
  63493. /**
  63494. * Class used to store data associated with WebGL texture data for the engine
  63495. * This class should not be used directly
  63496. */
  63497. export class InternalTexture implements IInternalTextureTracker {
  63498. /** hidden */
  63499. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63500. /**
  63501. * The source of the texture data is unknown
  63502. */
  63503. static DATASOURCE_UNKNOWN: number;
  63504. /**
  63505. * Texture data comes from an URL
  63506. */
  63507. static DATASOURCE_URL: number;
  63508. /**
  63509. * Texture data is only used for temporary storage
  63510. */
  63511. static DATASOURCE_TEMP: number;
  63512. /**
  63513. * Texture data comes from raw data (ArrayBuffer)
  63514. */
  63515. static DATASOURCE_RAW: number;
  63516. /**
  63517. * Texture content is dynamic (video or dynamic texture)
  63518. */
  63519. static DATASOURCE_DYNAMIC: number;
  63520. /**
  63521. * Texture content is generated by rendering to it
  63522. */
  63523. static DATASOURCE_RENDERTARGET: number;
  63524. /**
  63525. * Texture content is part of a multi render target process
  63526. */
  63527. static DATASOURCE_MULTIRENDERTARGET: number;
  63528. /**
  63529. * Texture data comes from a cube data file
  63530. */
  63531. static DATASOURCE_CUBE: number;
  63532. /**
  63533. * Texture data comes from a raw cube data
  63534. */
  63535. static DATASOURCE_CUBERAW: number;
  63536. /**
  63537. * Texture data come from a prefiltered cube data file
  63538. */
  63539. static DATASOURCE_CUBEPREFILTERED: number;
  63540. /**
  63541. * Texture content is raw 3D data
  63542. */
  63543. static DATASOURCE_RAW3D: number;
  63544. /**
  63545. * Texture content is a depth texture
  63546. */
  63547. static DATASOURCE_DEPTHTEXTURE: number;
  63548. /**
  63549. * Texture data comes from a raw cube data encoded with RGBD
  63550. */
  63551. static DATASOURCE_CUBERAW_RGBD: number;
  63552. /**
  63553. * Defines if the texture is ready
  63554. */
  63555. isReady: boolean;
  63556. /**
  63557. * Defines if the texture is a cube texture
  63558. */
  63559. isCube: boolean;
  63560. /**
  63561. * Defines if the texture contains 3D data
  63562. */
  63563. is3D: boolean;
  63564. /**
  63565. * Gets the URL used to load this texture
  63566. */
  63567. url: string;
  63568. /**
  63569. * Gets the sampling mode of the texture
  63570. */
  63571. samplingMode: number;
  63572. /**
  63573. * Gets a boolean indicating if the texture needs mipmaps generation
  63574. */
  63575. generateMipMaps: boolean;
  63576. /**
  63577. * Gets the number of samples used by the texture (WebGL2+ only)
  63578. */
  63579. samples: number;
  63580. /**
  63581. * Gets the type of the texture (int, float...)
  63582. */
  63583. type: number;
  63584. /**
  63585. * Gets the format of the texture (RGB, RGBA...)
  63586. */
  63587. format: number;
  63588. /**
  63589. * Observable called when the texture is loaded
  63590. */
  63591. onLoadedObservable: Observable<InternalTexture>;
  63592. /**
  63593. * Gets the width of the texture
  63594. */
  63595. width: number;
  63596. /**
  63597. * Gets the height of the texture
  63598. */
  63599. height: number;
  63600. /**
  63601. * Gets the depth of the texture
  63602. */
  63603. depth: number;
  63604. /**
  63605. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  63606. */
  63607. baseWidth: number;
  63608. /**
  63609. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  63610. */
  63611. baseHeight: number;
  63612. /**
  63613. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  63614. */
  63615. baseDepth: number;
  63616. /**
  63617. * Gets a boolean indicating if the texture is inverted on Y axis
  63618. */
  63619. invertY: boolean;
  63620. /**
  63621. * Gets or set the previous tracker in the list
  63622. */
  63623. previous: Nullable<IInternalTextureTracker>;
  63624. /**
  63625. * Gets or set the next tracker in the list
  63626. */
  63627. next: Nullable<IInternalTextureTracker>;
  63628. /** @hidden */
  63629. _invertVScale: boolean;
  63630. /** @hidden */
  63631. _initialSlot: number;
  63632. /** @hidden */
  63633. _designatedSlot: number;
  63634. /** @hidden */
  63635. _dataSource: number;
  63636. /** @hidden */
  63637. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  63638. /** @hidden */
  63639. _bufferView: Nullable<ArrayBufferView>;
  63640. /** @hidden */
  63641. _bufferViewArray: Nullable<ArrayBufferView[]>;
  63642. /** @hidden */
  63643. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  63644. /** @hidden */
  63645. _size: number;
  63646. /** @hidden */
  63647. _extension: string;
  63648. /** @hidden */
  63649. _files: Nullable<string[]>;
  63650. /** @hidden */
  63651. _workingCanvas: HTMLCanvasElement;
  63652. /** @hidden */
  63653. _workingContext: CanvasRenderingContext2D;
  63654. /** @hidden */
  63655. _framebuffer: Nullable<WebGLFramebuffer>;
  63656. /** @hidden */
  63657. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  63658. /** @hidden */
  63659. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  63660. /** @hidden */
  63661. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  63662. /** @hidden */
  63663. _attachments: Nullable<number[]>;
  63664. /** @hidden */
  63665. _cachedCoordinatesMode: Nullable<number>;
  63666. /** @hidden */
  63667. _cachedWrapU: Nullable<number>;
  63668. /** @hidden */
  63669. _cachedWrapV: Nullable<number>;
  63670. /** @hidden */
  63671. _cachedWrapR: Nullable<number>;
  63672. /** @hidden */
  63673. _cachedAnisotropicFilteringLevel: Nullable<number>;
  63674. /** @hidden */
  63675. _isDisabled: boolean;
  63676. /** @hidden */
  63677. _compression: Nullable<string>;
  63678. /** @hidden */
  63679. _generateStencilBuffer: boolean;
  63680. /** @hidden */
  63681. _generateDepthBuffer: boolean;
  63682. /** @hidden */
  63683. _comparisonFunction: number;
  63684. /** @hidden */
  63685. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  63686. /** @hidden */
  63687. _lodGenerationScale: number;
  63688. /** @hidden */
  63689. _lodGenerationOffset: number;
  63690. /** @hidden */
  63691. _lodTextureHigh: BaseTexture;
  63692. /** @hidden */
  63693. _lodTextureMid: BaseTexture;
  63694. /** @hidden */
  63695. _lodTextureLow: BaseTexture;
  63696. /** @hidden */
  63697. _isRGBD: boolean;
  63698. /** @hidden */
  63699. _webGLTexture: Nullable<WebGLTexture>;
  63700. /** @hidden */
  63701. _references: number;
  63702. private _engine;
  63703. /**
  63704. * Gets the Engine the texture belongs to.
  63705. * @returns The babylon engine
  63706. */
  63707. getEngine(): Engine;
  63708. /**
  63709. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  63710. */
  63711. readonly dataSource: number;
  63712. /**
  63713. * Creates a new InternalTexture
  63714. * @param engine defines the engine to use
  63715. * @param dataSource defines the type of data that will be used
  63716. * @param delayAllocation if the texture allocation should be delayed (default: false)
  63717. */
  63718. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  63719. /**
  63720. * Increments the number of references (ie. the number of Texture that point to it)
  63721. */
  63722. incrementReferences(): void;
  63723. /**
  63724. * Change the size of the texture (not the size of the content)
  63725. * @param width defines the new width
  63726. * @param height defines the new height
  63727. * @param depth defines the new depth (1 by default)
  63728. */
  63729. updateSize(width: int, height: int, depth?: int): void;
  63730. /** @hidden */
  63731. _rebuild(): void;
  63732. /** @hidden */
  63733. _swapAndDie(target: InternalTexture): void;
  63734. /**
  63735. * Dispose the current allocated resources
  63736. */
  63737. dispose(): void;
  63738. }
  63739. }
  63740. declare module BABYLON {
  63741. /**
  63742. * This represents the main contract an easing function should follow.
  63743. * Easing functions are used throughout the animation system.
  63744. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63745. */
  63746. export interface IEasingFunction {
  63747. /**
  63748. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63749. * of the easing function.
  63750. * The link below provides some of the most common examples of easing functions.
  63751. * @see https://easings.net/
  63752. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63753. * @returns the corresponding value on the curve defined by the easing function
  63754. */
  63755. ease(gradient: number): number;
  63756. }
  63757. /**
  63758. * Base class used for every default easing function.
  63759. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63760. */
  63761. export class EasingFunction implements IEasingFunction {
  63762. /**
  63763. * Interpolation follows the mathematical formula associated with the easing function.
  63764. */
  63765. static readonly EASINGMODE_EASEIN: number;
  63766. /**
  63767. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  63768. */
  63769. static readonly EASINGMODE_EASEOUT: number;
  63770. /**
  63771. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  63772. */
  63773. static readonly EASINGMODE_EASEINOUT: number;
  63774. private _easingMode;
  63775. /**
  63776. * Sets the easing mode of the current function.
  63777. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  63778. */
  63779. setEasingMode(easingMode: number): void;
  63780. /**
  63781. * Gets the current easing mode.
  63782. * @returns the easing mode
  63783. */
  63784. getEasingMode(): number;
  63785. /**
  63786. * @hidden
  63787. */
  63788. easeInCore(gradient: number): number;
  63789. /**
  63790. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63791. * of the easing function.
  63792. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63793. * @returns the corresponding value on the curve defined by the easing function
  63794. */
  63795. ease(gradient: number): number;
  63796. }
  63797. /**
  63798. * Easing function with a circle shape (see link below).
  63799. * @see https://easings.net/#easeInCirc
  63800. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63801. */
  63802. export class CircleEase extends EasingFunction implements IEasingFunction {
  63803. /** @hidden */
  63804. easeInCore(gradient: number): number;
  63805. }
  63806. /**
  63807. * Easing function with a ease back shape (see link below).
  63808. * @see https://easings.net/#easeInBack
  63809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63810. */
  63811. export class BackEase extends EasingFunction implements IEasingFunction {
  63812. /** Defines the amplitude of the function */
  63813. amplitude: number;
  63814. /**
  63815. * Instantiates a back ease easing
  63816. * @see https://easings.net/#easeInBack
  63817. * @param amplitude Defines the amplitude of the function
  63818. */
  63819. constructor(
  63820. /** Defines the amplitude of the function */
  63821. amplitude?: number);
  63822. /** @hidden */
  63823. easeInCore(gradient: number): number;
  63824. }
  63825. /**
  63826. * Easing function with a bouncing shape (see link below).
  63827. * @see https://easings.net/#easeInBounce
  63828. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63829. */
  63830. export class BounceEase extends EasingFunction implements IEasingFunction {
  63831. /** Defines the number of bounces */
  63832. bounces: number;
  63833. /** Defines the amplitude of the bounce */
  63834. bounciness: number;
  63835. /**
  63836. * Instantiates a bounce easing
  63837. * @see https://easings.net/#easeInBounce
  63838. * @param bounces Defines the number of bounces
  63839. * @param bounciness Defines the amplitude of the bounce
  63840. */
  63841. constructor(
  63842. /** Defines the number of bounces */
  63843. bounces?: number,
  63844. /** Defines the amplitude of the bounce */
  63845. bounciness?: number);
  63846. /** @hidden */
  63847. easeInCore(gradient: number): number;
  63848. }
  63849. /**
  63850. * Easing function with a power of 3 shape (see link below).
  63851. * @see https://easings.net/#easeInCubic
  63852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63853. */
  63854. export class CubicEase extends EasingFunction implements IEasingFunction {
  63855. /** @hidden */
  63856. easeInCore(gradient: number): number;
  63857. }
  63858. /**
  63859. * Easing function with an elastic shape (see link below).
  63860. * @see https://easings.net/#easeInElastic
  63861. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63862. */
  63863. export class ElasticEase extends EasingFunction implements IEasingFunction {
  63864. /** Defines the number of oscillations*/
  63865. oscillations: number;
  63866. /** Defines the amplitude of the oscillations*/
  63867. springiness: number;
  63868. /**
  63869. * Instantiates an elastic easing function
  63870. * @see https://easings.net/#easeInElastic
  63871. * @param oscillations Defines the number of oscillations
  63872. * @param springiness Defines the amplitude of the oscillations
  63873. */
  63874. constructor(
  63875. /** Defines the number of oscillations*/
  63876. oscillations?: number,
  63877. /** Defines the amplitude of the oscillations*/
  63878. springiness?: number);
  63879. /** @hidden */
  63880. easeInCore(gradient: number): number;
  63881. }
  63882. /**
  63883. * Easing function with an exponential shape (see link below).
  63884. * @see https://easings.net/#easeInExpo
  63885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63886. */
  63887. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  63888. /** Defines the exponent of the function */
  63889. exponent: number;
  63890. /**
  63891. * Instantiates an exponential easing function
  63892. * @see https://easings.net/#easeInExpo
  63893. * @param exponent Defines the exponent of the function
  63894. */
  63895. constructor(
  63896. /** Defines the exponent of the function */
  63897. exponent?: number);
  63898. /** @hidden */
  63899. easeInCore(gradient: number): number;
  63900. }
  63901. /**
  63902. * Easing function with a power shape (see link below).
  63903. * @see https://easings.net/#easeInQuad
  63904. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63905. */
  63906. export class PowerEase extends EasingFunction implements IEasingFunction {
  63907. /** Defines the power of the function */
  63908. power: number;
  63909. /**
  63910. * Instantiates an power base easing function
  63911. * @see https://easings.net/#easeInQuad
  63912. * @param power Defines the power of the function
  63913. */
  63914. constructor(
  63915. /** Defines the power of the function */
  63916. power?: number);
  63917. /** @hidden */
  63918. easeInCore(gradient: number): number;
  63919. }
  63920. /**
  63921. * Easing function with a power of 2 shape (see link below).
  63922. * @see https://easings.net/#easeInQuad
  63923. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63924. */
  63925. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  63926. /** @hidden */
  63927. easeInCore(gradient: number): number;
  63928. }
  63929. /**
  63930. * Easing function with a power of 4 shape (see link below).
  63931. * @see https://easings.net/#easeInQuart
  63932. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63933. */
  63934. export class QuarticEase extends EasingFunction implements IEasingFunction {
  63935. /** @hidden */
  63936. easeInCore(gradient: number): number;
  63937. }
  63938. /**
  63939. * Easing function with a power of 5 shape (see link below).
  63940. * @see https://easings.net/#easeInQuint
  63941. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63942. */
  63943. export class QuinticEase extends EasingFunction implements IEasingFunction {
  63944. /** @hidden */
  63945. easeInCore(gradient: number): number;
  63946. }
  63947. /**
  63948. * Easing function with a sin shape (see link below).
  63949. * @see https://easings.net/#easeInSine
  63950. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63951. */
  63952. export class SineEase extends EasingFunction implements IEasingFunction {
  63953. /** @hidden */
  63954. easeInCore(gradient: number): number;
  63955. }
  63956. /**
  63957. * Easing function with a bezier shape (see link below).
  63958. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63959. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63960. */
  63961. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  63962. /** Defines the x component of the start tangent in the bezier curve */
  63963. x1: number;
  63964. /** Defines the y component of the start tangent in the bezier curve */
  63965. y1: number;
  63966. /** Defines the x component of the end tangent in the bezier curve */
  63967. x2: number;
  63968. /** Defines the y component of the end tangent in the bezier curve */
  63969. y2: number;
  63970. /**
  63971. * Instantiates a bezier function
  63972. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63973. * @param x1 Defines the x component of the start tangent in the bezier curve
  63974. * @param y1 Defines the y component of the start tangent in the bezier curve
  63975. * @param x2 Defines the x component of the end tangent in the bezier curve
  63976. * @param y2 Defines the y component of the end tangent in the bezier curve
  63977. */
  63978. constructor(
  63979. /** Defines the x component of the start tangent in the bezier curve */
  63980. x1?: number,
  63981. /** Defines the y component of the start tangent in the bezier curve */
  63982. y1?: number,
  63983. /** Defines the x component of the end tangent in the bezier curve */
  63984. x2?: number,
  63985. /** Defines the y component of the end tangent in the bezier curve */
  63986. y2?: number);
  63987. /** @hidden */
  63988. easeInCore(gradient: number): number;
  63989. }
  63990. }
  63991. declare module BABYLON {
  63992. /**
  63993. * Defines an interface which represents an animation key frame
  63994. */
  63995. export interface IAnimationKey {
  63996. /**
  63997. * Frame of the key frame
  63998. */
  63999. frame: number;
  64000. /**
  64001. * Value at the specifies key frame
  64002. */
  64003. value: any;
  64004. /**
  64005. * The input tangent for the cubic hermite spline
  64006. */
  64007. inTangent?: any;
  64008. /**
  64009. * The output tangent for the cubic hermite spline
  64010. */
  64011. outTangent?: any;
  64012. /**
  64013. * The animation interpolation type
  64014. */
  64015. interpolation?: AnimationKeyInterpolation;
  64016. }
  64017. /**
  64018. * Enum for the animation key frame interpolation type
  64019. */
  64020. export enum AnimationKeyInterpolation {
  64021. /**
  64022. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  64023. */
  64024. STEP = 1
  64025. }
  64026. }
  64027. declare module BABYLON {
  64028. /**
  64029. * Represents the range of an animation
  64030. */
  64031. export class AnimationRange {
  64032. /**The name of the animation range**/
  64033. name: string;
  64034. /**The starting frame of the animation */
  64035. from: number;
  64036. /**The ending frame of the animation*/
  64037. to: number;
  64038. /**
  64039. * Initializes the range of an animation
  64040. * @param name The name of the animation range
  64041. * @param from The starting frame of the animation
  64042. * @param to The ending frame of the animation
  64043. */
  64044. constructor(
  64045. /**The name of the animation range**/
  64046. name: string,
  64047. /**The starting frame of the animation */
  64048. from: number,
  64049. /**The ending frame of the animation*/
  64050. to: number);
  64051. /**
  64052. * Makes a copy of the animation range
  64053. * @returns A copy of the animation range
  64054. */
  64055. clone(): AnimationRange;
  64056. }
  64057. }
  64058. declare module BABYLON {
  64059. /**
  64060. * Composed of a frame, and an action function
  64061. */
  64062. export class AnimationEvent {
  64063. /** The frame for which the event is triggered **/
  64064. frame: number;
  64065. /** The event to perform when triggered **/
  64066. action: (currentFrame: number) => void;
  64067. /** Specifies if the event should be triggered only once**/
  64068. onlyOnce?: boolean | undefined;
  64069. /**
  64070. * Specifies if the animation event is done
  64071. */
  64072. isDone: boolean;
  64073. /**
  64074. * Initializes the animation event
  64075. * @param frame The frame for which the event is triggered
  64076. * @param action The event to perform when triggered
  64077. * @param onlyOnce Specifies if the event should be triggered only once
  64078. */
  64079. constructor(
  64080. /** The frame for which the event is triggered **/
  64081. frame: number,
  64082. /** The event to perform when triggered **/
  64083. action: (currentFrame: number) => void,
  64084. /** Specifies if the event should be triggered only once**/
  64085. onlyOnce?: boolean | undefined);
  64086. /** @hidden */
  64087. _clone(): AnimationEvent;
  64088. }
  64089. }
  64090. declare module BABYLON {
  64091. /**
  64092. * Interface used to define a behavior
  64093. */
  64094. export interface Behavior<T> {
  64095. /** gets or sets behavior's name */
  64096. name: string;
  64097. /**
  64098. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64099. */
  64100. init(): void;
  64101. /**
  64102. * Called when the behavior is attached to a target
  64103. * @param target defines the target where the behavior is attached to
  64104. */
  64105. attach(target: T): void;
  64106. /**
  64107. * Called when the behavior is detached from its target
  64108. */
  64109. detach(): void;
  64110. }
  64111. /**
  64112. * Interface implemented by classes supporting behaviors
  64113. */
  64114. export interface IBehaviorAware<T> {
  64115. /**
  64116. * Attach a behavior
  64117. * @param behavior defines the behavior to attach
  64118. * @returns the current host
  64119. */
  64120. addBehavior(behavior: Behavior<T>): T;
  64121. /**
  64122. * Remove a behavior from the current object
  64123. * @param behavior defines the behavior to detach
  64124. * @returns the current host
  64125. */
  64126. removeBehavior(behavior: Behavior<T>): T;
  64127. /**
  64128. * Gets a behavior using its name to search
  64129. * @param name defines the name to search
  64130. * @returns the behavior or null if not found
  64131. */
  64132. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64133. }
  64134. }
  64135. declare module BABYLON {
  64136. /**
  64137. * @hidden
  64138. */
  64139. export class IntersectionInfo {
  64140. bu: Nullable<number>;
  64141. bv: Nullable<number>;
  64142. distance: number;
  64143. faceId: number;
  64144. subMeshId: number;
  64145. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64146. }
  64147. }
  64148. declare module BABYLON {
  64149. /**
  64150. * Class used to store bounding sphere information
  64151. */
  64152. export class BoundingSphere {
  64153. /**
  64154. * Gets the center of the bounding sphere in local space
  64155. */
  64156. readonly center: Vector3;
  64157. /**
  64158. * Radius of the bounding sphere in local space
  64159. */
  64160. radius: number;
  64161. /**
  64162. * Gets the center of the bounding sphere in world space
  64163. */
  64164. readonly centerWorld: Vector3;
  64165. /**
  64166. * Radius of the bounding sphere in world space
  64167. */
  64168. radiusWorld: number;
  64169. /**
  64170. * Gets the minimum vector in local space
  64171. */
  64172. readonly minimum: Vector3;
  64173. /**
  64174. * Gets the maximum vector in local space
  64175. */
  64176. readonly maximum: Vector3;
  64177. private _worldMatrix;
  64178. private static readonly TmpVector3;
  64179. /**
  64180. * Creates a new bounding sphere
  64181. * @param min defines the minimum vector (in local space)
  64182. * @param max defines the maximum vector (in local space)
  64183. * @param worldMatrix defines the new world matrix
  64184. */
  64185. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64186. /**
  64187. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64188. * @param min defines the new minimum vector (in local space)
  64189. * @param max defines the new maximum vector (in local space)
  64190. * @param worldMatrix defines the new world matrix
  64191. */
  64192. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64193. /**
  64194. * Scale the current bounding sphere by applying a scale factor
  64195. * @param factor defines the scale factor to apply
  64196. * @returns the current bounding box
  64197. */
  64198. scale(factor: number): BoundingSphere;
  64199. /**
  64200. * Gets the world matrix of the bounding box
  64201. * @returns a matrix
  64202. */
  64203. getWorldMatrix(): DeepImmutable<Matrix>;
  64204. /** @hidden */
  64205. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64206. /**
  64207. * Tests if the bounding sphere is intersecting the frustum planes
  64208. * @param frustumPlanes defines the frustum planes to test
  64209. * @returns true if there is an intersection
  64210. */
  64211. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64212. /**
  64213. * Tests if the bounding sphere center is in between the frustum planes.
  64214. * Used for optimistic fast inclusion.
  64215. * @param frustumPlanes defines the frustum planes to test
  64216. * @returns true if the sphere center is in between the frustum planes
  64217. */
  64218. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64219. /**
  64220. * Tests if a point is inside the bounding sphere
  64221. * @param point defines the point to test
  64222. * @returns true if the point is inside the bounding sphere
  64223. */
  64224. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64225. /**
  64226. * Checks if two sphere intersct
  64227. * @param sphere0 sphere 0
  64228. * @param sphere1 sphere 1
  64229. * @returns true if the speres intersect
  64230. */
  64231. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64232. }
  64233. }
  64234. declare module BABYLON {
  64235. /**
  64236. * Class used to store bounding box information
  64237. */
  64238. export class BoundingBox implements ICullable {
  64239. /**
  64240. * Gets the 8 vectors representing the bounding box in local space
  64241. */
  64242. readonly vectors: Vector3[];
  64243. /**
  64244. * Gets the center of the bounding box in local space
  64245. */
  64246. readonly center: Vector3;
  64247. /**
  64248. * Gets the center of the bounding box in world space
  64249. */
  64250. readonly centerWorld: Vector3;
  64251. /**
  64252. * Gets the extend size in local space
  64253. */
  64254. readonly extendSize: Vector3;
  64255. /**
  64256. * Gets the extend size in world space
  64257. */
  64258. readonly extendSizeWorld: Vector3;
  64259. /**
  64260. * Gets the OBB (object bounding box) directions
  64261. */
  64262. readonly directions: Vector3[];
  64263. /**
  64264. * Gets the 8 vectors representing the bounding box in world space
  64265. */
  64266. readonly vectorsWorld: Vector3[];
  64267. /**
  64268. * Gets the minimum vector in world space
  64269. */
  64270. readonly minimumWorld: Vector3;
  64271. /**
  64272. * Gets the maximum vector in world space
  64273. */
  64274. readonly maximumWorld: Vector3;
  64275. /**
  64276. * Gets the minimum vector in local space
  64277. */
  64278. readonly minimum: Vector3;
  64279. /**
  64280. * Gets the maximum vector in local space
  64281. */
  64282. readonly maximum: Vector3;
  64283. private _worldMatrix;
  64284. private static readonly TmpVector3;
  64285. /**
  64286. * @hidden
  64287. */
  64288. _tag: number;
  64289. /**
  64290. * Creates a new bounding box
  64291. * @param min defines the minimum vector (in local space)
  64292. * @param max defines the maximum vector (in local space)
  64293. * @param worldMatrix defines the new world matrix
  64294. */
  64295. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64296. /**
  64297. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64298. * @param min defines the new minimum vector (in local space)
  64299. * @param max defines the new maximum vector (in local space)
  64300. * @param worldMatrix defines the new world matrix
  64301. */
  64302. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64303. /**
  64304. * Scale the current bounding box by applying a scale factor
  64305. * @param factor defines the scale factor to apply
  64306. * @returns the current bounding box
  64307. */
  64308. scale(factor: number): BoundingBox;
  64309. /**
  64310. * Gets the world matrix of the bounding box
  64311. * @returns a matrix
  64312. */
  64313. getWorldMatrix(): DeepImmutable<Matrix>;
  64314. /** @hidden */
  64315. _update(world: DeepImmutable<Matrix>): void;
  64316. /**
  64317. * Tests if the bounding box is intersecting the frustum planes
  64318. * @param frustumPlanes defines the frustum planes to test
  64319. * @returns true if there is an intersection
  64320. */
  64321. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64322. /**
  64323. * Tests if the bounding box is entirely inside the frustum planes
  64324. * @param frustumPlanes defines the frustum planes to test
  64325. * @returns true if there is an inclusion
  64326. */
  64327. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64328. /**
  64329. * Tests if a point is inside the bounding box
  64330. * @param point defines the point to test
  64331. * @returns true if the point is inside the bounding box
  64332. */
  64333. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64334. /**
  64335. * Tests if the bounding box intersects with a bounding sphere
  64336. * @param sphere defines the sphere to test
  64337. * @returns true if there is an intersection
  64338. */
  64339. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64340. /**
  64341. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64342. * @param min defines the min vector to use
  64343. * @param max defines the max vector to use
  64344. * @returns true if there is an intersection
  64345. */
  64346. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64347. /**
  64348. * Tests if two bounding boxes are intersections
  64349. * @param box0 defines the first box to test
  64350. * @param box1 defines the second box to test
  64351. * @returns true if there is an intersection
  64352. */
  64353. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64354. /**
  64355. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64356. * @param minPoint defines the minimum vector of the bounding box
  64357. * @param maxPoint defines the maximum vector of the bounding box
  64358. * @param sphereCenter defines the sphere center
  64359. * @param sphereRadius defines the sphere radius
  64360. * @returns true if there is an intersection
  64361. */
  64362. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64363. /**
  64364. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64365. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64366. * @param frustumPlanes defines the frustum planes to test
  64367. * @return true if there is an inclusion
  64368. */
  64369. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64370. /**
  64371. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64372. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64373. * @param frustumPlanes defines the frustum planes to test
  64374. * @return true if there is an intersection
  64375. */
  64376. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64377. }
  64378. }
  64379. declare module BABYLON {
  64380. /** @hidden */
  64381. export class Collider {
  64382. /** Define if a collision was found */
  64383. collisionFound: boolean;
  64384. /**
  64385. * Define last intersection point in local space
  64386. */
  64387. intersectionPoint: Vector3;
  64388. /**
  64389. * Define last collided mesh
  64390. */
  64391. collidedMesh: Nullable<AbstractMesh>;
  64392. private _collisionPoint;
  64393. private _planeIntersectionPoint;
  64394. private _tempVector;
  64395. private _tempVector2;
  64396. private _tempVector3;
  64397. private _tempVector4;
  64398. private _edge;
  64399. private _baseToVertex;
  64400. private _destinationPoint;
  64401. private _slidePlaneNormal;
  64402. private _displacementVector;
  64403. /** @hidden */
  64404. _radius: Vector3;
  64405. /** @hidden */
  64406. _retry: number;
  64407. private _velocity;
  64408. private _basePoint;
  64409. private _epsilon;
  64410. /** @hidden */
  64411. _velocityWorldLength: number;
  64412. /** @hidden */
  64413. _basePointWorld: Vector3;
  64414. private _velocityWorld;
  64415. private _normalizedVelocity;
  64416. /** @hidden */
  64417. _initialVelocity: Vector3;
  64418. /** @hidden */
  64419. _initialPosition: Vector3;
  64420. private _nearestDistance;
  64421. private _collisionMask;
  64422. collisionMask: number;
  64423. /**
  64424. * Gets the plane normal used to compute the sliding response (in local space)
  64425. */
  64426. readonly slidePlaneNormal: Vector3;
  64427. /** @hidden */
  64428. _initialize(source: Vector3, dir: Vector3, e: number): void;
  64429. /** @hidden */
  64430. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  64431. /** @hidden */
  64432. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  64433. /** @hidden */
  64434. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  64435. /** @hidden */
  64436. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  64437. /** @hidden */
  64438. _getResponse(pos: Vector3, vel: Vector3): void;
  64439. }
  64440. }
  64441. declare module BABYLON {
  64442. /**
  64443. * Interface for cullable objects
  64444. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  64445. */
  64446. export interface ICullable {
  64447. /**
  64448. * Checks if the object or part of the object is in the frustum
  64449. * @param frustumPlanes Camera near/planes
  64450. * @returns true if the object is in frustum otherwise false
  64451. */
  64452. isInFrustum(frustumPlanes: Plane[]): boolean;
  64453. /**
  64454. * Checks if a cullable object (mesh...) is in the camera frustum
  64455. * Unlike isInFrustum this cheks the full bounding box
  64456. * @param frustumPlanes Camera near/planes
  64457. * @returns true if the object is in frustum otherwise false
  64458. */
  64459. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64460. }
  64461. /**
  64462. * Info for a bounding data of a mesh
  64463. */
  64464. export class BoundingInfo implements ICullable {
  64465. /**
  64466. * Bounding box for the mesh
  64467. */
  64468. readonly boundingBox: BoundingBox;
  64469. /**
  64470. * Bounding sphere for the mesh
  64471. */
  64472. readonly boundingSphere: BoundingSphere;
  64473. private _isLocked;
  64474. private static readonly TmpVector3;
  64475. /**
  64476. * Constructs bounding info
  64477. * @param minimum min vector of the bounding box/sphere
  64478. * @param maximum max vector of the bounding box/sphere
  64479. * @param worldMatrix defines the new world matrix
  64480. */
  64481. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64482. /**
  64483. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64484. * @param min defines the new minimum vector (in local space)
  64485. * @param max defines the new maximum vector (in local space)
  64486. * @param worldMatrix defines the new world matrix
  64487. */
  64488. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64489. /**
  64490. * min vector of the bounding box/sphere
  64491. */
  64492. readonly minimum: Vector3;
  64493. /**
  64494. * max vector of the bounding box/sphere
  64495. */
  64496. readonly maximum: Vector3;
  64497. /**
  64498. * If the info is locked and won't be updated to avoid perf overhead
  64499. */
  64500. isLocked: boolean;
  64501. /**
  64502. * Updates the bounding sphere and box
  64503. * @param world world matrix to be used to update
  64504. */
  64505. update(world: DeepImmutable<Matrix>): void;
  64506. /**
  64507. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64508. * @param center New center of the bounding info
  64509. * @param extend New extend of the bounding info
  64510. * @returns the current bounding info
  64511. */
  64512. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64513. /**
  64514. * Scale the current bounding info by applying a scale factor
  64515. * @param factor defines the scale factor to apply
  64516. * @returns the current bounding info
  64517. */
  64518. scale(factor: number): BoundingInfo;
  64519. /**
  64520. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64521. * @param frustumPlanes defines the frustum to test
  64522. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64523. * @returns true if the bounding info is in the frustum planes
  64524. */
  64525. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64526. /**
  64527. * Gets the world distance between the min and max points of the bounding box
  64528. */
  64529. readonly diagonalLength: number;
  64530. /**
  64531. * Checks if a cullable object (mesh...) is in the camera frustum
  64532. * Unlike isInFrustum this cheks the full bounding box
  64533. * @param frustumPlanes Camera near/planes
  64534. * @returns true if the object is in frustum otherwise false
  64535. */
  64536. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64537. /** @hidden */
  64538. _checkCollision(collider: Collider): boolean;
  64539. /**
  64540. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  64541. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64542. * @param point the point to check intersection with
  64543. * @returns if the point intersects
  64544. */
  64545. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64546. /**
  64547. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  64548. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64549. * @param boundingInfo the bounding info to check intersection with
  64550. * @param precise if the intersection should be done using OBB
  64551. * @returns if the bounding info intersects
  64552. */
  64553. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  64554. }
  64555. }
  64556. declare module BABYLON {
  64557. /**
  64558. * Defines an array and its length.
  64559. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  64560. */
  64561. export interface ISmartArrayLike<T> {
  64562. /**
  64563. * The data of the array.
  64564. */
  64565. data: Array<T>;
  64566. /**
  64567. * The active length of the array.
  64568. */
  64569. length: number;
  64570. }
  64571. /**
  64572. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64573. */
  64574. export class SmartArray<T> implements ISmartArrayLike<T> {
  64575. /**
  64576. * The full set of data from the array.
  64577. */
  64578. data: Array<T>;
  64579. /**
  64580. * The active length of the array.
  64581. */
  64582. length: number;
  64583. protected _id: number;
  64584. /**
  64585. * Instantiates a Smart Array.
  64586. * @param capacity defines the default capacity of the array.
  64587. */
  64588. constructor(capacity: number);
  64589. /**
  64590. * Pushes a value at the end of the active data.
  64591. * @param value defines the object to push in the array.
  64592. */
  64593. push(value: T): void;
  64594. /**
  64595. * Iterates over the active data and apply the lambda to them.
  64596. * @param func defines the action to apply on each value.
  64597. */
  64598. forEach(func: (content: T) => void): void;
  64599. /**
  64600. * Sorts the full sets of data.
  64601. * @param compareFn defines the comparison function to apply.
  64602. */
  64603. sort(compareFn: (a: T, b: T) => number): void;
  64604. /**
  64605. * Resets the active data to an empty array.
  64606. */
  64607. reset(): void;
  64608. /**
  64609. * Releases all the data from the array as well as the array.
  64610. */
  64611. dispose(): void;
  64612. /**
  64613. * Concats the active data with a given array.
  64614. * @param array defines the data to concatenate with.
  64615. */
  64616. concat(array: any): void;
  64617. /**
  64618. * Returns the position of a value in the active data.
  64619. * @param value defines the value to find the index for
  64620. * @returns the index if found in the active data otherwise -1
  64621. */
  64622. indexOf(value: T): number;
  64623. /**
  64624. * Returns whether an element is part of the active data.
  64625. * @param value defines the value to look for
  64626. * @returns true if found in the active data otherwise false
  64627. */
  64628. contains(value: T): boolean;
  64629. private static _GlobalId;
  64630. }
  64631. /**
  64632. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64633. * The data in this array can only be present once
  64634. */
  64635. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  64636. private _duplicateId;
  64637. /**
  64638. * Pushes a value at the end of the active data.
  64639. * THIS DOES NOT PREVENT DUPPLICATE DATA
  64640. * @param value defines the object to push in the array.
  64641. */
  64642. push(value: T): void;
  64643. /**
  64644. * Pushes a value at the end of the active data.
  64645. * If the data is already present, it won t be added again
  64646. * @param value defines the object to push in the array.
  64647. * @returns true if added false if it was already present
  64648. */
  64649. pushNoDuplicate(value: T): boolean;
  64650. /**
  64651. * Resets the active data to an empty array.
  64652. */
  64653. reset(): void;
  64654. /**
  64655. * Concats the active data with a given array.
  64656. * This ensures no dupplicate will be present in the result.
  64657. * @param array defines the data to concatenate with.
  64658. */
  64659. concatWithNoDuplicate(array: any): void;
  64660. }
  64661. }
  64662. declare module BABYLON {
  64663. /**
  64664. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64665. * separate meshes. This can be use to improve performances.
  64666. * @see http://doc.babylonjs.com/how_to/multi_materials
  64667. */
  64668. export class MultiMaterial extends Material {
  64669. private _subMaterials;
  64670. /**
  64671. * Gets or Sets the list of Materials used within the multi material.
  64672. * They need to be ordered according to the submeshes order in the associated mesh
  64673. */
  64674. subMaterials: Nullable<Material>[];
  64675. /**
  64676. * Function used to align with Node.getChildren()
  64677. * @returns the list of Materials used within the multi material
  64678. */
  64679. getChildren(): Nullable<Material>[];
  64680. /**
  64681. * Instantiates a new Multi Material
  64682. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64683. * separate meshes. This can be use to improve performances.
  64684. * @see http://doc.babylonjs.com/how_to/multi_materials
  64685. * @param name Define the name in the scene
  64686. * @param scene Define the scene the material belongs to
  64687. */
  64688. constructor(name: string, scene: Scene);
  64689. private _hookArray;
  64690. /**
  64691. * Get one of the submaterial by its index in the submaterials array
  64692. * @param index The index to look the sub material at
  64693. * @returns The Material if the index has been defined
  64694. */
  64695. getSubMaterial(index: number): Nullable<Material>;
  64696. /**
  64697. * Get the list of active textures for the whole sub materials list.
  64698. * @returns All the textures that will be used during the rendering
  64699. */
  64700. getActiveTextures(): BaseTexture[];
  64701. /**
  64702. * Gets the current class name of the material e.g. "MultiMaterial"
  64703. * Mainly use in serialization.
  64704. * @returns the class name
  64705. */
  64706. getClassName(): string;
  64707. /**
  64708. * Checks if the material is ready to render the requested sub mesh
  64709. * @param mesh Define the mesh the submesh belongs to
  64710. * @param subMesh Define the sub mesh to look readyness for
  64711. * @param useInstances Define whether or not the material is used with instances
  64712. * @returns true if ready, otherwise false
  64713. */
  64714. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  64715. /**
  64716. * Clones the current material and its related sub materials
  64717. * @param name Define the name of the newly cloned material
  64718. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64719. * @returns the cloned material
  64720. */
  64721. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  64722. /**
  64723. * Serializes the materials into a JSON representation.
  64724. * @returns the JSON representation
  64725. */
  64726. serialize(): any;
  64727. /**
  64728. * Dispose the material and release its associated resources
  64729. * @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)
  64730. * @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)
  64731. * @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)
  64732. */
  64733. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64734. /**
  64735. * Creates a MultiMaterial from parsed MultiMaterial data.
  64736. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64737. * @param scene defines the hosting scene
  64738. * @returns a new MultiMaterial
  64739. */
  64740. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64741. }
  64742. }
  64743. declare module BABYLON {
  64744. /**
  64745. * Class used to represent data loading progression
  64746. */
  64747. export class SceneLoaderFlags {
  64748. private static _ForceFullSceneLoadingForIncremental;
  64749. private static _ShowLoadingScreen;
  64750. private static _CleanBoneMatrixWeights;
  64751. private static _loggingLevel;
  64752. /**
  64753. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  64754. */
  64755. static ForceFullSceneLoadingForIncremental: boolean;
  64756. /**
  64757. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  64758. */
  64759. static ShowLoadingScreen: boolean;
  64760. /**
  64761. * Defines the current logging level (while loading the scene)
  64762. * @ignorenaming
  64763. */
  64764. static loggingLevel: number;
  64765. /**
  64766. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  64767. */
  64768. static CleanBoneMatrixWeights: boolean;
  64769. }
  64770. }
  64771. declare module BABYLON {
  64772. /**
  64773. * 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.
  64774. * @see https://doc.babylonjs.com/how_to/transformnode
  64775. */
  64776. export class TransformNode extends Node {
  64777. /**
  64778. * Object will not rotate to face the camera
  64779. */
  64780. static BILLBOARDMODE_NONE: number;
  64781. /**
  64782. * Object will rotate to face the camera but only on the x axis
  64783. */
  64784. static BILLBOARDMODE_X: number;
  64785. /**
  64786. * Object will rotate to face the camera but only on the y axis
  64787. */
  64788. static BILLBOARDMODE_Y: number;
  64789. /**
  64790. * Object will rotate to face the camera but only on the z axis
  64791. */
  64792. static BILLBOARDMODE_Z: number;
  64793. /**
  64794. * Object will rotate to face the camera
  64795. */
  64796. static BILLBOARDMODE_ALL: number;
  64797. private _forward;
  64798. private _forwardInverted;
  64799. private _up;
  64800. private _right;
  64801. private _rightInverted;
  64802. private _position;
  64803. private _rotation;
  64804. private _rotationQuaternion;
  64805. protected _scaling: Vector3;
  64806. protected _isDirty: boolean;
  64807. private _transformToBoneReferal;
  64808. /**
  64809. * Set the billboard mode. Default is 0.
  64810. *
  64811. * | Value | Type | Description |
  64812. * | --- | --- | --- |
  64813. * | 0 | BILLBOARDMODE_NONE | |
  64814. * | 1 | BILLBOARDMODE_X | |
  64815. * | 2 | BILLBOARDMODE_Y | |
  64816. * | 4 | BILLBOARDMODE_Z | |
  64817. * | 7 | BILLBOARDMODE_ALL | |
  64818. *
  64819. */
  64820. billboardMode: number;
  64821. /**
  64822. * 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
  64823. */
  64824. scalingDeterminant: number;
  64825. /**
  64826. * Sets the distance of the object to max, often used by skybox
  64827. */
  64828. infiniteDistance: boolean;
  64829. /**
  64830. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  64831. * By default the system will update normals to compensate
  64832. */
  64833. ignoreNonUniformScaling: boolean;
  64834. /** @hidden */
  64835. _poseMatrix: Matrix;
  64836. /** @hidden */
  64837. _localMatrix: Matrix;
  64838. private _absolutePosition;
  64839. private _pivotMatrix;
  64840. private _pivotMatrixInverse;
  64841. protected _postMultiplyPivotMatrix: boolean;
  64842. protected _isWorldMatrixFrozen: boolean;
  64843. /** @hidden */
  64844. _indexInSceneTransformNodesArray: number;
  64845. /**
  64846. * An event triggered after the world matrix is updated
  64847. */
  64848. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  64849. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  64850. /**
  64851. * Gets a string identifying the name of the class
  64852. * @returns "TransformNode" string
  64853. */
  64854. getClassName(): string;
  64855. /**
  64856. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  64857. */
  64858. position: Vector3;
  64859. /**
  64860. * 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)).
  64861. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  64862. */
  64863. rotation: Vector3;
  64864. /**
  64865. * 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)).
  64866. */
  64867. scaling: Vector3;
  64868. /**
  64869. * 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).
  64870. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  64871. */
  64872. rotationQuaternion: Nullable<Quaternion>;
  64873. /**
  64874. * The forward direction of that transform in world space.
  64875. */
  64876. readonly forward: Vector3;
  64877. /**
  64878. * The up direction of that transform in world space.
  64879. */
  64880. readonly up: Vector3;
  64881. /**
  64882. * The right direction of that transform in world space.
  64883. */
  64884. readonly right: Vector3;
  64885. /**
  64886. * Copies the parameter passed Matrix into the mesh Pose matrix.
  64887. * @param matrix the matrix to copy the pose from
  64888. * @returns this TransformNode.
  64889. */
  64890. updatePoseMatrix(matrix: Matrix): TransformNode;
  64891. /**
  64892. * Returns the mesh Pose matrix.
  64893. * @returns the pose matrix
  64894. */
  64895. getPoseMatrix(): Matrix;
  64896. /** @hidden */
  64897. _isSynchronized(): boolean;
  64898. /** @hidden */
  64899. _initCache(): void;
  64900. /**
  64901. * Flag the transform node as dirty (Forcing it to update everything)
  64902. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  64903. * @returns this transform node
  64904. */
  64905. markAsDirty(property: string): TransformNode;
  64906. /**
  64907. * Returns the current mesh absolute position.
  64908. * Returns a Vector3.
  64909. */
  64910. readonly absolutePosition: Vector3;
  64911. /**
  64912. * Sets a new matrix to apply before all other transformation
  64913. * @param matrix defines the transform matrix
  64914. * @returns the current TransformNode
  64915. */
  64916. setPreTransformMatrix(matrix: Matrix): TransformNode;
  64917. /**
  64918. * Sets a new pivot matrix to the current node
  64919. * @param matrix defines the new pivot matrix to use
  64920. * @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
  64921. * @returns the current TransformNode
  64922. */
  64923. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  64924. /**
  64925. * Returns the mesh pivot matrix.
  64926. * Default : Identity.
  64927. * @returns the matrix
  64928. */
  64929. getPivotMatrix(): Matrix;
  64930. /**
  64931. * Prevents the World matrix to be computed any longer.
  64932. * @returns the TransformNode.
  64933. */
  64934. freezeWorldMatrix(): TransformNode;
  64935. /**
  64936. * Allows back the World matrix computation.
  64937. * @returns the TransformNode.
  64938. */
  64939. unfreezeWorldMatrix(): this;
  64940. /**
  64941. * True if the World matrix has been frozen.
  64942. */
  64943. readonly isWorldMatrixFrozen: boolean;
  64944. /**
  64945. * Retuns the mesh absolute position in the World.
  64946. * @returns a Vector3.
  64947. */
  64948. getAbsolutePosition(): Vector3;
  64949. /**
  64950. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  64951. * @param absolutePosition the absolute position to set
  64952. * @returns the TransformNode.
  64953. */
  64954. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  64955. /**
  64956. * Sets the mesh position in its local space.
  64957. * @param vector3 the position to set in localspace
  64958. * @returns the TransformNode.
  64959. */
  64960. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  64961. /**
  64962. * Returns the mesh position in the local space from the current World matrix values.
  64963. * @returns a new Vector3.
  64964. */
  64965. getPositionExpressedInLocalSpace(): Vector3;
  64966. /**
  64967. * Translates the mesh along the passed Vector3 in its local space.
  64968. * @param vector3 the distance to translate in localspace
  64969. * @returns the TransformNode.
  64970. */
  64971. locallyTranslate(vector3: Vector3): TransformNode;
  64972. private static _lookAtVectorCache;
  64973. /**
  64974. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  64975. * @param targetPoint the position (must be in same space as current mesh) to look at
  64976. * @param yawCor optional yaw (y-axis) correction in radians
  64977. * @param pitchCor optional pitch (x-axis) correction in radians
  64978. * @param rollCor optional roll (z-axis) correction in radians
  64979. * @param space the choosen space of the target
  64980. * @returns the TransformNode.
  64981. */
  64982. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  64983. /**
  64984. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  64985. * This Vector3 is expressed in the World space.
  64986. * @param localAxis axis to rotate
  64987. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  64988. */
  64989. getDirection(localAxis: Vector3): Vector3;
  64990. /**
  64991. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  64992. * localAxis is expressed in the mesh local space.
  64993. * result is computed in the Wordl space from the mesh World matrix.
  64994. * @param localAxis axis to rotate
  64995. * @param result the resulting transformnode
  64996. * @returns this TransformNode.
  64997. */
  64998. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  64999. /**
  65000. * Sets this transform node rotation to the given local axis.
  65001. * @param localAxis the axis in local space
  65002. * @param yawCor optional yaw (y-axis) correction in radians
  65003. * @param pitchCor optional pitch (x-axis) correction in radians
  65004. * @param rollCor optional roll (z-axis) correction in radians
  65005. * @returns this TransformNode
  65006. */
  65007. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65008. /**
  65009. * Sets a new pivot point to the current node
  65010. * @param point defines the new pivot point to use
  65011. * @param space defines if the point is in world or local space (local by default)
  65012. * @returns the current TransformNode
  65013. */
  65014. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65015. /**
  65016. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65017. * @returns the pivot point
  65018. */
  65019. getPivotPoint(): Vector3;
  65020. /**
  65021. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65022. * @param result the vector3 to store the result
  65023. * @returns this TransformNode.
  65024. */
  65025. getPivotPointToRef(result: Vector3): TransformNode;
  65026. /**
  65027. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65028. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65029. */
  65030. getAbsolutePivotPoint(): Vector3;
  65031. /**
  65032. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65033. * @param result vector3 to store the result
  65034. * @returns this TransformNode.
  65035. */
  65036. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65037. /**
  65038. * Defines the passed node as the parent of the current node.
  65039. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65040. * @param node the node ot set as the parent
  65041. * @returns this TransformNode.
  65042. */
  65043. setParent(node: Nullable<Node>): TransformNode;
  65044. private _nonUniformScaling;
  65045. /**
  65046. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65047. */
  65048. readonly nonUniformScaling: boolean;
  65049. /** @hidden */
  65050. _updateNonUniformScalingState(value: boolean): boolean;
  65051. /**
  65052. * Attach the current TransformNode to another TransformNode associated with a bone
  65053. * @param bone Bone affecting the TransformNode
  65054. * @param affectedTransformNode TransformNode associated with the bone
  65055. * @returns this object
  65056. */
  65057. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65058. /**
  65059. * Detach the transform node if its associated with a bone
  65060. * @returns this object
  65061. */
  65062. detachFromBone(): TransformNode;
  65063. private static _rotationAxisCache;
  65064. /**
  65065. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65066. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65067. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65068. * The passed axis is also normalized.
  65069. * @param axis the axis to rotate around
  65070. * @param amount the amount to rotate in radians
  65071. * @param space Space to rotate in (Default: local)
  65072. * @returns the TransformNode.
  65073. */
  65074. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65075. /**
  65076. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65077. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65078. * The passed axis is also normalized. .
  65079. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65080. * @param point the point to rotate around
  65081. * @param axis the axis to rotate around
  65082. * @param amount the amount to rotate in radians
  65083. * @returns the TransformNode
  65084. */
  65085. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65086. /**
  65087. * Translates the mesh along the axis vector for the passed distance in the given space.
  65088. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65089. * @param axis the axis to translate in
  65090. * @param distance the distance to translate
  65091. * @param space Space to rotate in (Default: local)
  65092. * @returns the TransformNode.
  65093. */
  65094. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65095. /**
  65096. * Adds a rotation step to the mesh current rotation.
  65097. * x, y, z are Euler angles expressed in radians.
  65098. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65099. * This means this rotation is made in the mesh local space only.
  65100. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65101. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65102. * ```javascript
  65103. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65104. * ```
  65105. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65106. * 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.
  65107. * @param x Rotation to add
  65108. * @param y Rotation to add
  65109. * @param z Rotation to add
  65110. * @returns the TransformNode.
  65111. */
  65112. addRotation(x: number, y: number, z: number): TransformNode;
  65113. /**
  65114. * Computes the world matrix of the node
  65115. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65116. * @returns the world matrix
  65117. */
  65118. computeWorldMatrix(force?: boolean): Matrix;
  65119. protected _afterComputeWorldMatrix(): void;
  65120. /**
  65121. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65122. * @param func callback function to add
  65123. *
  65124. * @returns the TransformNode.
  65125. */
  65126. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65127. /**
  65128. * Removes a registered callback function.
  65129. * @param func callback function to remove
  65130. * @returns the TransformNode.
  65131. */
  65132. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65133. /**
  65134. * Gets the position of the current mesh in camera space
  65135. * @param camera defines the camera to use
  65136. * @returns a position
  65137. */
  65138. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65139. /**
  65140. * Returns the distance from the mesh to the active camera
  65141. * @param camera defines the camera to use
  65142. * @returns the distance
  65143. */
  65144. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65145. /**
  65146. * Clone the current transform node
  65147. * @param name Name of the new clone
  65148. * @param newParent New parent for the clone
  65149. * @param doNotCloneChildren Do not clone children hierarchy
  65150. * @returns the new transform node
  65151. */
  65152. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65153. /**
  65154. * Serializes the objects information.
  65155. * @param currentSerializationObject defines the object to serialize in
  65156. * @returns the serialized object
  65157. */
  65158. serialize(currentSerializationObject?: any): any;
  65159. /**
  65160. * Returns a new TransformNode object parsed from the source provided.
  65161. * @param parsedTransformNode is the source.
  65162. * @param scene the scne the object belongs to
  65163. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65164. * @returns a new TransformNode object parsed from the source provided.
  65165. */
  65166. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65167. /**
  65168. * Get all child-transformNodes of this node
  65169. * @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
  65170. * @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
  65171. * @returns an array of TransformNode
  65172. */
  65173. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65174. /**
  65175. * Releases resources associated with this transform node.
  65176. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65177. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65178. */
  65179. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65180. }
  65181. }
  65182. declare module BABYLON {
  65183. /**
  65184. * Class used to override all child animations of a given target
  65185. */
  65186. export class AnimationPropertiesOverride {
  65187. /**
  65188. * Gets or sets a value indicating if animation blending must be used
  65189. */
  65190. enableBlending: boolean;
  65191. /**
  65192. * Gets or sets the blending speed to use when enableBlending is true
  65193. */
  65194. blendingSpeed: number;
  65195. /**
  65196. * Gets or sets the default loop mode to use
  65197. */
  65198. loopMode: number;
  65199. }
  65200. }
  65201. declare module BABYLON {
  65202. /**
  65203. * Class used to store bone information
  65204. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65205. */
  65206. export class Bone extends Node {
  65207. /**
  65208. * defines the bone name
  65209. */
  65210. name: string;
  65211. private static _tmpVecs;
  65212. private static _tmpQuat;
  65213. private static _tmpMats;
  65214. /**
  65215. * Gets the list of child bones
  65216. */
  65217. children: Bone[];
  65218. /** Gets the animations associated with this bone */
  65219. animations: Animation[];
  65220. /**
  65221. * Gets or sets bone length
  65222. */
  65223. length: number;
  65224. /**
  65225. * @hidden Internal only
  65226. * Set this value to map this bone to a different index in the transform matrices
  65227. * Set this value to -1 to exclude the bone from the transform matrices
  65228. */
  65229. _index: Nullable<number>;
  65230. private _skeleton;
  65231. private _localMatrix;
  65232. private _restPose;
  65233. private _baseMatrix;
  65234. private _absoluteTransform;
  65235. private _invertedAbsoluteTransform;
  65236. private _parent;
  65237. private _scalingDeterminant;
  65238. private _worldTransform;
  65239. private _localScaling;
  65240. private _localRotation;
  65241. private _localPosition;
  65242. private _needToDecompose;
  65243. private _needToCompose;
  65244. /** @hidden */
  65245. _linkedTransformNode: Nullable<TransformNode>;
  65246. /** @hidden */
  65247. /** @hidden */
  65248. _matrix: Matrix;
  65249. /**
  65250. * Create a new bone
  65251. * @param name defines the bone name
  65252. * @param skeleton defines the parent skeleton
  65253. * @param parentBone defines the parent (can be null if the bone is the root)
  65254. * @param localMatrix defines the local matrix
  65255. * @param restPose defines the rest pose matrix
  65256. * @param baseMatrix defines the base matrix
  65257. * @param index defines index of the bone in the hiearchy
  65258. */
  65259. constructor(
  65260. /**
  65261. * defines the bone name
  65262. */
  65263. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65264. /**
  65265. * Gets the current object class name.
  65266. * @return the class name
  65267. */
  65268. getClassName(): string;
  65269. /**
  65270. * Gets the parent skeleton
  65271. * @returns a skeleton
  65272. */
  65273. getSkeleton(): Skeleton;
  65274. /**
  65275. * Gets parent bone
  65276. * @returns a bone or null if the bone is the root of the bone hierarchy
  65277. */
  65278. getParent(): Nullable<Bone>;
  65279. /**
  65280. * Returns an array containing the root bones
  65281. * @returns an array containing the root bones
  65282. */
  65283. getChildren(): Array<Bone>;
  65284. /**
  65285. * Sets the parent bone
  65286. * @param parent defines the parent (can be null if the bone is the root)
  65287. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65288. */
  65289. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65290. /**
  65291. * Gets the local matrix
  65292. * @returns a matrix
  65293. */
  65294. getLocalMatrix(): Matrix;
  65295. /**
  65296. * Gets the base matrix (initial matrix which remains unchanged)
  65297. * @returns a matrix
  65298. */
  65299. getBaseMatrix(): Matrix;
  65300. /**
  65301. * Gets the rest pose matrix
  65302. * @returns a matrix
  65303. */
  65304. getRestPose(): Matrix;
  65305. /**
  65306. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65307. */
  65308. getWorldMatrix(): Matrix;
  65309. /**
  65310. * Sets the local matrix to rest pose matrix
  65311. */
  65312. returnToRest(): void;
  65313. /**
  65314. * Gets the inverse of the absolute transform matrix.
  65315. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65316. * @returns a matrix
  65317. */
  65318. getInvertedAbsoluteTransform(): Matrix;
  65319. /**
  65320. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65321. * @returns a matrix
  65322. */
  65323. getAbsoluteTransform(): Matrix;
  65324. /**
  65325. * Links with the given transform node.
  65326. * The local matrix of this bone is copied from the transform node every frame.
  65327. * @param transformNode defines the transform node to link to
  65328. */
  65329. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65330. /** Gets or sets current position (in local space) */
  65331. position: Vector3;
  65332. /** Gets or sets current rotation (in local space) */
  65333. rotation: Vector3;
  65334. /** Gets or sets current rotation quaternion (in local space) */
  65335. rotationQuaternion: Quaternion;
  65336. /** Gets or sets current scaling (in local space) */
  65337. scaling: Vector3;
  65338. /**
  65339. * Gets the animation properties override
  65340. */
  65341. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65342. private _decompose;
  65343. private _compose;
  65344. /**
  65345. * Update the base and local matrices
  65346. * @param matrix defines the new base or local matrix
  65347. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65348. * @param updateLocalMatrix defines if the local matrix should be updated
  65349. */
  65350. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65351. /** @hidden */
  65352. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65353. /**
  65354. * Flag the bone as dirty (Forcing it to update everything)
  65355. */
  65356. markAsDirty(): void;
  65357. private _markAsDirtyAndCompose;
  65358. private _markAsDirtyAndDecompose;
  65359. /**
  65360. * Translate the bone in local or world space
  65361. * @param vec The amount to translate the bone
  65362. * @param space The space that the translation is in
  65363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65364. */
  65365. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65366. /**
  65367. * Set the postion of the bone in local or world space
  65368. * @param position The position to set the bone
  65369. * @param space The space that the position is in
  65370. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65371. */
  65372. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65373. /**
  65374. * Set the absolute position of the bone (world space)
  65375. * @param position The position to set the bone
  65376. * @param mesh The mesh that this bone is attached to
  65377. */
  65378. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65379. /**
  65380. * Scale the bone on the x, y and z axes (in local space)
  65381. * @param x The amount to scale the bone on the x axis
  65382. * @param y The amount to scale the bone on the y axis
  65383. * @param z The amount to scale the bone on the z axis
  65384. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65385. */
  65386. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65387. /**
  65388. * Set the bone scaling in local space
  65389. * @param scale defines the scaling vector
  65390. */
  65391. setScale(scale: Vector3): void;
  65392. /**
  65393. * Gets the current scaling in local space
  65394. * @returns the current scaling vector
  65395. */
  65396. getScale(): Vector3;
  65397. /**
  65398. * Gets the current scaling in local space and stores it in a target vector
  65399. * @param result defines the target vector
  65400. */
  65401. getScaleToRef(result: Vector3): void;
  65402. /**
  65403. * Set the yaw, pitch, and roll of the bone in local or world space
  65404. * @param yaw The rotation of the bone on the y axis
  65405. * @param pitch The rotation of the bone on the x axis
  65406. * @param roll The rotation of the bone on the z axis
  65407. * @param space The space that the axes of rotation are in
  65408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65409. */
  65410. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65411. /**
  65412. * Add a rotation to the bone on an axis in local or world space
  65413. * @param axis The axis to rotate the bone on
  65414. * @param amount The amount to rotate the bone
  65415. * @param space The space that the axis is in
  65416. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65417. */
  65418. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  65419. /**
  65420. * Set the rotation of the bone to a particular axis angle in local or world space
  65421. * @param axis The axis to rotate the bone on
  65422. * @param angle The angle that the bone should be rotated to
  65423. * @param space The space that the axis is in
  65424. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65425. */
  65426. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  65427. /**
  65428. * Set the euler rotation of the bone in local of world space
  65429. * @param rotation The euler rotation that the bone should be set to
  65430. * @param space The space that the rotation is in
  65431. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65432. */
  65433. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65434. /**
  65435. * Set the quaternion rotation of the bone in local of world space
  65436. * @param quat The quaternion rotation that the bone should be set to
  65437. * @param space The space that the rotation is in
  65438. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65439. */
  65440. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  65441. /**
  65442. * Set the rotation matrix of the bone in local of world space
  65443. * @param rotMat The rotation matrix that the bone should be set to
  65444. * @param space The space that the rotation is in
  65445. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65446. */
  65447. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65448. private _rotateWithMatrix;
  65449. private _getNegativeRotationToRef;
  65450. /**
  65451. * Get the position of the bone in local or world space
  65452. * @param space The space that the returned position is in
  65453. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65454. * @returns The position of the bone
  65455. */
  65456. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65457. /**
  65458. * Copy the position of the bone to a vector3 in local or world space
  65459. * @param space The space that the returned position is in
  65460. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65461. * @param result The vector3 to copy the position to
  65462. */
  65463. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65464. /**
  65465. * Get the absolute position of the bone (world space)
  65466. * @param mesh The mesh that this bone is attached to
  65467. * @returns The absolute position of the bone
  65468. */
  65469. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65470. /**
  65471. * Copy the absolute position of the bone (world space) to the result param
  65472. * @param mesh The mesh that this bone is attached to
  65473. * @param result The vector3 to copy the absolute position to
  65474. */
  65475. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65476. /**
  65477. * Compute the absolute transforms of this bone and its children
  65478. */
  65479. computeAbsoluteTransforms(): void;
  65480. /**
  65481. * Get the world direction from an axis that is in the local space of the bone
  65482. * @param localAxis The local direction that is used to compute the world direction
  65483. * @param mesh The mesh that this bone is attached to
  65484. * @returns The world direction
  65485. */
  65486. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65487. /**
  65488. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65489. * @param localAxis The local direction that is used to compute the world direction
  65490. * @param mesh The mesh that this bone is attached to
  65491. * @param result The vector3 that the world direction will be copied to
  65492. */
  65493. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65494. /**
  65495. * Get the euler rotation of the bone in local or world space
  65496. * @param space The space that the rotation should be in
  65497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65498. * @returns The euler rotation
  65499. */
  65500. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65501. /**
  65502. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65503. * @param space The space that the rotation should be in
  65504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65505. * @param result The vector3 that the rotation should be copied to
  65506. */
  65507. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65508. /**
  65509. * Get the quaternion rotation of the bone in either local or world space
  65510. * @param space The space that the rotation should be in
  65511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65512. * @returns The quaternion rotation
  65513. */
  65514. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65515. /**
  65516. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65517. * @param space The space that the rotation should be in
  65518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65519. * @param result The quaternion that the rotation should be copied to
  65520. */
  65521. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65522. /**
  65523. * Get the rotation matrix of the bone in local or world space
  65524. * @param space The space that the rotation should be in
  65525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65526. * @returns The rotation matrix
  65527. */
  65528. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65529. /**
  65530. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65531. * @param space The space that the rotation should be in
  65532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65533. * @param result The quaternion that the rotation should be copied to
  65534. */
  65535. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65536. /**
  65537. * Get the world position of a point that is in the local space of the bone
  65538. * @param position The local position
  65539. * @param mesh The mesh that this bone is attached to
  65540. * @returns The world position
  65541. */
  65542. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65543. /**
  65544. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65545. * @param position The local position
  65546. * @param mesh The mesh that this bone is attached to
  65547. * @param result The vector3 that the world position should be copied to
  65548. */
  65549. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65550. /**
  65551. * Get the local position of a point that is in world space
  65552. * @param position The world position
  65553. * @param mesh The mesh that this bone is attached to
  65554. * @returns The local position
  65555. */
  65556. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65557. /**
  65558. * Get the local position of a point that is in world space and copy it to the result param
  65559. * @param position The world position
  65560. * @param mesh The mesh that this bone is attached to
  65561. * @param result The vector3 that the local position should be copied to
  65562. */
  65563. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65564. }
  65565. }
  65566. declare module BABYLON {
  65567. /**
  65568. * Class for creating a cube texture
  65569. */
  65570. export class CubeTexture extends BaseTexture {
  65571. private _delayedOnLoad;
  65572. /**
  65573. * The url of the texture
  65574. */
  65575. url: string;
  65576. /**
  65577. * Gets or sets the center of the bounding box associated with the cube texture.
  65578. * It must define where the camera used to render the texture was set
  65579. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65580. */
  65581. boundingBoxPosition: Vector3;
  65582. private _boundingBoxSize;
  65583. /**
  65584. * Gets or sets the size of the bounding box associated with the cube texture
  65585. * When defined, the cubemap will switch to local mode
  65586. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65587. * @example https://www.babylonjs-playground.com/#RNASML
  65588. */
  65589. /**
  65590. * Returns the bounding box size
  65591. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65592. */
  65593. boundingBoxSize: Vector3;
  65594. protected _rotationY: number;
  65595. /**
  65596. * Sets texture matrix rotation angle around Y axis in radians.
  65597. */
  65598. /**
  65599. * Gets texture matrix rotation angle around Y axis radians.
  65600. */
  65601. rotationY: number;
  65602. /**
  65603. * Are mip maps generated for this texture or not.
  65604. */
  65605. readonly noMipmap: boolean;
  65606. private _noMipmap;
  65607. private _files;
  65608. private _extensions;
  65609. private _textureMatrix;
  65610. private _format;
  65611. private _createPolynomials;
  65612. /** @hidden */
  65613. _prefiltered: boolean;
  65614. /**
  65615. * Creates a cube texture from an array of image urls
  65616. * @param files defines an array of image urls
  65617. * @param scene defines the hosting scene
  65618. * @param noMipmap specifies if mip maps are not used
  65619. * @returns a cube texture
  65620. */
  65621. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  65622. /**
  65623. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  65624. * @param url defines the url of the prefiltered texture
  65625. * @param scene defines the scene the texture is attached to
  65626. * @param forcedExtension defines the extension of the file if different from the url
  65627. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65628. * @return the prefiltered texture
  65629. */
  65630. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  65631. /**
  65632. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  65633. * as prefiltered data.
  65634. * @param rootUrl defines the url of the texture or the root name of the six images
  65635. * @param scene defines the scene the texture is attached to
  65636. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  65637. * @param noMipmap defines if mipmaps should be created or not
  65638. * @param files defines the six files to load for the different faces
  65639. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  65640. * @param onError defines a callback triggered in case of error during load
  65641. * @param format defines the internal format to use for the texture once loaded
  65642. * @param prefiltered defines whether or not the texture is created from prefiltered data
  65643. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  65644. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65645. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65646. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65647. * @return the cube texture
  65648. */
  65649. 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);
  65650. /**
  65651. * Get the current class name of the texture useful for serialization or dynamic coding.
  65652. * @returns "CubeTexture"
  65653. */
  65654. getClassName(): string;
  65655. /**
  65656. * Update the url (and optional buffer) of this texture if url was null during construction.
  65657. * @param url the url of the texture
  65658. * @param forcedExtension defines the extension to use
  65659. * @param onLoad callback called when the texture is loaded (defaults to null)
  65660. */
  65661. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  65662. /**
  65663. * Delays loading of the cube texture
  65664. * @param forcedExtension defines the extension to use
  65665. */
  65666. delayLoad(forcedExtension?: string): void;
  65667. /**
  65668. * Returns the reflection texture matrix
  65669. * @returns the reflection texture matrix
  65670. */
  65671. getReflectionTextureMatrix(): Matrix;
  65672. /**
  65673. * Sets the reflection texture matrix
  65674. * @param value Reflection texture matrix
  65675. */
  65676. setReflectionTextureMatrix(value: Matrix): void;
  65677. /**
  65678. * Parses text to create a cube texture
  65679. * @param parsedTexture define the serialized text to read from
  65680. * @param scene defines the hosting scene
  65681. * @param rootUrl defines the root url of the cube texture
  65682. * @returns a cube texture
  65683. */
  65684. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  65685. /**
  65686. * Makes a clone, or deep copy, of the cube texture
  65687. * @returns a new cube texture
  65688. */
  65689. clone(): CubeTexture;
  65690. }
  65691. }
  65692. declare module BABYLON {
  65693. /** @hidden */
  65694. export var postprocessVertexShader: {
  65695. name: string;
  65696. shader: string;
  65697. };
  65698. }
  65699. declare module BABYLON {
  65700. /**
  65701. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  65702. * This is the base of the follow, arc rotate cameras and Free camera
  65703. * @see http://doc.babylonjs.com/features/cameras
  65704. */
  65705. export class TargetCamera extends Camera {
  65706. private static _RigCamTransformMatrix;
  65707. private static _TargetTransformMatrix;
  65708. private static _TargetFocalPoint;
  65709. /**
  65710. * Define the current direction the camera is moving to
  65711. */
  65712. cameraDirection: Vector3;
  65713. /**
  65714. * Define the current rotation the camera is rotating to
  65715. */
  65716. cameraRotation: Vector2;
  65717. /**
  65718. * When set, the up vector of the camera will be updated by the rotation of the camera
  65719. */
  65720. updateUpVectorFromRotation: boolean;
  65721. private _tmpQuaternion;
  65722. /**
  65723. * Define the current rotation of the camera
  65724. */
  65725. rotation: Vector3;
  65726. /**
  65727. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  65728. */
  65729. rotationQuaternion: Quaternion;
  65730. /**
  65731. * Define the current speed of the camera
  65732. */
  65733. speed: number;
  65734. /**
  65735. * Add cconstraint to the camera to prevent it to move freely in all directions and
  65736. * around all axis.
  65737. */
  65738. noRotationConstraint: boolean;
  65739. /**
  65740. * Define the current target of the camera as an object or a position.
  65741. */
  65742. lockedTarget: any;
  65743. /** @hidden */
  65744. _currentTarget: Vector3;
  65745. /** @hidden */
  65746. _initialFocalDistance: number;
  65747. /** @hidden */
  65748. _viewMatrix: Matrix;
  65749. /** @hidden */
  65750. _camMatrix: Matrix;
  65751. /** @hidden */
  65752. _cameraTransformMatrix: Matrix;
  65753. /** @hidden */
  65754. _cameraRotationMatrix: Matrix;
  65755. /** @hidden */
  65756. _referencePoint: Vector3;
  65757. /** @hidden */
  65758. _transformedReferencePoint: Vector3;
  65759. protected _globalCurrentTarget: Vector3;
  65760. protected _globalCurrentUpVector: Vector3;
  65761. /** @hidden */
  65762. _reset: () => void;
  65763. private _defaultUp;
  65764. /**
  65765. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  65766. * This is the base of the follow, arc rotate cameras and Free camera
  65767. * @see http://doc.babylonjs.com/features/cameras
  65768. * @param name Defines the name of the camera in the scene
  65769. * @param position Defines the start position of the camera in the scene
  65770. * @param scene Defines the scene the camera belongs to
  65771. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  65772. */
  65773. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  65774. /**
  65775. * Gets the position in front of the camera at a given distance.
  65776. * @param distance The distance from the camera we want the position to be
  65777. * @returns the position
  65778. */
  65779. getFrontPosition(distance: number): Vector3;
  65780. /** @hidden */
  65781. _getLockedTargetPosition(): Nullable<Vector3>;
  65782. private _storedPosition;
  65783. private _storedRotation;
  65784. private _storedRotationQuaternion;
  65785. /**
  65786. * Store current camera state of the camera (fov, position, rotation, etc..)
  65787. * @returns the camera
  65788. */
  65789. storeState(): Camera;
  65790. /**
  65791. * Restored camera state. You must call storeState() first
  65792. * @returns whether it was successful or not
  65793. * @hidden
  65794. */
  65795. _restoreStateValues(): boolean;
  65796. /** @hidden */
  65797. _initCache(): void;
  65798. /** @hidden */
  65799. _updateCache(ignoreParentClass?: boolean): void;
  65800. /** @hidden */
  65801. _isSynchronizedViewMatrix(): boolean;
  65802. /** @hidden */
  65803. _computeLocalCameraSpeed(): number;
  65804. /** @hidden */
  65805. setTarget(target: Vector3): void;
  65806. /**
  65807. * Return the current target position of the camera. This value is expressed in local space.
  65808. * @returns the target position
  65809. */
  65810. getTarget(): Vector3;
  65811. /** @hidden */
  65812. _decideIfNeedsToMove(): boolean;
  65813. /** @hidden */
  65814. _updatePosition(): void;
  65815. /** @hidden */
  65816. _checkInputs(): void;
  65817. protected _updateCameraRotationMatrix(): void;
  65818. /**
  65819. * 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)
  65820. * @returns the current camera
  65821. */
  65822. private _rotateUpVectorWithCameraRotationMatrix;
  65823. private _cachedRotationZ;
  65824. private _cachedQuaternionRotationZ;
  65825. /** @hidden */
  65826. _getViewMatrix(): Matrix;
  65827. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  65828. /**
  65829. * @hidden
  65830. */
  65831. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  65832. /**
  65833. * @hidden
  65834. */
  65835. _updateRigCameras(): void;
  65836. private _getRigCamPositionAndTarget;
  65837. /**
  65838. * Gets the current object class name.
  65839. * @return the class name
  65840. */
  65841. getClassName(): string;
  65842. }
  65843. }
  65844. declare module BABYLON {
  65845. /**
  65846. * @ignore
  65847. * This is a list of all the different input types that are available in the application.
  65848. * Fo instance: ArcRotateCameraGamepadInput...
  65849. */
  65850. export var CameraInputTypes: {};
  65851. /**
  65852. * This is the contract to implement in order to create a new input class.
  65853. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  65854. */
  65855. export interface ICameraInput<TCamera extends Camera> {
  65856. /**
  65857. * Defines the camera the input is attached to.
  65858. */
  65859. camera: Nullable<TCamera>;
  65860. /**
  65861. * Gets the class name of the current intput.
  65862. * @returns the class name
  65863. */
  65864. getClassName(): string;
  65865. /**
  65866. * Get the friendly name associated with the input class.
  65867. * @returns the input friendly name
  65868. */
  65869. getSimpleName(): string;
  65870. /**
  65871. * Attach the input controls to a specific dom element to get the input from.
  65872. * @param element Defines the element the controls should be listened from
  65873. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65874. */
  65875. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  65876. /**
  65877. * Detach the current controls from the specified dom element.
  65878. * @param element Defines the element to stop listening the inputs from
  65879. */
  65880. detachControl(element: Nullable<HTMLElement>): void;
  65881. /**
  65882. * Update the current camera state depending on the inputs that have been used this frame.
  65883. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65884. */
  65885. checkInputs?: () => void;
  65886. }
  65887. /**
  65888. * Represents a map of input types to input instance or input index to input instance.
  65889. */
  65890. export interface CameraInputsMap<TCamera extends Camera> {
  65891. /**
  65892. * Accessor to the input by input type.
  65893. */
  65894. [name: string]: ICameraInput<TCamera>;
  65895. /**
  65896. * Accessor to the input by input index.
  65897. */
  65898. [idx: number]: ICameraInput<TCamera>;
  65899. }
  65900. /**
  65901. * This represents the input manager used within a camera.
  65902. * It helps dealing with all the different kind of input attached to a camera.
  65903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65904. */
  65905. export class CameraInputsManager<TCamera extends Camera> {
  65906. /**
  65907. * Defines the list of inputs attahed to the camera.
  65908. */
  65909. attached: CameraInputsMap<TCamera>;
  65910. /**
  65911. * Defines the dom element the camera is collecting inputs from.
  65912. * This is null if the controls have not been attached.
  65913. */
  65914. attachedElement: Nullable<HTMLElement>;
  65915. /**
  65916. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65917. */
  65918. noPreventDefault: boolean;
  65919. /**
  65920. * Defined the camera the input manager belongs to.
  65921. */
  65922. camera: TCamera;
  65923. /**
  65924. * Update the current camera state depending on the inputs that have been used this frame.
  65925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65926. */
  65927. checkInputs: () => void;
  65928. /**
  65929. * Instantiate a new Camera Input Manager.
  65930. * @param camera Defines the camera the input manager blongs to
  65931. */
  65932. constructor(camera: TCamera);
  65933. /**
  65934. * Add an input method to a camera
  65935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65936. * @param input camera input method
  65937. */
  65938. add(input: ICameraInput<TCamera>): void;
  65939. /**
  65940. * Remove a specific input method from a camera
  65941. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  65942. * @param inputToRemove camera input method
  65943. */
  65944. remove(inputToRemove: ICameraInput<TCamera>): void;
  65945. /**
  65946. * Remove a specific input type from a camera
  65947. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  65948. * @param inputType the type of the input to remove
  65949. */
  65950. removeByType(inputType: string): void;
  65951. private _addCheckInputs;
  65952. /**
  65953. * Attach the input controls to the currently attached dom element to listen the events from.
  65954. * @param input Defines the input to attach
  65955. */
  65956. attachInput(input: ICameraInput<TCamera>): void;
  65957. /**
  65958. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  65959. * @param element Defines the dom element to collect the events from
  65960. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65961. */
  65962. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  65963. /**
  65964. * Detach the current manager inputs controls from a specific dom element.
  65965. * @param element Defines the dom element to collect the events from
  65966. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  65967. */
  65968. detachElement(element: HTMLElement, disconnect?: boolean): void;
  65969. /**
  65970. * Rebuild the dynamic inputCheck function from the current list of
  65971. * defined inputs in the manager.
  65972. */
  65973. rebuildInputCheck(): void;
  65974. /**
  65975. * Remove all attached input methods from a camera
  65976. */
  65977. clear(): void;
  65978. /**
  65979. * Serialize the current input manager attached to a camera.
  65980. * This ensures than once parsed,
  65981. * the input associated to the camera will be identical to the current ones
  65982. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  65983. */
  65984. serialize(serializedCamera: any): void;
  65985. /**
  65986. * Parses an input manager serialized JSON to restore the previous list of inputs
  65987. * and states associated to a camera.
  65988. * @param parsedCamera Defines the JSON to parse
  65989. */
  65990. parse(parsedCamera: any): void;
  65991. }
  65992. }
  65993. declare module BABYLON {
  65994. /**
  65995. * Gather the list of keyboard event types as constants.
  65996. */
  65997. export class KeyboardEventTypes {
  65998. /**
  65999. * The keydown event is fired when a key becomes active (pressed).
  66000. */
  66001. static readonly KEYDOWN: number;
  66002. /**
  66003. * The keyup event is fired when a key has been released.
  66004. */
  66005. static readonly KEYUP: number;
  66006. }
  66007. /**
  66008. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66009. */
  66010. export class KeyboardInfo {
  66011. /**
  66012. * Defines the type of event (KeyboardEventTypes)
  66013. */
  66014. type: number;
  66015. /**
  66016. * Defines the related dom event
  66017. */
  66018. event: KeyboardEvent;
  66019. /**
  66020. * Instantiates a new keyboard info.
  66021. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66022. * @param type Defines the type of event (KeyboardEventTypes)
  66023. * @param event Defines the related dom event
  66024. */
  66025. constructor(
  66026. /**
  66027. * Defines the type of event (KeyboardEventTypes)
  66028. */
  66029. type: number,
  66030. /**
  66031. * Defines the related dom event
  66032. */
  66033. event: KeyboardEvent);
  66034. }
  66035. /**
  66036. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66037. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  66038. */
  66039. export class KeyboardInfoPre extends KeyboardInfo {
  66040. /**
  66041. * Defines the type of event (KeyboardEventTypes)
  66042. */
  66043. type: number;
  66044. /**
  66045. * Defines the related dom event
  66046. */
  66047. event: KeyboardEvent;
  66048. /**
  66049. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  66050. */
  66051. skipOnPointerObservable: boolean;
  66052. /**
  66053. * Instantiates a new keyboard pre info.
  66054. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66055. * @param type Defines the type of event (KeyboardEventTypes)
  66056. * @param event Defines the related dom event
  66057. */
  66058. constructor(
  66059. /**
  66060. * Defines the type of event (KeyboardEventTypes)
  66061. */
  66062. type: number,
  66063. /**
  66064. * Defines the related dom event
  66065. */
  66066. event: KeyboardEvent);
  66067. }
  66068. }
  66069. declare module BABYLON {
  66070. /**
  66071. * Manage the keyboard inputs to control the movement of a free camera.
  66072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66073. */
  66074. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  66075. /**
  66076. * Defines the camera the input is attached to.
  66077. */
  66078. camera: FreeCamera;
  66079. /**
  66080. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  66081. */
  66082. keysUp: number[];
  66083. /**
  66084. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  66085. */
  66086. keysDown: number[];
  66087. /**
  66088. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  66089. */
  66090. keysLeft: number[];
  66091. /**
  66092. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  66093. */
  66094. keysRight: number[];
  66095. private _keys;
  66096. private _onCanvasBlurObserver;
  66097. private _onKeyboardObserver;
  66098. private _engine;
  66099. private _scene;
  66100. /**
  66101. * Attach the input controls to a specific dom element to get the input from.
  66102. * @param element Defines the element the controls should be listened from
  66103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66104. */
  66105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66106. /**
  66107. * Detach the current controls from the specified dom element.
  66108. * @param element Defines the element to stop listening the inputs from
  66109. */
  66110. detachControl(element: Nullable<HTMLElement>): void;
  66111. /**
  66112. * Update the current camera state depending on the inputs that have been used this frame.
  66113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66114. */
  66115. checkInputs(): void;
  66116. /**
  66117. * Gets the class name of the current intput.
  66118. * @returns the class name
  66119. */
  66120. getClassName(): string;
  66121. /** @hidden */
  66122. _onLostFocus(): void;
  66123. /**
  66124. * Get the friendly name associated with the input class.
  66125. * @returns the input friendly name
  66126. */
  66127. getSimpleName(): string;
  66128. }
  66129. }
  66130. declare module BABYLON {
  66131. /**
  66132. * Interface describing all the common properties and methods a shadow light needs to implement.
  66133. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66134. * as well as binding the different shadow properties to the effects.
  66135. */
  66136. export interface IShadowLight extends Light {
  66137. /**
  66138. * The light id in the scene (used in scene.findLighById for instance)
  66139. */
  66140. id: string;
  66141. /**
  66142. * The position the shdow will be casted from.
  66143. */
  66144. position: Vector3;
  66145. /**
  66146. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66147. */
  66148. direction: Vector3;
  66149. /**
  66150. * The transformed position. Position of the light in world space taking parenting in account.
  66151. */
  66152. transformedPosition: Vector3;
  66153. /**
  66154. * The transformed direction. Direction of the light in world space taking parenting in account.
  66155. */
  66156. transformedDirection: Vector3;
  66157. /**
  66158. * The friendly name of the light in the scene.
  66159. */
  66160. name: string;
  66161. /**
  66162. * Defines the shadow projection clipping minimum z value.
  66163. */
  66164. shadowMinZ: number;
  66165. /**
  66166. * Defines the shadow projection clipping maximum z value.
  66167. */
  66168. shadowMaxZ: number;
  66169. /**
  66170. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66171. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66172. */
  66173. computeTransformedInformation(): boolean;
  66174. /**
  66175. * Gets the scene the light belongs to.
  66176. * @returns The scene
  66177. */
  66178. getScene(): Scene;
  66179. /**
  66180. * Callback defining a custom Projection Matrix Builder.
  66181. * This can be used to override the default projection matrix computation.
  66182. */
  66183. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66184. /**
  66185. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66186. * @param matrix The materix to updated with the projection information
  66187. * @param viewMatrix The transform matrix of the light
  66188. * @param renderList The list of mesh to render in the map
  66189. * @returns The current light
  66190. */
  66191. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66192. /**
  66193. * Gets the current depth scale used in ESM.
  66194. * @returns The scale
  66195. */
  66196. getDepthScale(): number;
  66197. /**
  66198. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66199. * @returns true if a cube texture needs to be use
  66200. */
  66201. needCube(): boolean;
  66202. /**
  66203. * Detects if the projection matrix requires to be recomputed this frame.
  66204. * @returns true if it requires to be recomputed otherwise, false.
  66205. */
  66206. needProjectionMatrixCompute(): boolean;
  66207. /**
  66208. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66209. */
  66210. forceProjectionMatrixCompute(): void;
  66211. /**
  66212. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66213. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66214. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66215. */
  66216. getShadowDirection(faceIndex?: number): Vector3;
  66217. /**
  66218. * Gets the minZ used for shadow according to both the scene and the light.
  66219. * @param activeCamera The camera we are returning the min for
  66220. * @returns the depth min z
  66221. */
  66222. getDepthMinZ(activeCamera: Camera): number;
  66223. /**
  66224. * Gets the maxZ used for shadow according to both the scene and the light.
  66225. * @param activeCamera The camera we are returning the max for
  66226. * @returns the depth max z
  66227. */
  66228. getDepthMaxZ(activeCamera: Camera): number;
  66229. }
  66230. /**
  66231. * Base implementation IShadowLight
  66232. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66233. */
  66234. export abstract class ShadowLight extends Light implements IShadowLight {
  66235. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66236. protected _position: Vector3;
  66237. protected _setPosition(value: Vector3): void;
  66238. /**
  66239. * Sets the position the shadow will be casted from. Also use as the light position for both
  66240. * point and spot lights.
  66241. */
  66242. /**
  66243. * Sets the position the shadow will be casted from. Also use as the light position for both
  66244. * point and spot lights.
  66245. */
  66246. position: Vector3;
  66247. protected _direction: Vector3;
  66248. protected _setDirection(value: Vector3): void;
  66249. /**
  66250. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66251. * Also use as the light direction on spot and directional lights.
  66252. */
  66253. /**
  66254. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66255. * Also use as the light direction on spot and directional lights.
  66256. */
  66257. direction: Vector3;
  66258. private _shadowMinZ;
  66259. /**
  66260. * Gets the shadow projection clipping minimum z value.
  66261. */
  66262. /**
  66263. * Sets the shadow projection clipping minimum z value.
  66264. */
  66265. shadowMinZ: number;
  66266. private _shadowMaxZ;
  66267. /**
  66268. * Sets the shadow projection clipping maximum z value.
  66269. */
  66270. /**
  66271. * Gets the shadow projection clipping maximum z value.
  66272. */
  66273. shadowMaxZ: number;
  66274. /**
  66275. * Callback defining a custom Projection Matrix Builder.
  66276. * This can be used to override the default projection matrix computation.
  66277. */
  66278. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66279. /**
  66280. * The transformed position. Position of the light in world space taking parenting in account.
  66281. */
  66282. transformedPosition: Vector3;
  66283. /**
  66284. * The transformed direction. Direction of the light in world space taking parenting in account.
  66285. */
  66286. transformedDirection: Vector3;
  66287. private _needProjectionMatrixCompute;
  66288. /**
  66289. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66290. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66291. */
  66292. computeTransformedInformation(): boolean;
  66293. /**
  66294. * Return the depth scale used for the shadow map.
  66295. * @returns the depth scale.
  66296. */
  66297. getDepthScale(): number;
  66298. /**
  66299. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66300. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66301. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66302. */
  66303. getShadowDirection(faceIndex?: number): Vector3;
  66304. /**
  66305. * Returns the ShadowLight absolute position in the World.
  66306. * @returns the position vector in world space
  66307. */
  66308. getAbsolutePosition(): Vector3;
  66309. /**
  66310. * Sets the ShadowLight direction toward the passed target.
  66311. * @param target The point to target in local space
  66312. * @returns the updated ShadowLight direction
  66313. */
  66314. setDirectionToTarget(target: Vector3): Vector3;
  66315. /**
  66316. * Returns the light rotation in euler definition.
  66317. * @returns the x y z rotation in local space.
  66318. */
  66319. getRotation(): Vector3;
  66320. /**
  66321. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66322. * @returns true if a cube texture needs to be use
  66323. */
  66324. needCube(): boolean;
  66325. /**
  66326. * Detects if the projection matrix requires to be recomputed this frame.
  66327. * @returns true if it requires to be recomputed otherwise, false.
  66328. */
  66329. needProjectionMatrixCompute(): boolean;
  66330. /**
  66331. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66332. */
  66333. forceProjectionMatrixCompute(): void;
  66334. /** @hidden */
  66335. _initCache(): void;
  66336. /** @hidden */
  66337. _isSynchronized(): boolean;
  66338. /**
  66339. * Computes the world matrix of the node
  66340. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66341. * @returns the world matrix
  66342. */
  66343. computeWorldMatrix(force?: boolean): Matrix;
  66344. /**
  66345. * Gets the minZ used for shadow according to both the scene and the light.
  66346. * @param activeCamera The camera we are returning the min for
  66347. * @returns the depth min z
  66348. */
  66349. getDepthMinZ(activeCamera: Camera): number;
  66350. /**
  66351. * Gets the maxZ used for shadow according to both the scene and the light.
  66352. * @param activeCamera The camera we are returning the max for
  66353. * @returns the depth max z
  66354. */
  66355. getDepthMaxZ(activeCamera: Camera): number;
  66356. /**
  66357. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66358. * @param matrix The materix to updated with the projection information
  66359. * @param viewMatrix The transform matrix of the light
  66360. * @param renderList The list of mesh to render in the map
  66361. * @returns The current light
  66362. */
  66363. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66364. }
  66365. }
  66366. declare module BABYLON {
  66367. /**
  66368. * "Static Class" containing the most commonly used helper while dealing with material for
  66369. * rendering purpose.
  66370. *
  66371. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66372. *
  66373. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66374. */
  66375. export class MaterialHelper {
  66376. /**
  66377. * Bind the current view position to an effect.
  66378. * @param effect The effect to be bound
  66379. * @param scene The scene the eyes position is used from
  66380. */
  66381. static BindEyePosition(effect: Effect, scene: Scene): void;
  66382. /**
  66383. * Helps preparing the defines values about the UVs in used in the effect.
  66384. * UVs are shared as much as we can accross channels in the shaders.
  66385. * @param texture The texture we are preparing the UVs for
  66386. * @param defines The defines to update
  66387. * @param key The channel key "diffuse", "specular"... used in the shader
  66388. */
  66389. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66390. /**
  66391. * Binds a texture matrix value to its corrsponding uniform
  66392. * @param texture The texture to bind the matrix for
  66393. * @param uniformBuffer The uniform buffer receivin the data
  66394. * @param key The channel key "diffuse", "specular"... used in the shader
  66395. */
  66396. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66397. /**
  66398. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66399. * @param mesh defines the current mesh
  66400. * @param scene defines the current scene
  66401. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66402. * @param pointsCloud defines if point cloud rendering has to be turned on
  66403. * @param fogEnabled defines if fog has to be turned on
  66404. * @param alphaTest defines if alpha testing has to be turned on
  66405. * @param defines defines the current list of defines
  66406. */
  66407. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66408. /**
  66409. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66410. * @param scene defines the current scene
  66411. * @param engine defines the current engine
  66412. * @param defines specifies the list of active defines
  66413. * @param useInstances defines if instances have to be turned on
  66414. * @param useClipPlane defines if clip plane have to be turned on
  66415. */
  66416. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66417. /**
  66418. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66419. * @param mesh The mesh containing the geometry data we will draw
  66420. * @param defines The defines to update
  66421. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66422. * @param useBones Precise whether bones should be used or not (override mesh info)
  66423. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66424. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66425. * @returns false if defines are considered not dirty and have not been checked
  66426. */
  66427. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66428. /**
  66429. * Prepares the defines related to the light information passed in parameter
  66430. * @param scene The scene we are intending to draw
  66431. * @param mesh The mesh the effect is compiling for
  66432. * @param defines The defines to update
  66433. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66434. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66435. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66436. * @returns true if normals will be required for the rest of the effect
  66437. */
  66438. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66439. /**
  66440. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66441. * that won t be acctive due to defines being turned off.
  66442. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66443. * @param samplersList The samplers list
  66444. * @param defines The defines helping in the list generation
  66445. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66446. */
  66447. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66448. /**
  66449. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66450. * @param defines The defines to update while falling back
  66451. * @param fallbacks The authorized effect fallbacks
  66452. * @param maxSimultaneousLights The maximum number of lights allowed
  66453. * @param rank the current rank of the Effect
  66454. * @returns The newly affected rank
  66455. */
  66456. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66457. /**
  66458. * Prepares the list of attributes required for morph targets according to the effect defines.
  66459. * @param attribs The current list of supported attribs
  66460. * @param mesh The mesh to prepare the morph targets attributes for
  66461. * @param defines The current Defines of the effect
  66462. */
  66463. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66464. /**
  66465. * Prepares the list of attributes required for bones according to the effect defines.
  66466. * @param attribs The current list of supported attribs
  66467. * @param mesh The mesh to prepare the bones attributes for
  66468. * @param defines The current Defines of the effect
  66469. * @param fallbacks The current efffect fallback strategy
  66470. */
  66471. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66472. /**
  66473. * Prepares the list of attributes required for instances according to the effect defines.
  66474. * @param attribs The current list of supported attribs
  66475. * @param defines The current Defines of the effect
  66476. */
  66477. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66478. /**
  66479. * Binds the light shadow information to the effect for the given mesh.
  66480. * @param light The light containing the generator
  66481. * @param scene The scene the lights belongs to
  66482. * @param mesh The mesh we are binding the information to render
  66483. * @param lightIndex The light index in the effect used to render the mesh
  66484. * @param effect The effect we are binding the data to
  66485. */
  66486. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66487. /**
  66488. * Binds the light information to the effect.
  66489. * @param light The light containing the generator
  66490. * @param effect The effect we are binding the data to
  66491. * @param lightIndex The light index in the effect used to render
  66492. */
  66493. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66494. /**
  66495. * Binds the lights information from the scene to the effect for the given mesh.
  66496. * @param scene The scene the lights belongs to
  66497. * @param mesh The mesh we are binding the information to render
  66498. * @param effect The effect we are binding the data to
  66499. * @param defines The generated defines for the effect
  66500. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66501. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66502. */
  66503. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66504. private static _tempFogColor;
  66505. /**
  66506. * Binds the fog information from the scene to the effect for the given mesh.
  66507. * @param scene The scene the lights belongs to
  66508. * @param mesh The mesh we are binding the information to render
  66509. * @param effect The effect we are binding the data to
  66510. * @param linearSpace Defines if the fog effect is applied in linear space
  66511. */
  66512. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66513. /**
  66514. * Binds the bones information from the mesh to the effect.
  66515. * @param mesh The mesh we are binding the information to render
  66516. * @param effect The effect we are binding the data to
  66517. */
  66518. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66519. /**
  66520. * Binds the morph targets information from the mesh to the effect.
  66521. * @param abstractMesh The mesh we are binding the information to render
  66522. * @param effect The effect we are binding the data to
  66523. */
  66524. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66525. /**
  66526. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66527. * @param defines The generated defines used in the effect
  66528. * @param effect The effect we are binding the data to
  66529. * @param scene The scene we are willing to render with logarithmic scale for
  66530. */
  66531. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66532. /**
  66533. * Binds the clip plane information from the scene to the effect.
  66534. * @param scene The scene the clip plane information are extracted from
  66535. * @param effect The effect we are binding the data to
  66536. */
  66537. static BindClipPlane(effect: Effect, scene: Scene): void;
  66538. }
  66539. }
  66540. declare module BABYLON {
  66541. /** @hidden */
  66542. export var kernelBlurVaryingDeclaration: {
  66543. name: string;
  66544. shader: string;
  66545. };
  66546. }
  66547. declare module BABYLON {
  66548. /** @hidden */
  66549. export var kernelBlurFragment: {
  66550. name: string;
  66551. shader: string;
  66552. };
  66553. }
  66554. declare module BABYLON {
  66555. /** @hidden */
  66556. export var kernelBlurFragment2: {
  66557. name: string;
  66558. shader: string;
  66559. };
  66560. }
  66561. declare module BABYLON {
  66562. /** @hidden */
  66563. export var kernelBlurPixelShader: {
  66564. name: string;
  66565. shader: string;
  66566. };
  66567. }
  66568. declare module BABYLON {
  66569. /** @hidden */
  66570. export var kernelBlurVertex: {
  66571. name: string;
  66572. shader: string;
  66573. };
  66574. }
  66575. declare module BABYLON {
  66576. /** @hidden */
  66577. export var kernelBlurVertexShader: {
  66578. name: string;
  66579. shader: string;
  66580. };
  66581. }
  66582. declare module BABYLON {
  66583. /**
  66584. * The Blur Post Process which blurs an image based on a kernel and direction.
  66585. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  66586. */
  66587. export class BlurPostProcess extends PostProcess {
  66588. /** The direction in which to blur the image. */
  66589. direction: Vector2;
  66590. private blockCompilation;
  66591. protected _kernel: number;
  66592. protected _idealKernel: number;
  66593. protected _packedFloat: boolean;
  66594. private _staticDefines;
  66595. /**
  66596. * Sets the length in pixels of the blur sample region
  66597. */
  66598. /**
  66599. * Gets the length in pixels of the blur sample region
  66600. */
  66601. kernel: number;
  66602. /**
  66603. * Sets wether or not the blur needs to unpack/repack floats
  66604. */
  66605. /**
  66606. * Gets wether or not the blur is unpacking/repacking floats
  66607. */
  66608. packedFloat: boolean;
  66609. /**
  66610. * Creates a new instance BlurPostProcess
  66611. * @param name The name of the effect.
  66612. * @param direction The direction in which to blur the image.
  66613. * @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.
  66614. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  66615. * @param camera The camera to apply the render pass to.
  66616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66617. * @param engine The engine which the post process will be applied. (default: current engine)
  66618. * @param reusable If the post process can be reused on the same frame. (default: false)
  66619. * @param textureType Type of textures used when performing the post process. (default: 0)
  66620. * @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)
  66621. */
  66622. constructor(name: string,
  66623. /** The direction in which to blur the image. */
  66624. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  66625. /**
  66626. * Updates the effect with the current post process compile time values and recompiles the shader.
  66627. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66628. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66629. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66630. * @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
  66631. * @param onCompiled Called when the shader has been compiled.
  66632. * @param onError Called if there is an error when compiling a shader.
  66633. */
  66634. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66635. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66636. /**
  66637. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  66638. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  66639. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  66640. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  66641. * The gaps between physical kernels are compensated for in the weighting of the samples
  66642. * @param idealKernel Ideal blur kernel.
  66643. * @return Nearest best kernel.
  66644. */
  66645. protected _nearestBestKernel(idealKernel: number): number;
  66646. /**
  66647. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  66648. * @param x The point on the Gaussian distribution to sample.
  66649. * @return the value of the Gaussian function at x.
  66650. */
  66651. protected _gaussianWeight(x: number): number;
  66652. /**
  66653. * Generates a string that can be used as a floating point number in GLSL.
  66654. * @param x Value to print.
  66655. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  66656. * @return GLSL float string.
  66657. */
  66658. protected _glslFloat(x: number, decimalFigures?: number): string;
  66659. }
  66660. }
  66661. declare module BABYLON {
  66662. /** @hidden */
  66663. export var shadowMapPixelShader: {
  66664. name: string;
  66665. shader: string;
  66666. };
  66667. }
  66668. declare module BABYLON {
  66669. /** @hidden */
  66670. export var bonesDeclaration: {
  66671. name: string;
  66672. shader: string;
  66673. };
  66674. }
  66675. declare module BABYLON {
  66676. /** @hidden */
  66677. export var morphTargetsVertexGlobalDeclaration: {
  66678. name: string;
  66679. shader: string;
  66680. };
  66681. }
  66682. declare module BABYLON {
  66683. /** @hidden */
  66684. export var morphTargetsVertexDeclaration: {
  66685. name: string;
  66686. shader: string;
  66687. };
  66688. }
  66689. declare module BABYLON {
  66690. /** @hidden */
  66691. export var instancesDeclaration: {
  66692. name: string;
  66693. shader: string;
  66694. };
  66695. }
  66696. declare module BABYLON {
  66697. /** @hidden */
  66698. export var helperFunctions: {
  66699. name: string;
  66700. shader: string;
  66701. };
  66702. }
  66703. declare module BABYLON {
  66704. /** @hidden */
  66705. export var morphTargetsVertex: {
  66706. name: string;
  66707. shader: string;
  66708. };
  66709. }
  66710. declare module BABYLON {
  66711. /** @hidden */
  66712. export var instancesVertex: {
  66713. name: string;
  66714. shader: string;
  66715. };
  66716. }
  66717. declare module BABYLON {
  66718. /** @hidden */
  66719. export var bonesVertex: {
  66720. name: string;
  66721. shader: string;
  66722. };
  66723. }
  66724. declare module BABYLON {
  66725. /** @hidden */
  66726. export var shadowMapVertexShader: {
  66727. name: string;
  66728. shader: string;
  66729. };
  66730. }
  66731. declare module BABYLON {
  66732. /** @hidden */
  66733. export var depthBoxBlurPixelShader: {
  66734. name: string;
  66735. shader: string;
  66736. };
  66737. }
  66738. declare module BABYLON {
  66739. /**
  66740. * Defines the options associated with the creation of a custom shader for a shadow generator.
  66741. */
  66742. export interface ICustomShaderOptions {
  66743. /**
  66744. * Gets or sets the custom shader name to use
  66745. */
  66746. shaderName: string;
  66747. /**
  66748. * The list of attribute names used in the shader
  66749. */
  66750. attributes?: string[];
  66751. /**
  66752. * The list of unifrom names used in the shader
  66753. */
  66754. uniforms?: string[];
  66755. /**
  66756. * The list of sampler names used in the shader
  66757. */
  66758. samplers?: string[];
  66759. /**
  66760. * The list of defines used in the shader
  66761. */
  66762. defines?: string[];
  66763. }
  66764. /**
  66765. * Interface to implement to create a shadow generator compatible with BJS.
  66766. */
  66767. export interface IShadowGenerator {
  66768. /**
  66769. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66770. * @returns The render target texture if present otherwise, null
  66771. */
  66772. getShadowMap(): Nullable<RenderTargetTexture>;
  66773. /**
  66774. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66775. * @returns The render target texture if the shadow map is present otherwise, null
  66776. */
  66777. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66778. /**
  66779. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66780. * @param subMesh The submesh we want to render in the shadow map
  66781. * @param useInstances Defines wether will draw in the map using instances
  66782. * @returns true if ready otherwise, false
  66783. */
  66784. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66785. /**
  66786. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66787. * @param defines Defines of the material we want to update
  66788. * @param lightIndex Index of the light in the enabled light list of the material
  66789. */
  66790. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  66791. /**
  66792. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66793. * defined in the generator but impacting the effect).
  66794. * It implies the unifroms available on the materials are the standard BJS ones.
  66795. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66796. * @param effect The effect we are binfing the information for
  66797. */
  66798. bindShadowLight(lightIndex: string, effect: Effect): void;
  66799. /**
  66800. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66801. * (eq to shadow prjection matrix * light transform matrix)
  66802. * @returns The transform matrix used to create the shadow map
  66803. */
  66804. getTransformMatrix(): Matrix;
  66805. /**
  66806. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66807. * Cube and 2D textures for instance.
  66808. */
  66809. recreateShadowMap(): void;
  66810. /**
  66811. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66812. * @param onCompiled Callback triggered at the and of the effects compilation
  66813. * @param options Sets of optional options forcing the compilation with different modes
  66814. */
  66815. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66816. useInstances: boolean;
  66817. }>): void;
  66818. /**
  66819. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66820. * @param options Sets of optional options forcing the compilation with different modes
  66821. * @returns A promise that resolves when the compilation completes
  66822. */
  66823. forceCompilationAsync(options?: Partial<{
  66824. useInstances: boolean;
  66825. }>): Promise<void>;
  66826. /**
  66827. * Serializes the shadow generator setup to a json object.
  66828. * @returns The serialized JSON object
  66829. */
  66830. serialize(): any;
  66831. /**
  66832. * Disposes the Shadow map and related Textures and effects.
  66833. */
  66834. dispose(): void;
  66835. }
  66836. /**
  66837. * Default implementation IShadowGenerator.
  66838. * This is the main object responsible of generating shadows in the framework.
  66839. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  66840. */
  66841. export class ShadowGenerator implements IShadowGenerator {
  66842. /**
  66843. * Shadow generator mode None: no filtering applied.
  66844. */
  66845. static readonly FILTER_NONE: number;
  66846. /**
  66847. * Shadow generator mode ESM: Exponential Shadow Mapping.
  66848. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66849. */
  66850. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  66851. /**
  66852. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  66853. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  66854. */
  66855. static readonly FILTER_POISSONSAMPLING: number;
  66856. /**
  66857. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  66858. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66859. */
  66860. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  66861. /**
  66862. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  66863. * edge artifacts on steep falloff.
  66864. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66865. */
  66866. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  66867. /**
  66868. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  66869. * edge artifacts on steep falloff.
  66870. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66871. */
  66872. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  66873. /**
  66874. * Shadow generator mode PCF: Percentage Closer Filtering
  66875. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66876. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  66877. */
  66878. static readonly FILTER_PCF: number;
  66879. /**
  66880. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  66881. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66882. * Contact Hardening
  66883. */
  66884. static readonly FILTER_PCSS: number;
  66885. /**
  66886. * Reserved for PCF and PCSS
  66887. * Highest Quality.
  66888. *
  66889. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  66890. *
  66891. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  66892. */
  66893. static readonly QUALITY_HIGH: number;
  66894. /**
  66895. * Reserved for PCF and PCSS
  66896. * Good tradeoff for quality/perf cross devices
  66897. *
  66898. * Execute PCF on a 3*3 kernel.
  66899. *
  66900. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  66901. */
  66902. static readonly QUALITY_MEDIUM: number;
  66903. /**
  66904. * Reserved for PCF and PCSS
  66905. * The lowest quality but the fastest.
  66906. *
  66907. * Execute PCF on a 1*1 kernel.
  66908. *
  66909. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  66910. */
  66911. static readonly QUALITY_LOW: number;
  66912. /** Gets or sets the custom shader name to use */
  66913. customShaderOptions: ICustomShaderOptions;
  66914. /**
  66915. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  66916. */
  66917. onBeforeShadowMapRenderObservable: Observable<Effect>;
  66918. private _bias;
  66919. /**
  66920. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  66921. */
  66922. /**
  66923. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  66924. */
  66925. bias: number;
  66926. private _normalBias;
  66927. /**
  66928. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66929. */
  66930. /**
  66931. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66932. */
  66933. normalBias: number;
  66934. private _blurBoxOffset;
  66935. /**
  66936. * Gets the blur box offset: offset applied during the blur pass.
  66937. * Only useful if useKernelBlur = false
  66938. */
  66939. /**
  66940. * Sets the blur box offset: offset applied during the blur pass.
  66941. * Only useful if useKernelBlur = false
  66942. */
  66943. blurBoxOffset: number;
  66944. private _blurScale;
  66945. /**
  66946. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  66947. * 2 means half of the size.
  66948. */
  66949. /**
  66950. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  66951. * 2 means half of the size.
  66952. */
  66953. blurScale: number;
  66954. private _blurKernel;
  66955. /**
  66956. * Gets the blur kernel: kernel size of the blur pass.
  66957. * Only useful if useKernelBlur = true
  66958. */
  66959. /**
  66960. * Sets the blur kernel: kernel size of the blur pass.
  66961. * Only useful if useKernelBlur = true
  66962. */
  66963. blurKernel: number;
  66964. private _useKernelBlur;
  66965. /**
  66966. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  66967. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66968. */
  66969. /**
  66970. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  66971. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66972. */
  66973. useKernelBlur: boolean;
  66974. private _depthScale;
  66975. /**
  66976. * Gets the depth scale used in ESM mode.
  66977. */
  66978. /**
  66979. * Sets the depth scale used in ESM mode.
  66980. * This can override the scale stored on the light.
  66981. */
  66982. depthScale: number;
  66983. private _filter;
  66984. /**
  66985. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  66986. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66987. */
  66988. /**
  66989. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  66990. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66991. */
  66992. filter: number;
  66993. /**
  66994. * Gets if the current filter is set to Poisson Sampling.
  66995. */
  66996. /**
  66997. * Sets the current filter to Poisson Sampling.
  66998. */
  66999. usePoissonSampling: boolean;
  67000. /**
  67001. * Gets if the current filter is set to ESM.
  67002. */
  67003. /**
  67004. * Sets the current filter is to ESM.
  67005. */
  67006. useExponentialShadowMap: boolean;
  67007. /**
  67008. * Gets if the current filter is set to filtered ESM.
  67009. */
  67010. /**
  67011. * Gets if the current filter is set to filtered ESM.
  67012. */
  67013. useBlurExponentialShadowMap: boolean;
  67014. /**
  67015. * Gets if the current filter is set to "close ESM" (using the inverse of the
  67016. * exponential to prevent steep falloff artifacts).
  67017. */
  67018. /**
  67019. * Sets the current filter to "close ESM" (using the inverse of the
  67020. * exponential to prevent steep falloff artifacts).
  67021. */
  67022. useCloseExponentialShadowMap: boolean;
  67023. /**
  67024. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  67025. * exponential to prevent steep falloff artifacts).
  67026. */
  67027. /**
  67028. * Sets the current filter to filtered "close ESM" (using the inverse of the
  67029. * exponential to prevent steep falloff artifacts).
  67030. */
  67031. useBlurCloseExponentialShadowMap: boolean;
  67032. /**
  67033. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  67034. */
  67035. /**
  67036. * Sets the current filter to "PCF" (percentage closer filtering).
  67037. */
  67038. usePercentageCloserFiltering: boolean;
  67039. private _filteringQuality;
  67040. /**
  67041. * Gets the PCF or PCSS Quality.
  67042. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67043. */
  67044. /**
  67045. * Sets the PCF or PCSS Quality.
  67046. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67047. */
  67048. filteringQuality: number;
  67049. /**
  67050. * Gets if the current filter is set to "PCSS" (contact hardening).
  67051. */
  67052. /**
  67053. * Sets the current filter to "PCSS" (contact hardening).
  67054. */
  67055. useContactHardeningShadow: boolean;
  67056. private _contactHardeningLightSizeUVRatio;
  67057. /**
  67058. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67059. * Using a ratio helps keeping shape stability independently of the map size.
  67060. *
  67061. * It does not account for the light projection as it was having too much
  67062. * instability during the light setup or during light position changes.
  67063. *
  67064. * Only valid if useContactHardeningShadow is true.
  67065. */
  67066. /**
  67067. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67068. * Using a ratio helps keeping shape stability independently of the map size.
  67069. *
  67070. * It does not account for the light projection as it was having too much
  67071. * instability during the light setup or during light position changes.
  67072. *
  67073. * Only valid if useContactHardeningShadow is true.
  67074. */
  67075. contactHardeningLightSizeUVRatio: number;
  67076. private _darkness;
  67077. /**
  67078. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67079. * 0 means strongest and 1 would means no shadow.
  67080. * @returns the darkness.
  67081. */
  67082. getDarkness(): number;
  67083. /**
  67084. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67085. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67086. * @returns the shadow generator allowing fluent coding.
  67087. */
  67088. setDarkness(darkness: number): ShadowGenerator;
  67089. private _transparencyShadow;
  67090. /**
  67091. * Sets the ability to have transparent shadow (boolean).
  67092. * @param transparent True if transparent else False
  67093. * @returns the shadow generator allowing fluent coding
  67094. */
  67095. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67096. private _shadowMap;
  67097. private _shadowMap2;
  67098. /**
  67099. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67100. * @returns The render target texture if present otherwise, null
  67101. */
  67102. getShadowMap(): Nullable<RenderTargetTexture>;
  67103. /**
  67104. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67105. * @returns The render target texture if the shadow map is present otherwise, null
  67106. */
  67107. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67108. /**
  67109. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67110. * @param mesh Mesh to add
  67111. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67112. * @returns the Shadow Generator itself
  67113. */
  67114. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67115. /**
  67116. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67117. * @param mesh Mesh to remove
  67118. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67119. * @returns the Shadow Generator itself
  67120. */
  67121. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67122. /**
  67123. * Controls the extent to which the shadows fade out at the edge of the frustum
  67124. * Used only by directionals and spots
  67125. */
  67126. frustumEdgeFalloff: number;
  67127. private _light;
  67128. /**
  67129. * Returns the associated light object.
  67130. * @returns the light generating the shadow
  67131. */
  67132. getLight(): IShadowLight;
  67133. /**
  67134. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67135. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67136. * It might on the other hand introduce peter panning.
  67137. */
  67138. forceBackFacesOnly: boolean;
  67139. private _scene;
  67140. private _lightDirection;
  67141. private _effect;
  67142. private _viewMatrix;
  67143. private _projectionMatrix;
  67144. private _transformMatrix;
  67145. private _cachedPosition;
  67146. private _cachedDirection;
  67147. private _cachedDefines;
  67148. private _currentRenderID;
  67149. private _boxBlurPostprocess;
  67150. private _kernelBlurXPostprocess;
  67151. private _kernelBlurYPostprocess;
  67152. private _blurPostProcesses;
  67153. private _mapSize;
  67154. private _currentFaceIndex;
  67155. private _currentFaceIndexCache;
  67156. private _textureType;
  67157. private _defaultTextureMatrix;
  67158. /** @hidden */
  67159. static _SceneComponentInitialization: (scene: Scene) => void;
  67160. /**
  67161. * Creates a ShadowGenerator object.
  67162. * A ShadowGenerator is the required tool to use the shadows.
  67163. * Each light casting shadows needs to use its own ShadowGenerator.
  67164. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67165. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67166. * @param light The light object generating the shadows.
  67167. * @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.
  67168. */
  67169. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67170. private _initializeGenerator;
  67171. private _initializeShadowMap;
  67172. private _initializeBlurRTTAndPostProcesses;
  67173. private _renderForShadowMap;
  67174. private _renderSubMeshForShadowMap;
  67175. private _applyFilterValues;
  67176. /**
  67177. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67178. * @param onCompiled Callback triggered at the and of the effects compilation
  67179. * @param options Sets of optional options forcing the compilation with different modes
  67180. */
  67181. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67182. useInstances: boolean;
  67183. }>): void;
  67184. /**
  67185. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67186. * @param options Sets of optional options forcing the compilation with different modes
  67187. * @returns A promise that resolves when the compilation completes
  67188. */
  67189. forceCompilationAsync(options?: Partial<{
  67190. useInstances: boolean;
  67191. }>): Promise<void>;
  67192. /**
  67193. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67194. * @param subMesh The submesh we want to render in the shadow map
  67195. * @param useInstances Defines wether will draw in the map using instances
  67196. * @returns true if ready otherwise, false
  67197. */
  67198. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67199. /**
  67200. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67201. * @param defines Defines of the material we want to update
  67202. * @param lightIndex Index of the light in the enabled light list of the material
  67203. */
  67204. prepareDefines(defines: any, lightIndex: number): void;
  67205. /**
  67206. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67207. * defined in the generator but impacting the effect).
  67208. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67209. * @param effect The effect we are binfing the information for
  67210. */
  67211. bindShadowLight(lightIndex: string, effect: Effect): void;
  67212. /**
  67213. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67214. * (eq to shadow prjection matrix * light transform matrix)
  67215. * @returns The transform matrix used to create the shadow map
  67216. */
  67217. getTransformMatrix(): Matrix;
  67218. /**
  67219. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67220. * Cube and 2D textures for instance.
  67221. */
  67222. recreateShadowMap(): void;
  67223. private _disposeBlurPostProcesses;
  67224. private _disposeRTTandPostProcesses;
  67225. /**
  67226. * Disposes the ShadowGenerator.
  67227. * Returns nothing.
  67228. */
  67229. dispose(): void;
  67230. /**
  67231. * Serializes the shadow generator setup to a json object.
  67232. * @returns The serialized JSON object
  67233. */
  67234. serialize(): any;
  67235. /**
  67236. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67237. * @param parsedShadowGenerator The JSON object to parse
  67238. * @param scene The scene to create the shadow map for
  67239. * @returns The parsed shadow generator
  67240. */
  67241. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67242. }
  67243. }
  67244. declare module BABYLON {
  67245. /**
  67246. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67247. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67248. * 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.
  67249. */
  67250. export abstract class Light extends Node {
  67251. /**
  67252. * Falloff Default: light is falling off following the material specification:
  67253. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67254. */
  67255. static readonly FALLOFF_DEFAULT: number;
  67256. /**
  67257. * Falloff Physical: light is falling off following the inverse squared distance law.
  67258. */
  67259. static readonly FALLOFF_PHYSICAL: number;
  67260. /**
  67261. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67262. * to enhance interoperability with other engines.
  67263. */
  67264. static readonly FALLOFF_GLTF: number;
  67265. /**
  67266. * Falloff Standard: light is falling off like in the standard material
  67267. * to enhance interoperability with other materials.
  67268. */
  67269. static readonly FALLOFF_STANDARD: number;
  67270. /**
  67271. * If every light affecting the material is in this lightmapMode,
  67272. * material.lightmapTexture adds or multiplies
  67273. * (depends on material.useLightmapAsShadowmap)
  67274. * after every other light calculations.
  67275. */
  67276. static readonly LIGHTMAP_DEFAULT: number;
  67277. /**
  67278. * material.lightmapTexture as only diffuse lighting from this light
  67279. * adds only specular lighting from this light
  67280. * adds dynamic shadows
  67281. */
  67282. static readonly LIGHTMAP_SPECULAR: number;
  67283. /**
  67284. * material.lightmapTexture as only lighting
  67285. * no light calculation from this light
  67286. * only adds dynamic shadows from this light
  67287. */
  67288. static readonly LIGHTMAP_SHADOWSONLY: number;
  67289. /**
  67290. * Each light type uses the default quantity according to its type:
  67291. * point/spot lights use luminous intensity
  67292. * directional lights use illuminance
  67293. */
  67294. static readonly INTENSITYMODE_AUTOMATIC: number;
  67295. /**
  67296. * lumen (lm)
  67297. */
  67298. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67299. /**
  67300. * candela (lm/sr)
  67301. */
  67302. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67303. /**
  67304. * lux (lm/m^2)
  67305. */
  67306. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67307. /**
  67308. * nit (cd/m^2)
  67309. */
  67310. static readonly INTENSITYMODE_LUMINANCE: number;
  67311. /**
  67312. * Light type const id of the point light.
  67313. */
  67314. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67315. /**
  67316. * Light type const id of the directional light.
  67317. */
  67318. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67319. /**
  67320. * Light type const id of the spot light.
  67321. */
  67322. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67323. /**
  67324. * Light type const id of the hemispheric light.
  67325. */
  67326. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67327. /**
  67328. * Diffuse gives the basic color to an object.
  67329. */
  67330. diffuse: Color3;
  67331. /**
  67332. * Specular produces a highlight color on an object.
  67333. * Note: This is note affecting PBR materials.
  67334. */
  67335. specular: Color3;
  67336. /**
  67337. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67338. * falling off base on range or angle.
  67339. * This can be set to any values in Light.FALLOFF_x.
  67340. *
  67341. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67342. * other types of materials.
  67343. */
  67344. falloffType: number;
  67345. /**
  67346. * Strength of the light.
  67347. * Note: By default it is define in the framework own unit.
  67348. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67349. */
  67350. intensity: number;
  67351. private _range;
  67352. protected _inverseSquaredRange: number;
  67353. /**
  67354. * Defines how far from the source the light is impacting in scene units.
  67355. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67356. */
  67357. /**
  67358. * Defines how far from the source the light is impacting in scene units.
  67359. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67360. */
  67361. range: number;
  67362. /**
  67363. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67364. * of light.
  67365. */
  67366. private _photometricScale;
  67367. private _intensityMode;
  67368. /**
  67369. * Gets the photometric scale used to interpret the intensity.
  67370. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67371. */
  67372. /**
  67373. * Sets the photometric scale used to interpret the intensity.
  67374. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67375. */
  67376. intensityMode: number;
  67377. private _radius;
  67378. /**
  67379. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67380. */
  67381. /**
  67382. * sets the light radius used by PBR Materials to simulate soft area lights.
  67383. */
  67384. radius: number;
  67385. private _renderPriority;
  67386. /**
  67387. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67388. * exceeding the number allowed of the materials.
  67389. */
  67390. renderPriority: number;
  67391. private _shadowEnabled;
  67392. /**
  67393. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67394. * the current shadow generator.
  67395. */
  67396. /**
  67397. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67398. * the current shadow generator.
  67399. */
  67400. shadowEnabled: boolean;
  67401. private _includedOnlyMeshes;
  67402. /**
  67403. * Gets the only meshes impacted by this light.
  67404. */
  67405. /**
  67406. * Sets the only meshes impacted by this light.
  67407. */
  67408. includedOnlyMeshes: AbstractMesh[];
  67409. private _excludedMeshes;
  67410. /**
  67411. * Gets the meshes not impacted by this light.
  67412. */
  67413. /**
  67414. * Sets the meshes not impacted by this light.
  67415. */
  67416. excludedMeshes: AbstractMesh[];
  67417. private _excludeWithLayerMask;
  67418. /**
  67419. * Gets the layer id use to find what meshes are not impacted by the light.
  67420. * Inactive if 0
  67421. */
  67422. /**
  67423. * Sets the layer id use to find what meshes are not impacted by the light.
  67424. * Inactive if 0
  67425. */
  67426. excludeWithLayerMask: number;
  67427. private _includeOnlyWithLayerMask;
  67428. /**
  67429. * Gets the layer id use to find what meshes are impacted by the light.
  67430. * Inactive if 0
  67431. */
  67432. /**
  67433. * Sets the layer id use to find what meshes are impacted by the light.
  67434. * Inactive if 0
  67435. */
  67436. includeOnlyWithLayerMask: number;
  67437. private _lightmapMode;
  67438. /**
  67439. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67440. */
  67441. /**
  67442. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67443. */
  67444. lightmapMode: number;
  67445. /**
  67446. * Shadow generator associted to the light.
  67447. * @hidden Internal use only.
  67448. */
  67449. _shadowGenerator: Nullable<IShadowGenerator>;
  67450. /**
  67451. * @hidden Internal use only.
  67452. */
  67453. _excludedMeshesIds: string[];
  67454. /**
  67455. * @hidden Internal use only.
  67456. */
  67457. _includedOnlyMeshesIds: string[];
  67458. /**
  67459. * The current light unifom buffer.
  67460. * @hidden Internal use only.
  67461. */
  67462. _uniformBuffer: UniformBuffer;
  67463. /**
  67464. * Creates a Light object in the scene.
  67465. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67466. * @param name The firendly name of the light
  67467. * @param scene The scene the light belongs too
  67468. */
  67469. constructor(name: string, scene: Scene);
  67470. protected abstract _buildUniformLayout(): void;
  67471. /**
  67472. * Sets the passed Effect "effect" with the Light information.
  67473. * @param effect The effect to update
  67474. * @param lightIndex The index of the light in the effect to update
  67475. * @returns The light
  67476. */
  67477. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67478. /**
  67479. * Returns the string "Light".
  67480. * @returns the class name
  67481. */
  67482. getClassName(): string;
  67483. /** @hidden */
  67484. readonly _isLight: boolean;
  67485. /**
  67486. * Converts the light information to a readable string for debug purpose.
  67487. * @param fullDetails Supports for multiple levels of logging within scene loading
  67488. * @returns the human readable light info
  67489. */
  67490. toString(fullDetails?: boolean): string;
  67491. /** @hidden */
  67492. protected _syncParentEnabledState(): void;
  67493. /**
  67494. * Set the enabled state of this node.
  67495. * @param value - the new enabled state
  67496. */
  67497. setEnabled(value: boolean): void;
  67498. /**
  67499. * Returns the Light associated shadow generator if any.
  67500. * @return the associated shadow generator.
  67501. */
  67502. getShadowGenerator(): Nullable<IShadowGenerator>;
  67503. /**
  67504. * Returns a Vector3, the absolute light position in the World.
  67505. * @returns the world space position of the light
  67506. */
  67507. getAbsolutePosition(): Vector3;
  67508. /**
  67509. * Specifies if the light will affect the passed mesh.
  67510. * @param mesh The mesh to test against the light
  67511. * @return true the mesh is affected otherwise, false.
  67512. */
  67513. canAffectMesh(mesh: AbstractMesh): boolean;
  67514. /**
  67515. * Sort function to order lights for rendering.
  67516. * @param a First Light object to compare to second.
  67517. * @param b Second Light object to compare first.
  67518. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67519. */
  67520. static CompareLightsPriority(a: Light, b: Light): number;
  67521. /**
  67522. * Releases resources associated with this node.
  67523. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67524. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67525. */
  67526. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67527. /**
  67528. * Returns the light type ID (integer).
  67529. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67530. */
  67531. getTypeID(): number;
  67532. /**
  67533. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67534. * @returns the scaled intensity in intensity mode unit
  67535. */
  67536. getScaledIntensity(): number;
  67537. /**
  67538. * Returns a new Light object, named "name", from the current one.
  67539. * @param name The name of the cloned light
  67540. * @returns the new created light
  67541. */
  67542. clone(name: string): Nullable<Light>;
  67543. /**
  67544. * Serializes the current light into a Serialization object.
  67545. * @returns the serialized object.
  67546. */
  67547. serialize(): any;
  67548. /**
  67549. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67550. * This new light is named "name" and added to the passed scene.
  67551. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67552. * @param name The friendly name of the light
  67553. * @param scene The scene the new light will belong to
  67554. * @returns the constructor function
  67555. */
  67556. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67557. /**
  67558. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67559. * @param parsedLight The JSON representation of the light
  67560. * @param scene The scene to create the parsed light in
  67561. * @returns the created light after parsing
  67562. */
  67563. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67564. private _hookArrayForExcluded;
  67565. private _hookArrayForIncludedOnly;
  67566. private _resyncMeshes;
  67567. /**
  67568. * Forces the meshes to update their light related information in their rendering used effects
  67569. * @hidden Internal Use Only
  67570. */
  67571. _markMeshesAsLightDirty(): void;
  67572. /**
  67573. * Recomputes the cached photometric scale if needed.
  67574. */
  67575. private _computePhotometricScale;
  67576. /**
  67577. * Returns the Photometric Scale according to the light type and intensity mode.
  67578. */
  67579. private _getPhotometricScale;
  67580. /**
  67581. * Reorder the light in the scene according to their defined priority.
  67582. * @hidden Internal Use Only
  67583. */
  67584. _reorderLightsInScene(): void;
  67585. /**
  67586. * Prepares the list of defines specific to the light type.
  67587. * @param defines the list of defines
  67588. * @param lightIndex defines the index of the light for the effect
  67589. */
  67590. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67591. }
  67592. }
  67593. declare module BABYLON {
  67594. /**
  67595. * Interface used to define Action
  67596. */
  67597. export interface IAction {
  67598. /**
  67599. * Trigger for the action
  67600. */
  67601. trigger: number;
  67602. /** Options of the trigger */
  67603. triggerOptions: any;
  67604. /**
  67605. * Gets the trigger parameters
  67606. * @returns the trigger parameters
  67607. */
  67608. getTriggerParameter(): any;
  67609. /**
  67610. * Internal only - executes current action event
  67611. * @hidden
  67612. */
  67613. _executeCurrent(evt?: ActionEvent): void;
  67614. /**
  67615. * Serialize placeholder for child classes
  67616. * @param parent of child
  67617. * @returns the serialized object
  67618. */
  67619. serialize(parent: any): any;
  67620. }
  67621. /**
  67622. * The action to be carried out following a trigger
  67623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  67624. */
  67625. export class Action implements IAction {
  67626. /** the trigger, with or without parameters, for the action */
  67627. triggerOptions: any;
  67628. /**
  67629. * Trigger for the action
  67630. */
  67631. trigger: number;
  67632. /**
  67633. * Internal only - manager for action
  67634. * @hidden
  67635. */
  67636. _actionManager: ActionManager;
  67637. private _nextActiveAction;
  67638. private _child;
  67639. private _condition?;
  67640. private _triggerParameter;
  67641. /**
  67642. * An event triggered prior to action being executed.
  67643. */
  67644. onBeforeExecuteObservable: Observable<Action>;
  67645. /**
  67646. * Creates a new Action
  67647. * @param triggerOptions the trigger, with or without parameters, for the action
  67648. * @param condition an optional determinant of action
  67649. */
  67650. constructor(
  67651. /** the trigger, with or without parameters, for the action */
  67652. triggerOptions: any, condition?: Condition);
  67653. /**
  67654. * Internal only
  67655. * @hidden
  67656. */
  67657. _prepare(): void;
  67658. /**
  67659. * Gets the trigger parameters
  67660. * @returns the trigger parameters
  67661. */
  67662. getTriggerParameter(): any;
  67663. /**
  67664. * Internal only - executes current action event
  67665. * @hidden
  67666. */
  67667. _executeCurrent(evt?: ActionEvent): void;
  67668. /**
  67669. * Execute placeholder for child classes
  67670. * @param evt optional action event
  67671. */
  67672. execute(evt?: ActionEvent): void;
  67673. /**
  67674. * Skips to next active action
  67675. */
  67676. skipToNextActiveAction(): void;
  67677. /**
  67678. * Adds action to chain of actions, may be a DoNothingAction
  67679. * @param action defines the next action to execute
  67680. * @returns The action passed in
  67681. * @see https://www.babylonjs-playground.com/#1T30HR#0
  67682. */
  67683. then(action: Action): Action;
  67684. /**
  67685. * Internal only
  67686. * @hidden
  67687. */
  67688. _getProperty(propertyPath: string): string;
  67689. /**
  67690. * Internal only
  67691. * @hidden
  67692. */
  67693. _getEffectiveTarget(target: any, propertyPath: string): any;
  67694. /**
  67695. * Serialize placeholder for child classes
  67696. * @param parent of child
  67697. * @returns the serialized object
  67698. */
  67699. serialize(parent: any): any;
  67700. /**
  67701. * Internal only called by serialize
  67702. * @hidden
  67703. */
  67704. protected _serialize(serializedAction: any, parent?: any): any;
  67705. /**
  67706. * Internal only
  67707. * @hidden
  67708. */
  67709. static _SerializeValueAsString: (value: any) => string;
  67710. /**
  67711. * Internal only
  67712. * @hidden
  67713. */
  67714. static _GetTargetProperty: (target: Scene | Node) => {
  67715. name: string;
  67716. targetType: string;
  67717. value: string;
  67718. };
  67719. }
  67720. }
  67721. declare module BABYLON {
  67722. /**
  67723. * A Condition applied to an Action
  67724. */
  67725. export class Condition {
  67726. /**
  67727. * Internal only - manager for action
  67728. * @hidden
  67729. */
  67730. _actionManager: ActionManager;
  67731. /**
  67732. * Internal only
  67733. * @hidden
  67734. */
  67735. _evaluationId: number;
  67736. /**
  67737. * Internal only
  67738. * @hidden
  67739. */
  67740. _currentResult: boolean;
  67741. /**
  67742. * Creates a new Condition
  67743. * @param actionManager the manager of the action the condition is applied to
  67744. */
  67745. constructor(actionManager: ActionManager);
  67746. /**
  67747. * Check if the current condition is valid
  67748. * @returns a boolean
  67749. */
  67750. isValid(): boolean;
  67751. /**
  67752. * Internal only
  67753. * @hidden
  67754. */
  67755. _getProperty(propertyPath: string): string;
  67756. /**
  67757. * Internal only
  67758. * @hidden
  67759. */
  67760. _getEffectiveTarget(target: any, propertyPath: string): any;
  67761. /**
  67762. * Serialize placeholder for child classes
  67763. * @returns the serialized object
  67764. */
  67765. serialize(): any;
  67766. /**
  67767. * Internal only
  67768. * @hidden
  67769. */
  67770. protected _serialize(serializedCondition: any): any;
  67771. }
  67772. /**
  67773. * Defines specific conditional operators as extensions of Condition
  67774. */
  67775. export class ValueCondition extends Condition {
  67776. /** path to specify the property of the target the conditional operator uses */
  67777. propertyPath: string;
  67778. /** the value compared by the conditional operator against the current value of the property */
  67779. value: any;
  67780. /** the conditional operator, default ValueCondition.IsEqual */
  67781. operator: number;
  67782. /**
  67783. * Internal only
  67784. * @hidden
  67785. */
  67786. private static _IsEqual;
  67787. /**
  67788. * Internal only
  67789. * @hidden
  67790. */
  67791. private static _IsDifferent;
  67792. /**
  67793. * Internal only
  67794. * @hidden
  67795. */
  67796. private static _IsGreater;
  67797. /**
  67798. * Internal only
  67799. * @hidden
  67800. */
  67801. private static _IsLesser;
  67802. /**
  67803. * returns the number for IsEqual
  67804. */
  67805. static readonly IsEqual: number;
  67806. /**
  67807. * Returns the number for IsDifferent
  67808. */
  67809. static readonly IsDifferent: number;
  67810. /**
  67811. * Returns the number for IsGreater
  67812. */
  67813. static readonly IsGreater: number;
  67814. /**
  67815. * Returns the number for IsLesser
  67816. */
  67817. static readonly IsLesser: number;
  67818. /**
  67819. * Internal only The action manager for the condition
  67820. * @hidden
  67821. */
  67822. _actionManager: ActionManager;
  67823. /**
  67824. * Internal only
  67825. * @hidden
  67826. */
  67827. private _target;
  67828. /**
  67829. * Internal only
  67830. * @hidden
  67831. */
  67832. private _effectiveTarget;
  67833. /**
  67834. * Internal only
  67835. * @hidden
  67836. */
  67837. private _property;
  67838. /**
  67839. * Creates a new ValueCondition
  67840. * @param actionManager manager for the action the condition applies to
  67841. * @param target for the action
  67842. * @param propertyPath path to specify the property of the target the conditional operator uses
  67843. * @param value the value compared by the conditional operator against the current value of the property
  67844. * @param operator the conditional operator, default ValueCondition.IsEqual
  67845. */
  67846. constructor(actionManager: ActionManager, target: any,
  67847. /** path to specify the property of the target the conditional operator uses */
  67848. propertyPath: string,
  67849. /** the value compared by the conditional operator against the current value of the property */
  67850. value: any,
  67851. /** the conditional operator, default ValueCondition.IsEqual */
  67852. operator?: number);
  67853. /**
  67854. * Compares the given value with the property value for the specified conditional operator
  67855. * @returns the result of the comparison
  67856. */
  67857. isValid(): boolean;
  67858. /**
  67859. * Serialize the ValueCondition into a JSON compatible object
  67860. * @returns serialization object
  67861. */
  67862. serialize(): any;
  67863. /**
  67864. * Gets the name of the conditional operator for the ValueCondition
  67865. * @param operator the conditional operator
  67866. * @returns the name
  67867. */
  67868. static GetOperatorName(operator: number): string;
  67869. }
  67870. /**
  67871. * Defines a predicate condition as an extension of Condition
  67872. */
  67873. export class PredicateCondition extends Condition {
  67874. /** defines the predicate function used to validate the condition */
  67875. predicate: () => boolean;
  67876. /**
  67877. * Internal only - manager for action
  67878. * @hidden
  67879. */
  67880. _actionManager: ActionManager;
  67881. /**
  67882. * Creates a new PredicateCondition
  67883. * @param actionManager manager for the action the condition applies to
  67884. * @param predicate defines the predicate function used to validate the condition
  67885. */
  67886. constructor(actionManager: ActionManager,
  67887. /** defines the predicate function used to validate the condition */
  67888. predicate: () => boolean);
  67889. /**
  67890. * @returns the validity of the predicate condition
  67891. */
  67892. isValid(): boolean;
  67893. }
  67894. /**
  67895. * Defines a state condition as an extension of Condition
  67896. */
  67897. export class StateCondition extends Condition {
  67898. /** Value to compare with target state */
  67899. value: string;
  67900. /**
  67901. * Internal only - manager for action
  67902. * @hidden
  67903. */
  67904. _actionManager: ActionManager;
  67905. /**
  67906. * Internal only
  67907. * @hidden
  67908. */
  67909. private _target;
  67910. /**
  67911. * Creates a new StateCondition
  67912. * @param actionManager manager for the action the condition applies to
  67913. * @param target of the condition
  67914. * @param value to compare with target state
  67915. */
  67916. constructor(actionManager: ActionManager, target: any,
  67917. /** Value to compare with target state */
  67918. value: string);
  67919. /**
  67920. * Gets a boolean indicating if the current condition is met
  67921. * @returns the validity of the state
  67922. */
  67923. isValid(): boolean;
  67924. /**
  67925. * Serialize the StateCondition into a JSON compatible object
  67926. * @returns serialization object
  67927. */
  67928. serialize(): any;
  67929. }
  67930. }
  67931. declare module BABYLON {
  67932. /**
  67933. * This defines an action responsible to toggle a boolean once triggered.
  67934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67935. */
  67936. export class SwitchBooleanAction extends Action {
  67937. /**
  67938. * The path to the boolean property in the target object
  67939. */
  67940. propertyPath: string;
  67941. private _target;
  67942. private _effectiveTarget;
  67943. private _property;
  67944. /**
  67945. * Instantiate the action
  67946. * @param triggerOptions defines the trigger options
  67947. * @param target defines the object containing the boolean
  67948. * @param propertyPath defines the path to the boolean property in the target object
  67949. * @param condition defines the trigger related conditions
  67950. */
  67951. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  67952. /** @hidden */
  67953. _prepare(): void;
  67954. /**
  67955. * Execute the action toggle the boolean value.
  67956. */
  67957. execute(): void;
  67958. /**
  67959. * Serializes the actions and its related information.
  67960. * @param parent defines the object to serialize in
  67961. * @returns the serialized object
  67962. */
  67963. serialize(parent: any): any;
  67964. }
  67965. /**
  67966. * This defines an action responsible to set a the state field of the target
  67967. * to a desired value once triggered.
  67968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67969. */
  67970. export class SetStateAction extends Action {
  67971. /**
  67972. * The value to store in the state field.
  67973. */
  67974. value: string;
  67975. private _target;
  67976. /**
  67977. * Instantiate the action
  67978. * @param triggerOptions defines the trigger options
  67979. * @param target defines the object containing the state property
  67980. * @param value defines the value to store in the state field
  67981. * @param condition defines the trigger related conditions
  67982. */
  67983. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  67984. /**
  67985. * Execute the action and store the value on the target state property.
  67986. */
  67987. execute(): void;
  67988. /**
  67989. * Serializes the actions and its related information.
  67990. * @param parent defines the object to serialize in
  67991. * @returns the serialized object
  67992. */
  67993. serialize(parent: any): any;
  67994. }
  67995. /**
  67996. * This defines an action responsible to set a property of the target
  67997. * to a desired value once triggered.
  67998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67999. */
  68000. export class SetValueAction extends Action {
  68001. /**
  68002. * The path of the property to set in the target.
  68003. */
  68004. propertyPath: string;
  68005. /**
  68006. * The value to set in the property
  68007. */
  68008. value: any;
  68009. private _target;
  68010. private _effectiveTarget;
  68011. private _property;
  68012. /**
  68013. * Instantiate the action
  68014. * @param triggerOptions defines the trigger options
  68015. * @param target defines the object containing the property
  68016. * @param propertyPath defines the path of the property to set in the target
  68017. * @param value defines the value to set in the property
  68018. * @param condition defines the trigger related conditions
  68019. */
  68020. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68021. /** @hidden */
  68022. _prepare(): void;
  68023. /**
  68024. * Execute the action and set the targetted property to the desired value.
  68025. */
  68026. execute(): void;
  68027. /**
  68028. * Serializes the actions and its related information.
  68029. * @param parent defines the object to serialize in
  68030. * @returns the serialized object
  68031. */
  68032. serialize(parent: any): any;
  68033. }
  68034. /**
  68035. * This defines an action responsible to increment the target value
  68036. * to a desired value once triggered.
  68037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68038. */
  68039. export class IncrementValueAction extends Action {
  68040. /**
  68041. * The path of the property to increment in the target.
  68042. */
  68043. propertyPath: string;
  68044. /**
  68045. * The value we should increment the property by.
  68046. */
  68047. value: any;
  68048. private _target;
  68049. private _effectiveTarget;
  68050. private _property;
  68051. /**
  68052. * Instantiate the action
  68053. * @param triggerOptions defines the trigger options
  68054. * @param target defines the object containing the property
  68055. * @param propertyPath defines the path of the property to increment in the target
  68056. * @param value defines the value value we should increment the property by
  68057. * @param condition defines the trigger related conditions
  68058. */
  68059. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68060. /** @hidden */
  68061. _prepare(): void;
  68062. /**
  68063. * Execute the action and increment the target of the value amount.
  68064. */
  68065. execute(): void;
  68066. /**
  68067. * Serializes the actions and its related information.
  68068. * @param parent defines the object to serialize in
  68069. * @returns the serialized object
  68070. */
  68071. serialize(parent: any): any;
  68072. }
  68073. /**
  68074. * This defines an action responsible to start an animation once triggered.
  68075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68076. */
  68077. export class PlayAnimationAction extends Action {
  68078. /**
  68079. * Where the animation should start (animation frame)
  68080. */
  68081. from: number;
  68082. /**
  68083. * Where the animation should stop (animation frame)
  68084. */
  68085. to: number;
  68086. /**
  68087. * Define if the animation should loop or stop after the first play.
  68088. */
  68089. loop?: boolean;
  68090. private _target;
  68091. /**
  68092. * Instantiate the action
  68093. * @param triggerOptions defines the trigger options
  68094. * @param target defines the target animation or animation name
  68095. * @param from defines from where the animation should start (animation frame)
  68096. * @param end defines where the animation should stop (animation frame)
  68097. * @param loop defines if the animation should loop or stop after the first play
  68098. * @param condition defines the trigger related conditions
  68099. */
  68100. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  68101. /** @hidden */
  68102. _prepare(): void;
  68103. /**
  68104. * Execute the action and play the animation.
  68105. */
  68106. execute(): void;
  68107. /**
  68108. * Serializes the actions and its related information.
  68109. * @param parent defines the object to serialize in
  68110. * @returns the serialized object
  68111. */
  68112. serialize(parent: any): any;
  68113. }
  68114. /**
  68115. * This defines an action responsible to stop an animation once triggered.
  68116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68117. */
  68118. export class StopAnimationAction extends Action {
  68119. private _target;
  68120. /**
  68121. * Instantiate the action
  68122. * @param triggerOptions defines the trigger options
  68123. * @param target defines the target animation or animation name
  68124. * @param condition defines the trigger related conditions
  68125. */
  68126. constructor(triggerOptions: any, target: any, condition?: Condition);
  68127. /** @hidden */
  68128. _prepare(): void;
  68129. /**
  68130. * Execute the action and stop the animation.
  68131. */
  68132. execute(): void;
  68133. /**
  68134. * Serializes the actions and its related information.
  68135. * @param parent defines the object to serialize in
  68136. * @returns the serialized object
  68137. */
  68138. serialize(parent: any): any;
  68139. }
  68140. /**
  68141. * This defines an action responsible that does nothing once triggered.
  68142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68143. */
  68144. export class DoNothingAction extends Action {
  68145. /**
  68146. * Instantiate the action
  68147. * @param triggerOptions defines the trigger options
  68148. * @param condition defines the trigger related conditions
  68149. */
  68150. constructor(triggerOptions?: any, condition?: Condition);
  68151. /**
  68152. * Execute the action and do nothing.
  68153. */
  68154. execute(): void;
  68155. /**
  68156. * Serializes the actions and its related information.
  68157. * @param parent defines the object to serialize in
  68158. * @returns the serialized object
  68159. */
  68160. serialize(parent: any): any;
  68161. }
  68162. /**
  68163. * This defines an action responsible to trigger several actions once triggered.
  68164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68165. */
  68166. export class CombineAction extends Action {
  68167. /**
  68168. * The list of aggregated animations to run.
  68169. */
  68170. children: Action[];
  68171. /**
  68172. * Instantiate the action
  68173. * @param triggerOptions defines the trigger options
  68174. * @param children defines the list of aggregated animations to run
  68175. * @param condition defines the trigger related conditions
  68176. */
  68177. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  68178. /** @hidden */
  68179. _prepare(): void;
  68180. /**
  68181. * Execute the action and executes all the aggregated actions.
  68182. */
  68183. execute(evt: ActionEvent): void;
  68184. /**
  68185. * Serializes the actions and its related information.
  68186. * @param parent defines the object to serialize in
  68187. * @returns the serialized object
  68188. */
  68189. serialize(parent: any): any;
  68190. }
  68191. /**
  68192. * This defines an action responsible to run code (external event) once triggered.
  68193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68194. */
  68195. export class ExecuteCodeAction extends Action {
  68196. /**
  68197. * The callback function to run.
  68198. */
  68199. func: (evt: ActionEvent) => void;
  68200. /**
  68201. * Instantiate the action
  68202. * @param triggerOptions defines the trigger options
  68203. * @param func defines the callback function to run
  68204. * @param condition defines the trigger related conditions
  68205. */
  68206. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  68207. /**
  68208. * Execute the action and run the attached code.
  68209. */
  68210. execute(evt: ActionEvent): void;
  68211. }
  68212. /**
  68213. * This defines an action responsible to set the parent property of the target once triggered.
  68214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68215. */
  68216. export class SetParentAction extends Action {
  68217. private _parent;
  68218. private _target;
  68219. /**
  68220. * Instantiate the action
  68221. * @param triggerOptions defines the trigger options
  68222. * @param target defines the target containing the parent property
  68223. * @param parent defines from where the animation should start (animation frame)
  68224. * @param condition defines the trigger related conditions
  68225. */
  68226. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  68227. /** @hidden */
  68228. _prepare(): void;
  68229. /**
  68230. * Execute the action and set the parent property.
  68231. */
  68232. execute(): void;
  68233. /**
  68234. * Serializes the actions and its related information.
  68235. * @param parent defines the object to serialize in
  68236. * @returns the serialized object
  68237. */
  68238. serialize(parent: any): any;
  68239. }
  68240. }
  68241. declare module BABYLON {
  68242. /**
  68243. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  68244. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  68245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68246. */
  68247. export class ActionManager extends AbstractActionManager {
  68248. /**
  68249. * Nothing
  68250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68251. */
  68252. static readonly NothingTrigger: number;
  68253. /**
  68254. * On pick
  68255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68256. */
  68257. static readonly OnPickTrigger: number;
  68258. /**
  68259. * On left pick
  68260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68261. */
  68262. static readonly OnLeftPickTrigger: number;
  68263. /**
  68264. * On right pick
  68265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68266. */
  68267. static readonly OnRightPickTrigger: number;
  68268. /**
  68269. * On center pick
  68270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68271. */
  68272. static readonly OnCenterPickTrigger: number;
  68273. /**
  68274. * On pick down
  68275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68276. */
  68277. static readonly OnPickDownTrigger: number;
  68278. /**
  68279. * On double pick
  68280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68281. */
  68282. static readonly OnDoublePickTrigger: number;
  68283. /**
  68284. * On pick up
  68285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68286. */
  68287. static readonly OnPickUpTrigger: number;
  68288. /**
  68289. * On pick out.
  68290. * This trigger will only be raised if you also declared a OnPickDown
  68291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68292. */
  68293. static readonly OnPickOutTrigger: number;
  68294. /**
  68295. * On long press
  68296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68297. */
  68298. static readonly OnLongPressTrigger: number;
  68299. /**
  68300. * On pointer over
  68301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68302. */
  68303. static readonly OnPointerOverTrigger: number;
  68304. /**
  68305. * On pointer out
  68306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68307. */
  68308. static readonly OnPointerOutTrigger: number;
  68309. /**
  68310. * On every frame
  68311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68312. */
  68313. static readonly OnEveryFrameTrigger: number;
  68314. /**
  68315. * On intersection enter
  68316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68317. */
  68318. static readonly OnIntersectionEnterTrigger: number;
  68319. /**
  68320. * On intersection exit
  68321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68322. */
  68323. static readonly OnIntersectionExitTrigger: number;
  68324. /**
  68325. * On key down
  68326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68327. */
  68328. static readonly OnKeyDownTrigger: number;
  68329. /**
  68330. * On key up
  68331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68332. */
  68333. static readonly OnKeyUpTrigger: number;
  68334. private _scene;
  68335. /**
  68336. * Creates a new action manager
  68337. * @param scene defines the hosting scene
  68338. */
  68339. constructor(scene: Scene);
  68340. /**
  68341. * Releases all associated resources
  68342. */
  68343. dispose(): void;
  68344. /**
  68345. * Gets hosting scene
  68346. * @returns the hosting scene
  68347. */
  68348. getScene(): Scene;
  68349. /**
  68350. * Does this action manager handles actions of any of the given triggers
  68351. * @param triggers defines the triggers to be tested
  68352. * @return a boolean indicating whether one (or more) of the triggers is handled
  68353. */
  68354. hasSpecificTriggers(triggers: number[]): boolean;
  68355. /**
  68356. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  68357. * speed.
  68358. * @param triggerA defines the trigger to be tested
  68359. * @param triggerB defines the trigger to be tested
  68360. * @return a boolean indicating whether one (or more) of the triggers is handled
  68361. */
  68362. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  68363. /**
  68364. * Does this action manager handles actions of a given trigger
  68365. * @param trigger defines the trigger to be tested
  68366. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  68367. * @return whether the trigger is handled
  68368. */
  68369. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  68370. /**
  68371. * Does this action manager has pointer triggers
  68372. */
  68373. readonly hasPointerTriggers: boolean;
  68374. /**
  68375. * Does this action manager has pick triggers
  68376. */
  68377. readonly hasPickTriggers: boolean;
  68378. /**
  68379. * Registers an action to this action manager
  68380. * @param action defines the action to be registered
  68381. * @return the action amended (prepared) after registration
  68382. */
  68383. registerAction(action: Action): Nullable<Action>;
  68384. /**
  68385. * Unregisters an action to this action manager
  68386. * @param action defines the action to be unregistered
  68387. * @return a boolean indicating whether the action has been unregistered
  68388. */
  68389. unregisterAction(action: Action): Boolean;
  68390. /**
  68391. * Process a specific trigger
  68392. * @param trigger defines the trigger to process
  68393. * @param evt defines the event details to be processed
  68394. */
  68395. processTrigger(trigger: number, evt?: IActionEvent): void;
  68396. /** @hidden */
  68397. _getEffectiveTarget(target: any, propertyPath: string): any;
  68398. /** @hidden */
  68399. _getProperty(propertyPath: string): string;
  68400. /**
  68401. * Serialize this manager to a JSON object
  68402. * @param name defines the property name to store this manager
  68403. * @returns a JSON representation of this manager
  68404. */
  68405. serialize(name: string): any;
  68406. /**
  68407. * Creates a new ActionManager from a JSON data
  68408. * @param parsedActions defines the JSON data to read from
  68409. * @param object defines the hosting mesh
  68410. * @param scene defines the hosting scene
  68411. */
  68412. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  68413. /**
  68414. * Get a trigger name by index
  68415. * @param trigger defines the trigger index
  68416. * @returns a trigger name
  68417. */
  68418. static GetTriggerName(trigger: number): string;
  68419. }
  68420. }
  68421. declare module BABYLON {
  68422. /**
  68423. * Class representing a ray with position and direction
  68424. */
  68425. export class Ray {
  68426. /** origin point */
  68427. origin: Vector3;
  68428. /** direction */
  68429. direction: Vector3;
  68430. /** length of the ray */
  68431. length: number;
  68432. private static readonly TmpVector3;
  68433. private _tmpRay;
  68434. /**
  68435. * Creates a new ray
  68436. * @param origin origin point
  68437. * @param direction direction
  68438. * @param length length of the ray
  68439. */
  68440. constructor(
  68441. /** origin point */
  68442. origin: Vector3,
  68443. /** direction */
  68444. direction: Vector3,
  68445. /** length of the ray */
  68446. length?: number);
  68447. /**
  68448. * Checks if the ray intersects a box
  68449. * @param minimum bound of the box
  68450. * @param maximum bound of the box
  68451. * @param intersectionTreshold extra extend to be added to the box in all direction
  68452. * @returns if the box was hit
  68453. */
  68454. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  68455. /**
  68456. * Checks if the ray intersects a box
  68457. * @param box the bounding box to check
  68458. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  68459. * @returns if the box was hit
  68460. */
  68461. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  68462. /**
  68463. * If the ray hits a sphere
  68464. * @param sphere the bounding sphere to check
  68465. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  68466. * @returns true if it hits the sphere
  68467. */
  68468. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  68469. /**
  68470. * If the ray hits a triange
  68471. * @param vertex0 triangle vertex
  68472. * @param vertex1 triangle vertex
  68473. * @param vertex2 triangle vertex
  68474. * @returns intersection information if hit
  68475. */
  68476. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  68477. /**
  68478. * Checks if ray intersects a plane
  68479. * @param plane the plane to check
  68480. * @returns the distance away it was hit
  68481. */
  68482. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  68483. /**
  68484. * Checks if ray intersects a mesh
  68485. * @param mesh the mesh to check
  68486. * @param fastCheck if only the bounding box should checked
  68487. * @returns picking info of the intersecton
  68488. */
  68489. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  68490. /**
  68491. * Checks if ray intersects a mesh
  68492. * @param meshes the meshes to check
  68493. * @param fastCheck if only the bounding box should checked
  68494. * @param results array to store result in
  68495. * @returns Array of picking infos
  68496. */
  68497. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  68498. private _comparePickingInfo;
  68499. private static smallnum;
  68500. private static rayl;
  68501. /**
  68502. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  68503. * @param sega the first point of the segment to test the intersection against
  68504. * @param segb the second point of the segment to test the intersection against
  68505. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  68506. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  68507. */
  68508. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  68509. /**
  68510. * Update the ray from viewport position
  68511. * @param x position
  68512. * @param y y position
  68513. * @param viewportWidth viewport width
  68514. * @param viewportHeight viewport height
  68515. * @param world world matrix
  68516. * @param view view matrix
  68517. * @param projection projection matrix
  68518. * @returns this ray updated
  68519. */
  68520. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68521. /**
  68522. * Creates a ray with origin and direction of 0,0,0
  68523. * @returns the new ray
  68524. */
  68525. static Zero(): Ray;
  68526. /**
  68527. * Creates a new ray from screen space and viewport
  68528. * @param x position
  68529. * @param y y position
  68530. * @param viewportWidth viewport width
  68531. * @param viewportHeight viewport height
  68532. * @param world world matrix
  68533. * @param view view matrix
  68534. * @param projection projection matrix
  68535. * @returns new ray
  68536. */
  68537. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68538. /**
  68539. * 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
  68540. * transformed to the given world matrix.
  68541. * @param origin The origin point
  68542. * @param end The end point
  68543. * @param world a matrix to transform the ray to. Default is the identity matrix.
  68544. * @returns the new ray
  68545. */
  68546. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  68547. /**
  68548. * Transforms a ray by a matrix
  68549. * @param ray ray to transform
  68550. * @param matrix matrix to apply
  68551. * @returns the resulting new ray
  68552. */
  68553. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  68554. /**
  68555. * Transforms a ray by a matrix
  68556. * @param ray ray to transform
  68557. * @param matrix matrix to apply
  68558. * @param result ray to store result in
  68559. */
  68560. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  68561. /**
  68562. * Unproject a ray from screen space to object space
  68563. * @param sourceX defines the screen space x coordinate to use
  68564. * @param sourceY defines the screen space y coordinate to use
  68565. * @param viewportWidth defines the current width of the viewport
  68566. * @param viewportHeight defines the current height of the viewport
  68567. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68568. * @param view defines the view matrix to use
  68569. * @param projection defines the projection matrix to use
  68570. */
  68571. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  68572. }
  68573. /**
  68574. * Type used to define predicate used to select faces when a mesh intersection is detected
  68575. */
  68576. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  68577. interface Scene {
  68578. /** @hidden */
  68579. _tempPickingRay: Nullable<Ray>;
  68580. /** @hidden */
  68581. _cachedRayForTransform: Ray;
  68582. /** @hidden */
  68583. _pickWithRayInverseMatrix: Matrix;
  68584. /** @hidden */
  68585. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  68586. /** @hidden */
  68587. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  68588. }
  68589. }
  68590. declare module BABYLON {
  68591. /**
  68592. * Groups all the scene component constants in one place to ease maintenance.
  68593. * @hidden
  68594. */
  68595. export class SceneComponentConstants {
  68596. static readonly NAME_EFFECTLAYER: string;
  68597. static readonly NAME_LAYER: string;
  68598. static readonly NAME_LENSFLARESYSTEM: string;
  68599. static readonly NAME_BOUNDINGBOXRENDERER: string;
  68600. static readonly NAME_PARTICLESYSTEM: string;
  68601. static readonly NAME_GAMEPAD: string;
  68602. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  68603. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  68604. static readonly NAME_DEPTHRENDERER: string;
  68605. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  68606. static readonly NAME_SPRITE: string;
  68607. static readonly NAME_OUTLINERENDERER: string;
  68608. static readonly NAME_PROCEDURALTEXTURE: string;
  68609. static readonly NAME_SHADOWGENERATOR: string;
  68610. static readonly NAME_OCTREE: string;
  68611. static readonly NAME_PHYSICSENGINE: string;
  68612. static readonly NAME_AUDIO: string;
  68613. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68614. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68615. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68616. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68617. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68618. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68619. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68620. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68621. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68622. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68623. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68624. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68625. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68626. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68627. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68628. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68629. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68630. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68631. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68632. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68633. static readonly STEP_AFTERRENDER_AUDIO: number;
  68634. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68635. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68636. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68637. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68638. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68639. static readonly STEP_POINTERMOVE_SPRITE: number;
  68640. static readonly STEP_POINTERDOWN_SPRITE: number;
  68641. static readonly STEP_POINTERUP_SPRITE: number;
  68642. }
  68643. /**
  68644. * This represents a scene component.
  68645. *
  68646. * This is used to decouple the dependency the scene is having on the different workloads like
  68647. * layers, post processes...
  68648. */
  68649. export interface ISceneComponent {
  68650. /**
  68651. * The name of the component. Each component must have a unique name.
  68652. */
  68653. name: string;
  68654. /**
  68655. * The scene the component belongs to.
  68656. */
  68657. scene: Scene;
  68658. /**
  68659. * Register the component to one instance of a scene.
  68660. */
  68661. register(): void;
  68662. /**
  68663. * Rebuilds the elements related to this component in case of
  68664. * context lost for instance.
  68665. */
  68666. rebuild(): void;
  68667. /**
  68668. * Disposes the component and the associated ressources.
  68669. */
  68670. dispose(): void;
  68671. }
  68672. /**
  68673. * This represents a SERIALIZABLE scene component.
  68674. *
  68675. * This extends Scene Component to add Serialization methods on top.
  68676. */
  68677. export interface ISceneSerializableComponent extends ISceneComponent {
  68678. /**
  68679. * Adds all the element from the container to the scene
  68680. * @param container the container holding the elements
  68681. */
  68682. addFromContainer(container: AbstractScene): void;
  68683. /**
  68684. * Removes all the elements in the container from the scene
  68685. * @param container contains the elements to remove
  68686. */
  68687. removeFromContainer(container: AbstractScene): void;
  68688. /**
  68689. * Serializes the component data to the specified json object
  68690. * @param serializationObject The object to serialize to
  68691. */
  68692. serialize(serializationObject: any): void;
  68693. }
  68694. /**
  68695. * Strong typing of a Mesh related stage step action
  68696. */
  68697. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  68698. /**
  68699. * Strong typing of a Evaluate Sub Mesh related stage step action
  68700. */
  68701. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  68702. /**
  68703. * Strong typing of a Active Mesh related stage step action
  68704. */
  68705. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  68706. /**
  68707. * Strong typing of a Camera related stage step action
  68708. */
  68709. export type CameraStageAction = (camera: Camera) => void;
  68710. /**
  68711. * Strong typing of a Render Target related stage step action
  68712. */
  68713. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  68714. /**
  68715. * Strong typing of a RenderingGroup related stage step action
  68716. */
  68717. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  68718. /**
  68719. * Strong typing of a Mesh Render related stage step action
  68720. */
  68721. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  68722. /**
  68723. * Strong typing of a simple stage step action
  68724. */
  68725. export type SimpleStageAction = () => void;
  68726. /**
  68727. * Strong typing of a render target action.
  68728. */
  68729. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  68730. /**
  68731. * Strong typing of a pointer move action.
  68732. */
  68733. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  68734. /**
  68735. * Strong typing of a pointer up/down action.
  68736. */
  68737. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  68738. /**
  68739. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  68740. * @hidden
  68741. */
  68742. export class Stage<T extends Function> extends Array<{
  68743. index: number;
  68744. component: ISceneComponent;
  68745. action: T;
  68746. }> {
  68747. /**
  68748. * Hide ctor from the rest of the world.
  68749. * @param items The items to add.
  68750. */
  68751. private constructor();
  68752. /**
  68753. * Creates a new Stage.
  68754. * @returns A new instance of a Stage
  68755. */
  68756. static Create<T extends Function>(): Stage<T>;
  68757. /**
  68758. * Registers a step in an ordered way in the targeted stage.
  68759. * @param index Defines the position to register the step in
  68760. * @param component Defines the component attached to the step
  68761. * @param action Defines the action to launch during the step
  68762. */
  68763. registerStep(index: number, component: ISceneComponent, action: T): void;
  68764. /**
  68765. * Clears all the steps from the stage.
  68766. */
  68767. clear(): void;
  68768. }
  68769. }
  68770. declare module BABYLON {
  68771. interface Scene {
  68772. /** @hidden */
  68773. _pointerOverSprite: Nullable<Sprite>;
  68774. /** @hidden */
  68775. _pickedDownSprite: Nullable<Sprite>;
  68776. /** @hidden */
  68777. _tempSpritePickingRay: Nullable<Ray>;
  68778. /**
  68779. * All of the sprite managers added to this scene
  68780. * @see http://doc.babylonjs.com/babylon101/sprites
  68781. */
  68782. spriteManagers: Array<ISpriteManager>;
  68783. /**
  68784. * An event triggered when sprites rendering is about to start
  68785. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68786. */
  68787. onBeforeSpritesRenderingObservable: Observable<Scene>;
  68788. /**
  68789. * An event triggered when sprites rendering is done
  68790. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68791. */
  68792. onAfterSpritesRenderingObservable: Observable<Scene>;
  68793. /** @hidden */
  68794. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68795. /** Launch a ray to try to pick a sprite in the scene
  68796. * @param x position on screen
  68797. * @param y position on screen
  68798. * @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
  68799. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68800. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  68801. * @returns a PickingInfo
  68802. */
  68803. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68804. /** Use the given ray to pick a sprite in the scene
  68805. * @param ray The ray (in world space) to use to pick meshes
  68806. * @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
  68807. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68808. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  68809. * @returns a PickingInfo
  68810. */
  68811. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68812. /**
  68813. * Force the sprite under the pointer
  68814. * @param sprite defines the sprite to use
  68815. */
  68816. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  68817. /**
  68818. * Gets the sprite under the pointer
  68819. * @returns a Sprite or null if no sprite is under the pointer
  68820. */
  68821. getPointerOverSprite(): Nullable<Sprite>;
  68822. }
  68823. /**
  68824. * Defines the sprite scene component responsible to manage sprites
  68825. * in a given scene.
  68826. */
  68827. export class SpriteSceneComponent implements ISceneComponent {
  68828. /**
  68829. * The component name helpfull to identify the component in the list of scene components.
  68830. */
  68831. readonly name: string;
  68832. /**
  68833. * The scene the component belongs to.
  68834. */
  68835. scene: Scene;
  68836. /** @hidden */
  68837. private _spritePredicate;
  68838. /**
  68839. * Creates a new instance of the component for the given scene
  68840. * @param scene Defines the scene to register the component in
  68841. */
  68842. constructor(scene: Scene);
  68843. /**
  68844. * Registers the component in a given scene
  68845. */
  68846. register(): void;
  68847. /**
  68848. * Rebuilds the elements related to this component in case of
  68849. * context lost for instance.
  68850. */
  68851. rebuild(): void;
  68852. /**
  68853. * Disposes the component and the associated ressources.
  68854. */
  68855. dispose(): void;
  68856. private _pickSpriteButKeepRay;
  68857. private _pointerMove;
  68858. private _pointerDown;
  68859. private _pointerUp;
  68860. }
  68861. }
  68862. declare module BABYLON {
  68863. /** @hidden */
  68864. export var fogFragmentDeclaration: {
  68865. name: string;
  68866. shader: string;
  68867. };
  68868. }
  68869. declare module BABYLON {
  68870. /** @hidden */
  68871. export var fogFragment: {
  68872. name: string;
  68873. shader: string;
  68874. };
  68875. }
  68876. declare module BABYLON {
  68877. /** @hidden */
  68878. export var spritesPixelShader: {
  68879. name: string;
  68880. shader: string;
  68881. };
  68882. }
  68883. declare module BABYLON {
  68884. /** @hidden */
  68885. export var fogVertexDeclaration: {
  68886. name: string;
  68887. shader: string;
  68888. };
  68889. }
  68890. declare module BABYLON {
  68891. /** @hidden */
  68892. export var spritesVertexShader: {
  68893. name: string;
  68894. shader: string;
  68895. };
  68896. }
  68897. declare module BABYLON {
  68898. /**
  68899. * Defines the minimum interface to fullfil in order to be a sprite manager.
  68900. */
  68901. export interface ISpriteManager extends IDisposable {
  68902. /**
  68903. * Restricts the camera to viewing objects with the same layerMask.
  68904. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  68905. */
  68906. layerMask: number;
  68907. /**
  68908. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  68909. */
  68910. isPickable: boolean;
  68911. /**
  68912. * Specifies the rendering group id for this mesh (0 by default)
  68913. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  68914. */
  68915. renderingGroupId: number;
  68916. /**
  68917. * Defines the list of sprites managed by the manager.
  68918. */
  68919. sprites: Array<Sprite>;
  68920. /**
  68921. * Tests the intersection of a sprite with a specific ray.
  68922. * @param ray The ray we are sending to test the collision
  68923. * @param camera The camera space we are sending rays in
  68924. * @param predicate A predicate allowing excluding sprites from the list of object to test
  68925. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  68926. * @returns picking info or null.
  68927. */
  68928. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68929. /**
  68930. * Renders the list of sprites on screen.
  68931. */
  68932. render(): void;
  68933. }
  68934. /**
  68935. * Class used to manage multiple sprites on the same spritesheet
  68936. * @see http://doc.babylonjs.com/babylon101/sprites
  68937. */
  68938. export class SpriteManager implements ISpriteManager {
  68939. /** defines the manager's name */
  68940. name: string;
  68941. /** Gets the list of sprites */
  68942. sprites: Sprite[];
  68943. /** Gets or sets the rendering group id (0 by default) */
  68944. renderingGroupId: number;
  68945. /** Gets or sets camera layer mask */
  68946. layerMask: number;
  68947. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  68948. fogEnabled: boolean;
  68949. /** Gets or sets a boolean indicating if the sprites are pickable */
  68950. isPickable: boolean;
  68951. /** Defines the default width of a cell in the spritesheet */
  68952. cellWidth: number;
  68953. /** Defines the default height of a cell in the spritesheet */
  68954. cellHeight: number;
  68955. /**
  68956. * An event triggered when the manager is disposed.
  68957. */
  68958. onDisposeObservable: Observable<SpriteManager>;
  68959. private _onDisposeObserver;
  68960. /**
  68961. * Callback called when the manager is disposed
  68962. */
  68963. onDispose: () => void;
  68964. private _capacity;
  68965. private _spriteTexture;
  68966. private _epsilon;
  68967. private _scene;
  68968. private _vertexData;
  68969. private _buffer;
  68970. private _vertexBuffers;
  68971. private _indexBuffer;
  68972. private _effectBase;
  68973. private _effectFog;
  68974. /**
  68975. * Gets or sets the spritesheet texture
  68976. */
  68977. texture: Texture;
  68978. /**
  68979. * Creates a new sprite manager
  68980. * @param name defines the manager's name
  68981. * @param imgUrl defines the sprite sheet url
  68982. * @param capacity defines the maximum allowed number of sprites
  68983. * @param cellSize defines the size of a sprite cell
  68984. * @param scene defines the hosting scene
  68985. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68986. * @param samplingMode defines the smapling mode to use with spritesheet
  68987. */
  68988. constructor(
  68989. /** defines the manager's name */
  68990. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  68991. private _appendSpriteVertex;
  68992. /**
  68993. * Intersects the sprites with a ray
  68994. * @param ray defines the ray to intersect with
  68995. * @param camera defines the current active camera
  68996. * @param predicate defines a predicate used to select candidate sprites
  68997. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  68998. * @returns null if no hit or a PickingInfo
  68999. */
  69000. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69001. /**
  69002. * Render all child sprites
  69003. */
  69004. render(): void;
  69005. /**
  69006. * Release associated resources
  69007. */
  69008. dispose(): void;
  69009. }
  69010. }
  69011. declare module BABYLON {
  69012. /**
  69013. * Class used to represent a sprite
  69014. * @see http://doc.babylonjs.com/babylon101/sprites
  69015. */
  69016. export class Sprite {
  69017. /** defines the name */
  69018. name: string;
  69019. /** Gets or sets the current world position */
  69020. position: Vector3;
  69021. /** Gets or sets the main color */
  69022. color: Color4;
  69023. /** Gets or sets the width */
  69024. width: number;
  69025. /** Gets or sets the height */
  69026. height: number;
  69027. /** Gets or sets rotation angle */
  69028. angle: number;
  69029. /** Gets or sets the cell index in the sprite sheet */
  69030. cellIndex: number;
  69031. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  69032. invertU: number;
  69033. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  69034. invertV: number;
  69035. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  69036. disposeWhenFinishedAnimating: boolean;
  69037. /** Gets the list of attached animations */
  69038. animations: Animation[];
  69039. /** Gets or sets a boolean indicating if the sprite can be picked */
  69040. isPickable: boolean;
  69041. /**
  69042. * Gets or sets the associated action manager
  69043. */
  69044. actionManager: Nullable<ActionManager>;
  69045. private _animationStarted;
  69046. private _loopAnimation;
  69047. private _fromIndex;
  69048. private _toIndex;
  69049. private _delay;
  69050. private _direction;
  69051. private _manager;
  69052. private _time;
  69053. private _onAnimationEnd;
  69054. /**
  69055. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  69056. */
  69057. isVisible: boolean;
  69058. /**
  69059. * Gets or sets the sprite size
  69060. */
  69061. size: number;
  69062. /**
  69063. * Creates a new Sprite
  69064. * @param name defines the name
  69065. * @param manager defines the manager
  69066. */
  69067. constructor(
  69068. /** defines the name */
  69069. name: string, manager: ISpriteManager);
  69070. /**
  69071. * Starts an animation
  69072. * @param from defines the initial key
  69073. * @param to defines the end key
  69074. * @param loop defines if the animation must loop
  69075. * @param delay defines the start delay (in ms)
  69076. * @param onAnimationEnd defines a callback to call when animation ends
  69077. */
  69078. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  69079. /** Stops current animation (if any) */
  69080. stopAnimation(): void;
  69081. /** @hidden */
  69082. _animate(deltaTime: number): void;
  69083. /** Release associated resources */
  69084. dispose(): void;
  69085. }
  69086. }
  69087. declare module BABYLON {
  69088. /**
  69089. * Information about the result of picking within a scene
  69090. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  69091. */
  69092. export class PickingInfo {
  69093. /** @hidden */
  69094. _pickingUnavailable: boolean;
  69095. /**
  69096. * If the pick collided with an object
  69097. */
  69098. hit: boolean;
  69099. /**
  69100. * Distance away where the pick collided
  69101. */
  69102. distance: number;
  69103. /**
  69104. * The location of pick collision
  69105. */
  69106. pickedPoint: Nullable<Vector3>;
  69107. /**
  69108. * The mesh corresponding the the pick collision
  69109. */
  69110. pickedMesh: Nullable<AbstractMesh>;
  69111. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  69112. bu: number;
  69113. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  69114. bv: number;
  69115. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  69116. faceId: number;
  69117. /** Id of the the submesh that was picked */
  69118. subMeshId: number;
  69119. /** If a sprite was picked, this will be the sprite the pick collided with */
  69120. pickedSprite: Nullable<Sprite>;
  69121. /**
  69122. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  69123. */
  69124. originMesh: Nullable<AbstractMesh>;
  69125. /**
  69126. * The ray that was used to perform the picking.
  69127. */
  69128. ray: Nullable<Ray>;
  69129. /**
  69130. * Gets the normal correspodning to the face the pick collided with
  69131. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  69132. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  69133. * @returns The normal correspodning to the face the pick collided with
  69134. */
  69135. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  69136. /**
  69137. * Gets the texture coordinates of where the pick occured
  69138. * @returns the vector containing the coordnates of the texture
  69139. */
  69140. getTextureCoordinates(): Nullable<Vector2>;
  69141. }
  69142. }
  69143. declare module BABYLON {
  69144. /**
  69145. * Gather the list of pointer event types as constants.
  69146. */
  69147. export class PointerEventTypes {
  69148. /**
  69149. * 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.
  69150. */
  69151. static readonly POINTERDOWN: number;
  69152. /**
  69153. * The pointerup event is fired when a pointer is no longer active.
  69154. */
  69155. static readonly POINTERUP: number;
  69156. /**
  69157. * The pointermove event is fired when a pointer changes coordinates.
  69158. */
  69159. static readonly POINTERMOVE: number;
  69160. /**
  69161. * The pointerwheel event is fired when a mouse wheel has been rotated.
  69162. */
  69163. static readonly POINTERWHEEL: number;
  69164. /**
  69165. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  69166. */
  69167. static readonly POINTERPICK: number;
  69168. /**
  69169. * The pointertap event is fired when a the object has been touched and released without drag.
  69170. */
  69171. static readonly POINTERTAP: number;
  69172. /**
  69173. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  69174. */
  69175. static readonly POINTERDOUBLETAP: number;
  69176. }
  69177. /**
  69178. * Base class of pointer info types.
  69179. */
  69180. export class PointerInfoBase {
  69181. /**
  69182. * Defines the type of event (PointerEventTypes)
  69183. */
  69184. type: number;
  69185. /**
  69186. * Defines the related dom event
  69187. */
  69188. event: PointerEvent | MouseWheelEvent;
  69189. /**
  69190. * Instantiates the base class of pointers info.
  69191. * @param type Defines the type of event (PointerEventTypes)
  69192. * @param event Defines the related dom event
  69193. */
  69194. constructor(
  69195. /**
  69196. * Defines the type of event (PointerEventTypes)
  69197. */
  69198. type: number,
  69199. /**
  69200. * Defines the related dom event
  69201. */
  69202. event: PointerEvent | MouseWheelEvent);
  69203. }
  69204. /**
  69205. * This class is used to store pointer related info for the onPrePointerObservable event.
  69206. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  69207. */
  69208. export class PointerInfoPre extends PointerInfoBase {
  69209. /**
  69210. * Ray from a pointer if availible (eg. 6dof controller)
  69211. */
  69212. ray: Nullable<Ray>;
  69213. /**
  69214. * Defines the local position of the pointer on the canvas.
  69215. */
  69216. localPosition: Vector2;
  69217. /**
  69218. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  69219. */
  69220. skipOnPointerObservable: boolean;
  69221. /**
  69222. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  69223. * @param type Defines the type of event (PointerEventTypes)
  69224. * @param event Defines the related dom event
  69225. * @param localX Defines the local x coordinates of the pointer when the event occured
  69226. * @param localY Defines the local y coordinates of the pointer when the event occured
  69227. */
  69228. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  69229. }
  69230. /**
  69231. * This type contains all the data related to a pointer event in Babylon.js.
  69232. * 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.
  69233. */
  69234. export class PointerInfo extends PointerInfoBase {
  69235. /**
  69236. * Defines the picking info associated to the info (if any)\
  69237. */
  69238. pickInfo: Nullable<PickingInfo>;
  69239. /**
  69240. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  69241. * @param type Defines the type of event (PointerEventTypes)
  69242. * @param event Defines the related dom event
  69243. * @param pickInfo Defines the picking info associated to the info (if any)\
  69244. */
  69245. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  69246. /**
  69247. * Defines the picking info associated to the info (if any)\
  69248. */
  69249. pickInfo: Nullable<PickingInfo>);
  69250. }
  69251. /**
  69252. * Data relating to a touch event on the screen.
  69253. */
  69254. export interface PointerTouch {
  69255. /**
  69256. * X coordinate of touch.
  69257. */
  69258. x: number;
  69259. /**
  69260. * Y coordinate of touch.
  69261. */
  69262. y: number;
  69263. /**
  69264. * Id of touch. Unique for each finger.
  69265. */
  69266. pointerId: number;
  69267. /**
  69268. * Event type passed from DOM.
  69269. */
  69270. type: any;
  69271. }
  69272. }
  69273. declare module BABYLON {
  69274. /**
  69275. * Manage the mouse inputs to control the movement of a free camera.
  69276. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69277. */
  69278. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  69279. /**
  69280. * Define if touch is enabled in the mouse input
  69281. */
  69282. touchEnabled: boolean;
  69283. /**
  69284. * Defines the camera the input is attached to.
  69285. */
  69286. camera: FreeCamera;
  69287. /**
  69288. * Defines the buttons associated with the input to handle camera move.
  69289. */
  69290. buttons: number[];
  69291. /**
  69292. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  69293. */
  69294. angularSensibility: number;
  69295. private _pointerInput;
  69296. private _onMouseMove;
  69297. private _observer;
  69298. private previousPosition;
  69299. /**
  69300. * Manage the mouse inputs to control the movement of a free camera.
  69301. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69302. * @param touchEnabled Defines if touch is enabled or not
  69303. */
  69304. constructor(
  69305. /**
  69306. * Define if touch is enabled in the mouse input
  69307. */
  69308. touchEnabled?: boolean);
  69309. /**
  69310. * Attach the input controls to a specific dom element to get the input from.
  69311. * @param element Defines the element the controls should be listened from
  69312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69313. */
  69314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69315. /**
  69316. * Detach the current controls from the specified dom element.
  69317. * @param element Defines the element to stop listening the inputs from
  69318. */
  69319. detachControl(element: Nullable<HTMLElement>): void;
  69320. /**
  69321. * Gets the class name of the current intput.
  69322. * @returns the class name
  69323. */
  69324. getClassName(): string;
  69325. /**
  69326. * Get the friendly name associated with the input class.
  69327. * @returns the input friendly name
  69328. */
  69329. getSimpleName(): string;
  69330. }
  69331. }
  69332. declare module BABYLON {
  69333. /**
  69334. * Manage the touch inputs to control the movement of a free camera.
  69335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69336. */
  69337. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69338. /**
  69339. * Defines the camera the input is attached to.
  69340. */
  69341. camera: FreeCamera;
  69342. /**
  69343. * Defines the touch sensibility for rotation.
  69344. * The higher the faster.
  69345. */
  69346. touchAngularSensibility: number;
  69347. /**
  69348. * Defines the touch sensibility for move.
  69349. * The higher the faster.
  69350. */
  69351. touchMoveSensibility: number;
  69352. private _offsetX;
  69353. private _offsetY;
  69354. private _pointerPressed;
  69355. private _pointerInput;
  69356. private _observer;
  69357. private _onLostFocus;
  69358. /**
  69359. * Attach the input controls to a specific dom element to get the input from.
  69360. * @param element Defines the element the controls should be listened from
  69361. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69362. */
  69363. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69364. /**
  69365. * Detach the current controls from the specified dom element.
  69366. * @param element Defines the element to stop listening the inputs from
  69367. */
  69368. detachControl(element: Nullable<HTMLElement>): void;
  69369. /**
  69370. * Update the current camera state depending on the inputs that have been used this frame.
  69371. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69372. */
  69373. checkInputs(): void;
  69374. /**
  69375. * Gets the class name of the current intput.
  69376. * @returns the class name
  69377. */
  69378. getClassName(): string;
  69379. /**
  69380. * Get the friendly name associated with the input class.
  69381. * @returns the input friendly name
  69382. */
  69383. getSimpleName(): string;
  69384. }
  69385. }
  69386. declare module BABYLON {
  69387. /**
  69388. * Default Inputs manager for the FreeCamera.
  69389. * It groups all the default supported inputs for ease of use.
  69390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69391. */
  69392. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  69393. /**
  69394. * Instantiates a new FreeCameraInputsManager.
  69395. * @param camera Defines the camera the inputs belong to
  69396. */
  69397. constructor(camera: FreeCamera);
  69398. /**
  69399. * Add keyboard input support to the input manager.
  69400. * @returns the current input manager
  69401. */
  69402. addKeyboard(): FreeCameraInputsManager;
  69403. /**
  69404. * Add mouse input support to the input manager.
  69405. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  69406. * @returns the current input manager
  69407. */
  69408. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  69409. /**
  69410. * Add touch input support to the input manager.
  69411. * @returns the current input manager
  69412. */
  69413. addTouch(): FreeCameraInputsManager;
  69414. }
  69415. }
  69416. declare module BABYLON {
  69417. /**
  69418. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69419. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  69420. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69421. */
  69422. export class FreeCamera extends TargetCamera {
  69423. /**
  69424. * Define the collision ellipsoid of the camera.
  69425. * This is helpful to simulate a camera body like the player body around the camera
  69426. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  69427. */
  69428. ellipsoid: Vector3;
  69429. /**
  69430. * Define an offset for the position of the ellipsoid around the camera.
  69431. * This can be helpful to determine the center of the body near the gravity center of the body
  69432. * instead of its head.
  69433. */
  69434. ellipsoidOffset: Vector3;
  69435. /**
  69436. * Enable or disable collisions of the camera with the rest of the scene objects.
  69437. */
  69438. checkCollisions: boolean;
  69439. /**
  69440. * Enable or disable gravity on the camera.
  69441. */
  69442. applyGravity: boolean;
  69443. /**
  69444. * Define the input manager associated to the camera.
  69445. */
  69446. inputs: FreeCameraInputsManager;
  69447. /**
  69448. * Gets the input sensibility for a mouse input. (default is 2000.0)
  69449. * Higher values reduce sensitivity.
  69450. */
  69451. /**
  69452. * Sets the input sensibility for a mouse input. (default is 2000.0)
  69453. * Higher values reduce sensitivity.
  69454. */
  69455. angularSensibility: number;
  69456. /**
  69457. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69458. */
  69459. keysUp: number[];
  69460. /**
  69461. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69462. */
  69463. keysDown: number[];
  69464. /**
  69465. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69466. */
  69467. keysLeft: number[];
  69468. /**
  69469. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69470. */
  69471. keysRight: number[];
  69472. /**
  69473. * Event raised when the camera collide with a mesh in the scene.
  69474. */
  69475. onCollide: (collidedMesh: AbstractMesh) => void;
  69476. private _collider;
  69477. private _needMoveForGravity;
  69478. private _oldPosition;
  69479. private _diffPosition;
  69480. private _newPosition;
  69481. /** @hidden */
  69482. _localDirection: Vector3;
  69483. /** @hidden */
  69484. _transformedDirection: Vector3;
  69485. /**
  69486. * Instantiates a Free Camera.
  69487. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69488. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  69489. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69490. * @param name Define the name of the camera in the scene
  69491. * @param position Define the start position of the camera in the scene
  69492. * @param scene Define the scene the camera belongs to
  69493. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69494. */
  69495. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69496. /**
  69497. * Attached controls to the current camera.
  69498. * @param element Defines the element the controls should be listened from
  69499. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69500. */
  69501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69502. /**
  69503. * Detach the current controls from the camera.
  69504. * The camera will stop reacting to inputs.
  69505. * @param element Defines the element to stop listening the inputs from
  69506. */
  69507. detachControl(element: HTMLElement): void;
  69508. private _collisionMask;
  69509. /**
  69510. * Define a collision mask to limit the list of object the camera can collide with
  69511. */
  69512. collisionMask: number;
  69513. /** @hidden */
  69514. _collideWithWorld(displacement: Vector3): void;
  69515. private _onCollisionPositionChange;
  69516. /** @hidden */
  69517. _checkInputs(): void;
  69518. /** @hidden */
  69519. _decideIfNeedsToMove(): boolean;
  69520. /** @hidden */
  69521. _updatePosition(): void;
  69522. /**
  69523. * Destroy the camera and release the current resources hold by it.
  69524. */
  69525. dispose(): void;
  69526. /**
  69527. * Gets the current object class name.
  69528. * @return the class name
  69529. */
  69530. getClassName(): string;
  69531. }
  69532. }
  69533. declare module BABYLON {
  69534. /**
  69535. * Represents a gamepad control stick position
  69536. */
  69537. export class StickValues {
  69538. /**
  69539. * The x component of the control stick
  69540. */
  69541. x: number;
  69542. /**
  69543. * The y component of the control stick
  69544. */
  69545. y: number;
  69546. /**
  69547. * Initializes the gamepad x and y control stick values
  69548. * @param x The x component of the gamepad control stick value
  69549. * @param y The y component of the gamepad control stick value
  69550. */
  69551. constructor(
  69552. /**
  69553. * The x component of the control stick
  69554. */
  69555. x: number,
  69556. /**
  69557. * The y component of the control stick
  69558. */
  69559. y: number);
  69560. }
  69561. /**
  69562. * An interface which manages callbacks for gamepad button changes
  69563. */
  69564. export interface GamepadButtonChanges {
  69565. /**
  69566. * Called when a gamepad has been changed
  69567. */
  69568. changed: boolean;
  69569. /**
  69570. * Called when a gamepad press event has been triggered
  69571. */
  69572. pressChanged: boolean;
  69573. /**
  69574. * Called when a touch event has been triggered
  69575. */
  69576. touchChanged: boolean;
  69577. /**
  69578. * Called when a value has changed
  69579. */
  69580. valueChanged: boolean;
  69581. }
  69582. /**
  69583. * Represents a gamepad
  69584. */
  69585. export class Gamepad {
  69586. /**
  69587. * The id of the gamepad
  69588. */
  69589. id: string;
  69590. /**
  69591. * The index of the gamepad
  69592. */
  69593. index: number;
  69594. /**
  69595. * The browser gamepad
  69596. */
  69597. browserGamepad: any;
  69598. /**
  69599. * Specifies what type of gamepad this represents
  69600. */
  69601. type: number;
  69602. private _leftStick;
  69603. private _rightStick;
  69604. /** @hidden */
  69605. _isConnected: boolean;
  69606. private _leftStickAxisX;
  69607. private _leftStickAxisY;
  69608. private _rightStickAxisX;
  69609. private _rightStickAxisY;
  69610. /**
  69611. * Triggered when the left control stick has been changed
  69612. */
  69613. private _onleftstickchanged;
  69614. /**
  69615. * Triggered when the right control stick has been changed
  69616. */
  69617. private _onrightstickchanged;
  69618. /**
  69619. * Represents a gamepad controller
  69620. */
  69621. static GAMEPAD: number;
  69622. /**
  69623. * Represents a generic controller
  69624. */
  69625. static GENERIC: number;
  69626. /**
  69627. * Represents an XBox controller
  69628. */
  69629. static XBOX: number;
  69630. /**
  69631. * Represents a pose-enabled controller
  69632. */
  69633. static POSE_ENABLED: number;
  69634. /**
  69635. * Specifies whether the left control stick should be Y-inverted
  69636. */
  69637. protected _invertLeftStickY: boolean;
  69638. /**
  69639. * Specifies if the gamepad has been connected
  69640. */
  69641. readonly isConnected: boolean;
  69642. /**
  69643. * Initializes the gamepad
  69644. * @param id The id of the gamepad
  69645. * @param index The index of the gamepad
  69646. * @param browserGamepad The browser gamepad
  69647. * @param leftStickX The x component of the left joystick
  69648. * @param leftStickY The y component of the left joystick
  69649. * @param rightStickX The x component of the right joystick
  69650. * @param rightStickY The y component of the right joystick
  69651. */
  69652. constructor(
  69653. /**
  69654. * The id of the gamepad
  69655. */
  69656. id: string,
  69657. /**
  69658. * The index of the gamepad
  69659. */
  69660. index: number,
  69661. /**
  69662. * The browser gamepad
  69663. */
  69664. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  69665. /**
  69666. * Callback triggered when the left joystick has changed
  69667. * @param callback
  69668. */
  69669. onleftstickchanged(callback: (values: StickValues) => void): void;
  69670. /**
  69671. * Callback triggered when the right joystick has changed
  69672. * @param callback
  69673. */
  69674. onrightstickchanged(callback: (values: StickValues) => void): void;
  69675. /**
  69676. * Gets the left joystick
  69677. */
  69678. /**
  69679. * Sets the left joystick values
  69680. */
  69681. leftStick: StickValues;
  69682. /**
  69683. * Gets the right joystick
  69684. */
  69685. /**
  69686. * Sets the right joystick value
  69687. */
  69688. rightStick: StickValues;
  69689. /**
  69690. * Updates the gamepad joystick positions
  69691. */
  69692. update(): void;
  69693. /**
  69694. * Disposes the gamepad
  69695. */
  69696. dispose(): void;
  69697. }
  69698. /**
  69699. * Represents a generic gamepad
  69700. */
  69701. export class GenericPad extends Gamepad {
  69702. private _buttons;
  69703. private _onbuttondown;
  69704. private _onbuttonup;
  69705. /**
  69706. * Observable triggered when a button has been pressed
  69707. */
  69708. onButtonDownObservable: Observable<number>;
  69709. /**
  69710. * Observable triggered when a button has been released
  69711. */
  69712. onButtonUpObservable: Observable<number>;
  69713. /**
  69714. * Callback triggered when a button has been pressed
  69715. * @param callback Called when a button has been pressed
  69716. */
  69717. onbuttondown(callback: (buttonPressed: number) => void): void;
  69718. /**
  69719. * Callback triggered when a button has been released
  69720. * @param callback Called when a button has been released
  69721. */
  69722. onbuttonup(callback: (buttonReleased: number) => void): void;
  69723. /**
  69724. * Initializes the generic gamepad
  69725. * @param id The id of the generic gamepad
  69726. * @param index The index of the generic gamepad
  69727. * @param browserGamepad The browser gamepad
  69728. */
  69729. constructor(id: string, index: number, browserGamepad: any);
  69730. private _setButtonValue;
  69731. /**
  69732. * Updates the generic gamepad
  69733. */
  69734. update(): void;
  69735. /**
  69736. * Disposes the generic gamepad
  69737. */
  69738. dispose(): void;
  69739. }
  69740. }
  69741. declare module BABYLON {
  69742. /**
  69743. * Defines the types of pose enabled controllers that are supported
  69744. */
  69745. export enum PoseEnabledControllerType {
  69746. /**
  69747. * HTC Vive
  69748. */
  69749. VIVE = 0,
  69750. /**
  69751. * Oculus Rift
  69752. */
  69753. OCULUS = 1,
  69754. /**
  69755. * Windows mixed reality
  69756. */
  69757. WINDOWS = 2,
  69758. /**
  69759. * Samsung gear VR
  69760. */
  69761. GEAR_VR = 3,
  69762. /**
  69763. * Google Daydream
  69764. */
  69765. DAYDREAM = 4,
  69766. /**
  69767. * Generic
  69768. */
  69769. GENERIC = 5
  69770. }
  69771. /**
  69772. * Defines the MutableGamepadButton interface for the state of a gamepad button
  69773. */
  69774. export interface MutableGamepadButton {
  69775. /**
  69776. * Value of the button/trigger
  69777. */
  69778. value: number;
  69779. /**
  69780. * If the button/trigger is currently touched
  69781. */
  69782. touched: boolean;
  69783. /**
  69784. * If the button/trigger is currently pressed
  69785. */
  69786. pressed: boolean;
  69787. }
  69788. /**
  69789. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  69790. * @hidden
  69791. */
  69792. export interface ExtendedGamepadButton extends GamepadButton {
  69793. /**
  69794. * If the button/trigger is currently pressed
  69795. */
  69796. readonly pressed: boolean;
  69797. /**
  69798. * If the button/trigger is currently touched
  69799. */
  69800. readonly touched: boolean;
  69801. /**
  69802. * Value of the button/trigger
  69803. */
  69804. readonly value: number;
  69805. }
  69806. /** @hidden */
  69807. export interface _GamePadFactory {
  69808. /**
  69809. * Returns wether or not the current gamepad can be created for this type of controller.
  69810. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69811. * @returns true if it can be created, otherwise false
  69812. */
  69813. canCreate(gamepadInfo: any): boolean;
  69814. /**
  69815. * Creates a new instance of the Gamepad.
  69816. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69817. * @returns the new gamepad instance
  69818. */
  69819. create(gamepadInfo: any): Gamepad;
  69820. }
  69821. /**
  69822. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69823. */
  69824. export class PoseEnabledControllerHelper {
  69825. /** @hidden */
  69826. static _ControllerFactories: _GamePadFactory[];
  69827. /** @hidden */
  69828. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  69829. /**
  69830. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69831. * @param vrGamepad the gamepad to initialized
  69832. * @returns a vr controller of the type the gamepad identified as
  69833. */
  69834. static InitiateController(vrGamepad: any): Gamepad;
  69835. }
  69836. /**
  69837. * Defines the PoseEnabledController object that contains state of a vr capable controller
  69838. */
  69839. export class PoseEnabledController extends Gamepad implements PoseControlled {
  69840. private _deviceRoomPosition;
  69841. private _deviceRoomRotationQuaternion;
  69842. /**
  69843. * The device position in babylon space
  69844. */
  69845. devicePosition: Vector3;
  69846. /**
  69847. * The device rotation in babylon space
  69848. */
  69849. deviceRotationQuaternion: Quaternion;
  69850. /**
  69851. * The scale factor of the device in babylon space
  69852. */
  69853. deviceScaleFactor: number;
  69854. /**
  69855. * (Likely devicePosition should be used instead) The device position in its room space
  69856. */
  69857. position: Vector3;
  69858. /**
  69859. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  69860. */
  69861. rotationQuaternion: Quaternion;
  69862. /**
  69863. * The type of controller (Eg. Windows mixed reality)
  69864. */
  69865. controllerType: PoseEnabledControllerType;
  69866. protected _calculatedPosition: Vector3;
  69867. private _calculatedRotation;
  69868. /**
  69869. * The raw pose from the device
  69870. */
  69871. rawPose: DevicePose;
  69872. private _trackPosition;
  69873. private _maxRotationDistFromHeadset;
  69874. private _draggedRoomRotation;
  69875. /**
  69876. * @hidden
  69877. */
  69878. _disableTrackPosition(fixedPosition: Vector3): void;
  69879. /**
  69880. * Internal, the mesh attached to the controller
  69881. * @hidden
  69882. */
  69883. _mesh: Nullable<AbstractMesh>;
  69884. private _poseControlledCamera;
  69885. private _leftHandSystemQuaternion;
  69886. /**
  69887. * Internal, matrix used to convert room space to babylon space
  69888. * @hidden
  69889. */
  69890. _deviceToWorld: Matrix;
  69891. /**
  69892. * Node to be used when casting a ray from the controller
  69893. * @hidden
  69894. */
  69895. _pointingPoseNode: Nullable<TransformNode>;
  69896. /**
  69897. * Name of the child mesh that can be used to cast a ray from the controller
  69898. */
  69899. static readonly POINTING_POSE: string;
  69900. /**
  69901. * Creates a new PoseEnabledController from a gamepad
  69902. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  69903. */
  69904. constructor(browserGamepad: any);
  69905. private _workingMatrix;
  69906. /**
  69907. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  69908. */
  69909. update(): void;
  69910. /**
  69911. * Updates only the pose device and mesh without doing any button event checking
  69912. */
  69913. protected _updatePoseAndMesh(): void;
  69914. /**
  69915. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  69916. * @param poseData raw pose fromthe device
  69917. */
  69918. updateFromDevice(poseData: DevicePose): void;
  69919. /**
  69920. * @hidden
  69921. */
  69922. _meshAttachedObservable: Observable<AbstractMesh>;
  69923. /**
  69924. * Attaches a mesh to the controller
  69925. * @param mesh the mesh to be attached
  69926. */
  69927. attachToMesh(mesh: AbstractMesh): void;
  69928. /**
  69929. * Attaches the controllers mesh to a camera
  69930. * @param camera the camera the mesh should be attached to
  69931. */
  69932. attachToPoseControlledCamera(camera: TargetCamera): void;
  69933. /**
  69934. * Disposes of the controller
  69935. */
  69936. dispose(): void;
  69937. /**
  69938. * The mesh that is attached to the controller
  69939. */
  69940. readonly mesh: Nullable<AbstractMesh>;
  69941. /**
  69942. * Gets the ray of the controller in the direction the controller is pointing
  69943. * @param length the length the resulting ray should be
  69944. * @returns a ray in the direction the controller is pointing
  69945. */
  69946. getForwardRay(length?: number): Ray;
  69947. }
  69948. }
  69949. declare module BABYLON {
  69950. /**
  69951. * Defines the WebVRController object that represents controllers tracked in 3D space
  69952. */
  69953. export abstract class WebVRController extends PoseEnabledController {
  69954. /**
  69955. * Internal, the default controller model for the controller
  69956. */
  69957. protected _defaultModel: AbstractMesh;
  69958. /**
  69959. * Fired when the trigger state has changed
  69960. */
  69961. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  69962. /**
  69963. * Fired when the main button state has changed
  69964. */
  69965. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69966. /**
  69967. * Fired when the secondary button state has changed
  69968. */
  69969. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69970. /**
  69971. * Fired when the pad state has changed
  69972. */
  69973. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  69974. /**
  69975. * Fired when controllers stick values have changed
  69976. */
  69977. onPadValuesChangedObservable: Observable<StickValues>;
  69978. /**
  69979. * Array of button availible on the controller
  69980. */
  69981. protected _buttons: Array<MutableGamepadButton>;
  69982. private _onButtonStateChange;
  69983. /**
  69984. * Fired when a controller button's state has changed
  69985. * @param callback the callback containing the button that was modified
  69986. */
  69987. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  69988. /**
  69989. * X and Y axis corrisponding to the controllers joystick
  69990. */
  69991. pad: StickValues;
  69992. /**
  69993. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  69994. */
  69995. hand: string;
  69996. /**
  69997. * The default controller model for the controller
  69998. */
  69999. readonly defaultModel: AbstractMesh;
  70000. /**
  70001. * Creates a new WebVRController from a gamepad
  70002. * @param vrGamepad the gamepad that the WebVRController should be created from
  70003. */
  70004. constructor(vrGamepad: any);
  70005. /**
  70006. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  70007. */
  70008. update(): void;
  70009. /**
  70010. * Function to be called when a button is modified
  70011. */
  70012. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  70013. /**
  70014. * Loads a mesh and attaches it to the controller
  70015. * @param scene the scene the mesh should be added to
  70016. * @param meshLoaded callback for when the mesh has been loaded
  70017. */
  70018. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  70019. private _setButtonValue;
  70020. private _changes;
  70021. private _checkChanges;
  70022. /**
  70023. * Disposes of th webVRCOntroller
  70024. */
  70025. dispose(): void;
  70026. }
  70027. }
  70028. declare module BABYLON {
  70029. /**
  70030. * The HemisphericLight simulates the ambient environment light,
  70031. * so the passed direction is the light reflection direction, not the incoming direction.
  70032. */
  70033. export class HemisphericLight extends Light {
  70034. /**
  70035. * The groundColor is the light in the opposite direction to the one specified during creation.
  70036. * 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.
  70037. */
  70038. groundColor: Color3;
  70039. /**
  70040. * The light reflection direction, not the incoming direction.
  70041. */
  70042. direction: Vector3;
  70043. /**
  70044. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  70045. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  70046. * The HemisphericLight can't cast shadows.
  70047. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70048. * @param name The friendly name of the light
  70049. * @param direction The direction of the light reflection
  70050. * @param scene The scene the light belongs to
  70051. */
  70052. constructor(name: string, direction: Vector3, scene: Scene);
  70053. protected _buildUniformLayout(): void;
  70054. /**
  70055. * Returns the string "HemisphericLight".
  70056. * @return The class name
  70057. */
  70058. getClassName(): string;
  70059. /**
  70060. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70061. * Returns the updated direction.
  70062. * @param target The target the direction should point to
  70063. * @return The computed direction
  70064. */
  70065. setDirectionToTarget(target: Vector3): Vector3;
  70066. /**
  70067. * Returns the shadow generator associated to the light.
  70068. * @returns Always null for hemispheric lights because it does not support shadows.
  70069. */
  70070. getShadowGenerator(): Nullable<IShadowGenerator>;
  70071. /**
  70072. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70073. * @param effect The effect to update
  70074. * @param lightIndex The index of the light in the effect to update
  70075. * @returns The hemispheric light
  70076. */
  70077. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70078. /**
  70079. * Computes the world matrix of the node
  70080. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70081. * @param useWasUpdatedFlag defines a reserved property
  70082. * @returns the world matrix
  70083. */
  70084. computeWorldMatrix(): Matrix;
  70085. /**
  70086. * Returns the integer 3.
  70087. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70088. */
  70089. getTypeID(): number;
  70090. /**
  70091. * Prepares the list of defines specific to the light type.
  70092. * @param defines the list of defines
  70093. * @param lightIndex defines the index of the light for the effect
  70094. */
  70095. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70096. }
  70097. }
  70098. declare module BABYLON {
  70099. /**
  70100. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70101. * IMPORTANT!! The data is right-hand data.
  70102. * @export
  70103. * @interface DevicePose
  70104. */
  70105. export interface DevicePose {
  70106. /**
  70107. * The position of the device, values in array are [x,y,z].
  70108. */
  70109. readonly position: Nullable<Float32Array>;
  70110. /**
  70111. * The linearVelocity of the device, values in array are [x,y,z].
  70112. */
  70113. readonly linearVelocity: Nullable<Float32Array>;
  70114. /**
  70115. * The linearAcceleration of the device, values in array are [x,y,z].
  70116. */
  70117. readonly linearAcceleration: Nullable<Float32Array>;
  70118. /**
  70119. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70120. */
  70121. readonly orientation: Nullable<Float32Array>;
  70122. /**
  70123. * The angularVelocity of the device, values in array are [x,y,z].
  70124. */
  70125. readonly angularVelocity: Nullable<Float32Array>;
  70126. /**
  70127. * The angularAcceleration of the device, values in array are [x,y,z].
  70128. */
  70129. readonly angularAcceleration: Nullable<Float32Array>;
  70130. }
  70131. /**
  70132. * Interface representing a pose controlled object in Babylon.
  70133. * A pose controlled object has both regular pose values as well as pose values
  70134. * from an external device such as a VR head mounted display
  70135. */
  70136. export interface PoseControlled {
  70137. /**
  70138. * The position of the object in babylon space.
  70139. */
  70140. position: Vector3;
  70141. /**
  70142. * The rotation quaternion of the object in babylon space.
  70143. */
  70144. rotationQuaternion: Quaternion;
  70145. /**
  70146. * The position of the device in babylon space.
  70147. */
  70148. devicePosition?: Vector3;
  70149. /**
  70150. * The rotation quaternion of the device in babylon space.
  70151. */
  70152. deviceRotationQuaternion: Quaternion;
  70153. /**
  70154. * The raw pose coming from the device.
  70155. */
  70156. rawPose: Nullable<DevicePose>;
  70157. /**
  70158. * The scale of the device to be used when translating from device space to babylon space.
  70159. */
  70160. deviceScaleFactor: number;
  70161. /**
  70162. * Updates the poseControlled values based on the input device pose.
  70163. * @param poseData the pose data to update the object with
  70164. */
  70165. updateFromDevice(poseData: DevicePose): void;
  70166. }
  70167. /**
  70168. * Set of options to customize the webVRCamera
  70169. */
  70170. export interface WebVROptions {
  70171. /**
  70172. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70173. */
  70174. trackPosition?: boolean;
  70175. /**
  70176. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70177. */
  70178. positionScale?: number;
  70179. /**
  70180. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70181. */
  70182. displayName?: string;
  70183. /**
  70184. * Should the native controller meshes be initialized. (default: true)
  70185. */
  70186. controllerMeshes?: boolean;
  70187. /**
  70188. * Creating a default HemiLight only on controllers. (default: true)
  70189. */
  70190. defaultLightingOnControllers?: boolean;
  70191. /**
  70192. * If you don't want to use the default VR button of the helper. (default: false)
  70193. */
  70194. useCustomVRButton?: boolean;
  70195. /**
  70196. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70197. */
  70198. customVRButton?: HTMLButtonElement;
  70199. /**
  70200. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70201. */
  70202. rayLength?: number;
  70203. /**
  70204. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70205. */
  70206. defaultHeight?: number;
  70207. }
  70208. /**
  70209. * This represents a WebVR camera.
  70210. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70211. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70212. */
  70213. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70214. private webVROptions;
  70215. /**
  70216. * @hidden
  70217. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70218. */
  70219. _vrDevice: any;
  70220. /**
  70221. * The rawPose of the vrDevice.
  70222. */
  70223. rawPose: Nullable<DevicePose>;
  70224. private _onVREnabled;
  70225. private _specsVersion;
  70226. private _attached;
  70227. private _frameData;
  70228. protected _descendants: Array<Node>;
  70229. private _deviceRoomPosition;
  70230. /** @hidden */
  70231. _deviceRoomRotationQuaternion: Quaternion;
  70232. private _standingMatrix;
  70233. /**
  70234. * Represents device position in babylon space.
  70235. */
  70236. devicePosition: Vector3;
  70237. /**
  70238. * Represents device rotation in babylon space.
  70239. */
  70240. deviceRotationQuaternion: Quaternion;
  70241. /**
  70242. * The scale of the device to be used when translating from device space to babylon space.
  70243. */
  70244. deviceScaleFactor: number;
  70245. private _deviceToWorld;
  70246. private _worldToDevice;
  70247. /**
  70248. * References to the webVR controllers for the vrDevice.
  70249. */
  70250. controllers: Array<WebVRController>;
  70251. /**
  70252. * Emits an event when a controller is attached.
  70253. */
  70254. onControllersAttachedObservable: Observable<WebVRController[]>;
  70255. /**
  70256. * Emits an event when a controller's mesh has been loaded;
  70257. */
  70258. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70259. /**
  70260. * Emits an event when the HMD's pose has been updated.
  70261. */
  70262. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70263. private _poseSet;
  70264. /**
  70265. * If the rig cameras be used as parent instead of this camera.
  70266. */
  70267. rigParenting: boolean;
  70268. private _lightOnControllers;
  70269. private _defaultHeight?;
  70270. /**
  70271. * Instantiates a WebVRFreeCamera.
  70272. * @param name The name of the WebVRFreeCamera
  70273. * @param position The starting anchor position for the camera
  70274. * @param scene The scene the camera belongs to
  70275. * @param webVROptions a set of customizable options for the webVRCamera
  70276. */
  70277. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70278. /**
  70279. * Gets the device distance from the ground in meters.
  70280. * @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.
  70281. */
  70282. deviceDistanceToRoomGround(): number;
  70283. /**
  70284. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70285. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70286. */
  70287. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70288. /**
  70289. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70290. * @returns A promise with a boolean set to if the standing matrix is supported.
  70291. */
  70292. useStandingMatrixAsync(): Promise<boolean>;
  70293. /**
  70294. * Disposes the camera
  70295. */
  70296. dispose(): void;
  70297. /**
  70298. * Gets a vrController by name.
  70299. * @param name The name of the controller to retreive
  70300. * @returns the controller matching the name specified or null if not found
  70301. */
  70302. getControllerByName(name: string): Nullable<WebVRController>;
  70303. private _leftController;
  70304. /**
  70305. * The controller corrisponding to the users left hand.
  70306. */
  70307. readonly leftController: Nullable<WebVRController>;
  70308. private _rightController;
  70309. /**
  70310. * The controller corrisponding to the users right hand.
  70311. */
  70312. readonly rightController: Nullable<WebVRController>;
  70313. /**
  70314. * Casts a ray forward from the vrCamera's gaze.
  70315. * @param length Length of the ray (default: 100)
  70316. * @returns the ray corrisponding to the gaze
  70317. */
  70318. getForwardRay(length?: number): Ray;
  70319. /**
  70320. * @hidden
  70321. * Updates the camera based on device's frame data
  70322. */
  70323. _checkInputs(): void;
  70324. /**
  70325. * Updates the poseControlled values based on the input device pose.
  70326. * @param poseData Pose coming from the device
  70327. */
  70328. updateFromDevice(poseData: DevicePose): void;
  70329. private _htmlElementAttached;
  70330. private _detachIfAttached;
  70331. /**
  70332. * WebVR's attach control will start broadcasting frames to the device.
  70333. * Note that in certain browsers (chrome for example) this function must be called
  70334. * within a user-interaction callback. Example:
  70335. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70336. *
  70337. * @param element html element to attach the vrDevice to
  70338. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70339. */
  70340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70341. /**
  70342. * Detaches the camera from the html element and disables VR
  70343. *
  70344. * @param element html element to detach from
  70345. */
  70346. detachControl(element: HTMLElement): void;
  70347. /**
  70348. * @returns the name of this class
  70349. */
  70350. getClassName(): string;
  70351. /**
  70352. * Calls resetPose on the vrDisplay
  70353. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70354. */
  70355. resetToCurrentRotation(): void;
  70356. /**
  70357. * @hidden
  70358. * Updates the rig cameras (left and right eye)
  70359. */
  70360. _updateRigCameras(): void;
  70361. private _workingVector;
  70362. private _oneVector;
  70363. private _workingMatrix;
  70364. private updateCacheCalled;
  70365. private _correctPositionIfNotTrackPosition;
  70366. /**
  70367. * @hidden
  70368. * Updates the cached values of the camera
  70369. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70370. */
  70371. _updateCache(ignoreParentClass?: boolean): void;
  70372. /**
  70373. * @hidden
  70374. * Get current device position in babylon world
  70375. */
  70376. _computeDevicePosition(): void;
  70377. /**
  70378. * Updates the current device position and rotation in the babylon world
  70379. */
  70380. update(): void;
  70381. /**
  70382. * @hidden
  70383. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70384. * @returns an identity matrix
  70385. */
  70386. _getViewMatrix(): Matrix;
  70387. private _tmpMatrix;
  70388. /**
  70389. * This function is called by the two RIG cameras.
  70390. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  70391. * @hidden
  70392. */
  70393. _getWebVRViewMatrix(): Matrix;
  70394. /** @hidden */
  70395. _getWebVRProjectionMatrix(): Matrix;
  70396. private _onGamepadConnectedObserver;
  70397. private _onGamepadDisconnectedObserver;
  70398. private _updateCacheWhenTrackingDisabledObserver;
  70399. /**
  70400. * Initializes the controllers and their meshes
  70401. */
  70402. initControllers(): void;
  70403. }
  70404. }
  70405. declare module BABYLON {
  70406. /**
  70407. * Size options for a post process
  70408. */
  70409. export type PostProcessOptions = {
  70410. width: number;
  70411. height: number;
  70412. };
  70413. /**
  70414. * PostProcess can be used to apply a shader to a texture after it has been rendered
  70415. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70416. */
  70417. export class PostProcess {
  70418. /** Name of the PostProcess. */
  70419. name: string;
  70420. /**
  70421. * Gets or sets the unique id of the post process
  70422. */
  70423. uniqueId: number;
  70424. /**
  70425. * Width of the texture to apply the post process on
  70426. */
  70427. width: number;
  70428. /**
  70429. * Height of the texture to apply the post process on
  70430. */
  70431. height: number;
  70432. /**
  70433. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  70434. * @hidden
  70435. */
  70436. _outputTexture: Nullable<InternalTexture>;
  70437. /**
  70438. * Sampling mode used by the shader
  70439. * See https://doc.babylonjs.com/classes/3.1/texture
  70440. */
  70441. renderTargetSamplingMode: number;
  70442. /**
  70443. * Clear color to use when screen clearing
  70444. */
  70445. clearColor: Color4;
  70446. /**
  70447. * If the buffer needs to be cleared before applying the post process. (default: true)
  70448. * Should be set to false if shader will overwrite all previous pixels.
  70449. */
  70450. autoClear: boolean;
  70451. /**
  70452. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  70453. */
  70454. alphaMode: number;
  70455. /**
  70456. * Sets the setAlphaBlendConstants of the babylon engine
  70457. */
  70458. alphaConstants: Color4;
  70459. /**
  70460. * Animations to be used for the post processing
  70461. */
  70462. animations: Animation[];
  70463. /**
  70464. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  70465. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  70466. */
  70467. enablePixelPerfectMode: boolean;
  70468. /**
  70469. * Force the postprocess to be applied without taking in account viewport
  70470. */
  70471. forceFullscreenViewport: boolean;
  70472. /**
  70473. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  70474. *
  70475. * | Value | Type | Description |
  70476. * | ----- | ----------------------------------- | ----------- |
  70477. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  70478. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  70479. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  70480. *
  70481. */
  70482. scaleMode: number;
  70483. /**
  70484. * Force textures to be a power of two (default: false)
  70485. */
  70486. alwaysForcePOT: boolean;
  70487. private _samples;
  70488. /**
  70489. * Number of sample textures (default: 1)
  70490. */
  70491. samples: number;
  70492. /**
  70493. * Modify the scale of the post process to be the same as the viewport (default: false)
  70494. */
  70495. adaptScaleToCurrentViewport: boolean;
  70496. private _camera;
  70497. private _scene;
  70498. private _engine;
  70499. private _options;
  70500. private _reusable;
  70501. private _textureType;
  70502. /**
  70503. * Smart array of input and output textures for the post process.
  70504. * @hidden
  70505. */
  70506. _textures: SmartArray<InternalTexture>;
  70507. /**
  70508. * The index in _textures that corresponds to the output texture.
  70509. * @hidden
  70510. */
  70511. _currentRenderTextureInd: number;
  70512. private _effect;
  70513. private _samplers;
  70514. private _fragmentUrl;
  70515. private _vertexUrl;
  70516. private _parameters;
  70517. private _scaleRatio;
  70518. protected _indexParameters: any;
  70519. private _shareOutputWithPostProcess;
  70520. private _texelSize;
  70521. private _forcedOutputTexture;
  70522. /**
  70523. * Returns the fragment url or shader name used in the post process.
  70524. * @returns the fragment url or name in the shader store.
  70525. */
  70526. getEffectName(): string;
  70527. /**
  70528. * An event triggered when the postprocess is activated.
  70529. */
  70530. onActivateObservable: Observable<Camera>;
  70531. private _onActivateObserver;
  70532. /**
  70533. * A function that is added to the onActivateObservable
  70534. */
  70535. onActivate: Nullable<(camera: Camera) => void>;
  70536. /**
  70537. * An event triggered when the postprocess changes its size.
  70538. */
  70539. onSizeChangedObservable: Observable<PostProcess>;
  70540. private _onSizeChangedObserver;
  70541. /**
  70542. * A function that is added to the onSizeChangedObservable
  70543. */
  70544. onSizeChanged: (postProcess: PostProcess) => void;
  70545. /**
  70546. * An event triggered when the postprocess applies its effect.
  70547. */
  70548. onApplyObservable: Observable<Effect>;
  70549. private _onApplyObserver;
  70550. /**
  70551. * A function that is added to the onApplyObservable
  70552. */
  70553. onApply: (effect: Effect) => void;
  70554. /**
  70555. * An event triggered before rendering the postprocess
  70556. */
  70557. onBeforeRenderObservable: Observable<Effect>;
  70558. private _onBeforeRenderObserver;
  70559. /**
  70560. * A function that is added to the onBeforeRenderObservable
  70561. */
  70562. onBeforeRender: (effect: Effect) => void;
  70563. /**
  70564. * An event triggered after rendering the postprocess
  70565. */
  70566. onAfterRenderObservable: Observable<Effect>;
  70567. private _onAfterRenderObserver;
  70568. /**
  70569. * A function that is added to the onAfterRenderObservable
  70570. */
  70571. onAfterRender: (efect: Effect) => void;
  70572. /**
  70573. * 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
  70574. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  70575. */
  70576. inputTexture: InternalTexture;
  70577. /**
  70578. * Gets the camera which post process is applied to.
  70579. * @returns The camera the post process is applied to.
  70580. */
  70581. getCamera(): Camera;
  70582. /**
  70583. * Gets the texel size of the postprocess.
  70584. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  70585. */
  70586. readonly texelSize: Vector2;
  70587. /**
  70588. * Creates a new instance PostProcess
  70589. * @param name The name of the PostProcess.
  70590. * @param fragmentUrl The url of the fragment shader to be used.
  70591. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70592. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70593. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70594. * @param camera The camera to apply the render pass to.
  70595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70596. * @param engine The engine which the post process will be applied. (default: current engine)
  70597. * @param reusable If the post process can be reused on the same frame. (default: false)
  70598. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70599. * @param textureType Type of textures used when performing the post process. (default: 0)
  70600. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70601. * @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
  70602. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70603. */
  70604. constructor(
  70605. /** Name of the PostProcess. */
  70606. 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);
  70607. /**
  70608. * Gets a string idenfifying the name of the class
  70609. * @returns "PostProcess" string
  70610. */
  70611. getClassName(): string;
  70612. /**
  70613. * Gets the engine which this post process belongs to.
  70614. * @returns The engine the post process was enabled with.
  70615. */
  70616. getEngine(): Engine;
  70617. /**
  70618. * The effect that is created when initializing the post process.
  70619. * @returns The created effect corrisponding the the postprocess.
  70620. */
  70621. getEffect(): Effect;
  70622. /**
  70623. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70624. * @param postProcess The post process to share the output with.
  70625. * @returns This post process.
  70626. */
  70627. shareOutputWith(postProcess: PostProcess): PostProcess;
  70628. /**
  70629. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70630. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70631. */
  70632. useOwnOutput(): void;
  70633. /**
  70634. * Updates the effect with the current post process compile time values and recompiles the shader.
  70635. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70636. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70637. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70638. * @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
  70639. * @param onCompiled Called when the shader has been compiled.
  70640. * @param onError Called if there is an error when compiling a shader.
  70641. */
  70642. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70643. /**
  70644. * The post process is reusable if it can be used multiple times within one frame.
  70645. * @returns If the post process is reusable
  70646. */
  70647. isReusable(): boolean;
  70648. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70649. markTextureDirty(): void;
  70650. /**
  70651. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70652. * 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.
  70653. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70654. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70655. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70656. * @returns The target texture that was bound to be written to.
  70657. */
  70658. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70659. /**
  70660. * If the post process is supported.
  70661. */
  70662. readonly isSupported: boolean;
  70663. /**
  70664. * The aspect ratio of the output texture.
  70665. */
  70666. readonly aspectRatio: number;
  70667. /**
  70668. * Get a value indicating if the post-process is ready to be used
  70669. * @returns true if the post-process is ready (shader is compiled)
  70670. */
  70671. isReady(): boolean;
  70672. /**
  70673. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70674. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70675. */
  70676. apply(): Nullable<Effect>;
  70677. private _disposeTextures;
  70678. /**
  70679. * Disposes the post process.
  70680. * @param camera The camera to dispose the post process on.
  70681. */
  70682. dispose(camera?: Camera): void;
  70683. }
  70684. }
  70685. declare module BABYLON {
  70686. /**
  70687. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70688. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70689. */
  70690. export class PostProcessManager {
  70691. private _scene;
  70692. private _indexBuffer;
  70693. private _vertexBuffers;
  70694. /**
  70695. * Creates a new instance PostProcess
  70696. * @param scene The scene that the post process is associated with.
  70697. */
  70698. constructor(scene: Scene);
  70699. private _prepareBuffers;
  70700. private _buildIndexBuffer;
  70701. /**
  70702. * Rebuilds the vertex buffers of the manager.
  70703. * @hidden
  70704. */
  70705. _rebuild(): void;
  70706. /**
  70707. * Prepares a frame to be run through a post process.
  70708. * @param sourceTexture The input texture to the post procesess. (default: null)
  70709. * @param postProcesses An array of post processes to be run. (default: null)
  70710. * @returns True if the post processes were able to be run.
  70711. * @hidden
  70712. */
  70713. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70714. /**
  70715. * Manually render a set of post processes to a texture.
  70716. * @param postProcesses An array of post processes to be run.
  70717. * @param targetTexture The target texture to render to.
  70718. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70719. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70720. * @param lodLevel defines which lod of the texture to render to
  70721. */
  70722. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70723. /**
  70724. * Finalize the result of the output of the postprocesses.
  70725. * @param doNotPresent If true the result will not be displayed to the screen.
  70726. * @param targetTexture The target texture to render to.
  70727. * @param faceIndex The index of the face to bind the target texture to.
  70728. * @param postProcesses The array of post processes to render.
  70729. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70730. * @hidden
  70731. */
  70732. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  70733. /**
  70734. * Disposes of the post process manager.
  70735. */
  70736. dispose(): void;
  70737. }
  70738. }
  70739. declare module BABYLON {
  70740. interface AbstractScene {
  70741. /**
  70742. * The list of layers (background and foreground) of the scene
  70743. */
  70744. layers: Array<Layer>;
  70745. }
  70746. /**
  70747. * Defines the layer scene component responsible to manage any layers
  70748. * in a given scene.
  70749. */
  70750. export class LayerSceneComponent implements ISceneComponent {
  70751. /**
  70752. * The component name helpfull to identify the component in the list of scene components.
  70753. */
  70754. readonly name: string;
  70755. /**
  70756. * The scene the component belongs to.
  70757. */
  70758. scene: Scene;
  70759. private _engine;
  70760. /**
  70761. * Creates a new instance of the component for the given scene
  70762. * @param scene Defines the scene to register the component in
  70763. */
  70764. constructor(scene: Scene);
  70765. /**
  70766. * Registers the component in a given scene
  70767. */
  70768. register(): void;
  70769. /**
  70770. * Rebuilds the elements related to this component in case of
  70771. * context lost for instance.
  70772. */
  70773. rebuild(): void;
  70774. /**
  70775. * Disposes the component and the associated ressources.
  70776. */
  70777. dispose(): void;
  70778. private _draw;
  70779. private _drawCameraPredicate;
  70780. private _drawCameraBackground;
  70781. private _drawCameraForeground;
  70782. private _drawRenderTargetPredicate;
  70783. private _drawRenderTargetBackground;
  70784. private _drawRenderTargetForeground;
  70785. }
  70786. }
  70787. declare module BABYLON {
  70788. /** @hidden */
  70789. export var layerPixelShader: {
  70790. name: string;
  70791. shader: string;
  70792. };
  70793. }
  70794. declare module BABYLON {
  70795. /** @hidden */
  70796. export var layerVertexShader: {
  70797. name: string;
  70798. shader: string;
  70799. };
  70800. }
  70801. declare module BABYLON {
  70802. /**
  70803. * This represents a full screen 2d layer.
  70804. * This can be useful to display a picture in the background of your scene for instance.
  70805. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70806. */
  70807. export class Layer {
  70808. /**
  70809. * Define the name of the layer.
  70810. */
  70811. name: string;
  70812. /**
  70813. * Define the texture the layer should display.
  70814. */
  70815. texture: Nullable<Texture>;
  70816. /**
  70817. * Is the layer in background or foreground.
  70818. */
  70819. isBackground: boolean;
  70820. /**
  70821. * Define the color of the layer (instead of texture).
  70822. */
  70823. color: Color4;
  70824. /**
  70825. * Define the scale of the layer in order to zoom in out of the texture.
  70826. */
  70827. scale: Vector2;
  70828. /**
  70829. * Define an offset for the layer in order to shift the texture.
  70830. */
  70831. offset: Vector2;
  70832. /**
  70833. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  70834. */
  70835. alphaBlendingMode: number;
  70836. /**
  70837. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  70838. * Alpha test will not mix with the background color in case of transparency.
  70839. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  70840. */
  70841. alphaTest: boolean;
  70842. /**
  70843. * Define a mask to restrict the layer to only some of the scene cameras.
  70844. */
  70845. layerMask: number;
  70846. /**
  70847. * Define the list of render target the layer is visible into.
  70848. */
  70849. renderTargetTextures: RenderTargetTexture[];
  70850. /**
  70851. * Define if the layer is only used in renderTarget or if it also
  70852. * renders in the main frame buffer of the canvas.
  70853. */
  70854. renderOnlyInRenderTargetTextures: boolean;
  70855. private _scene;
  70856. private _vertexBuffers;
  70857. private _indexBuffer;
  70858. private _effect;
  70859. private _alphaTestEffect;
  70860. /**
  70861. * An event triggered when the layer is disposed.
  70862. */
  70863. onDisposeObservable: Observable<Layer>;
  70864. private _onDisposeObserver;
  70865. /**
  70866. * Back compatibility with callback before the onDisposeObservable existed.
  70867. * The set callback will be triggered when the layer has been disposed.
  70868. */
  70869. onDispose: () => void;
  70870. /**
  70871. * An event triggered before rendering the scene
  70872. */
  70873. onBeforeRenderObservable: Observable<Layer>;
  70874. private _onBeforeRenderObserver;
  70875. /**
  70876. * Back compatibility with callback before the onBeforeRenderObservable existed.
  70877. * The set callback will be triggered just before rendering the layer.
  70878. */
  70879. onBeforeRender: () => void;
  70880. /**
  70881. * An event triggered after rendering the scene
  70882. */
  70883. onAfterRenderObservable: Observable<Layer>;
  70884. private _onAfterRenderObserver;
  70885. /**
  70886. * Back compatibility with callback before the onAfterRenderObservable existed.
  70887. * The set callback will be triggered just after rendering the layer.
  70888. */
  70889. onAfterRender: () => void;
  70890. /**
  70891. * Instantiates a new layer.
  70892. * This represents a full screen 2d layer.
  70893. * This can be useful to display a picture in the background of your scene for instance.
  70894. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70895. * @param name Define the name of the layer in the scene
  70896. * @param imgUrl Define the url of the texture to display in the layer
  70897. * @param scene Define the scene the layer belongs to
  70898. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  70899. * @param color Defines a color for the layer
  70900. */
  70901. constructor(
  70902. /**
  70903. * Define the name of the layer.
  70904. */
  70905. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  70906. private _createIndexBuffer;
  70907. /** @hidden */
  70908. _rebuild(): void;
  70909. /**
  70910. * Renders the layer in the scene.
  70911. */
  70912. render(): void;
  70913. /**
  70914. * Disposes and releases the associated ressources.
  70915. */
  70916. dispose(): void;
  70917. }
  70918. }
  70919. declare module BABYLON {
  70920. interface AbstractScene {
  70921. /**
  70922. * The list of procedural textures added to the scene
  70923. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70924. */
  70925. proceduralTextures: Array<ProceduralTexture>;
  70926. }
  70927. /**
  70928. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  70929. * in a given scene.
  70930. */
  70931. export class ProceduralTextureSceneComponent implements ISceneComponent {
  70932. /**
  70933. * The component name helpfull to identify the component in the list of scene components.
  70934. */
  70935. readonly name: string;
  70936. /**
  70937. * The scene the component belongs to.
  70938. */
  70939. scene: Scene;
  70940. /**
  70941. * Creates a new instance of the component for the given scene
  70942. * @param scene Defines the scene to register the component in
  70943. */
  70944. constructor(scene: Scene);
  70945. /**
  70946. * Registers the component in a given scene
  70947. */
  70948. register(): void;
  70949. /**
  70950. * Rebuilds the elements related to this component in case of
  70951. * context lost for instance.
  70952. */
  70953. rebuild(): void;
  70954. /**
  70955. * Disposes the component and the associated ressources.
  70956. */
  70957. dispose(): void;
  70958. private _beforeClear;
  70959. }
  70960. }
  70961. declare module BABYLON {
  70962. /** @hidden */
  70963. export var proceduralVertexShader: {
  70964. name: string;
  70965. shader: string;
  70966. };
  70967. }
  70968. declare module BABYLON {
  70969. /**
  70970. * 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.
  70971. * This is the base class of any Procedural texture and contains most of the shareable code.
  70972. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70973. */
  70974. export class ProceduralTexture extends Texture {
  70975. isCube: boolean;
  70976. /**
  70977. * Define if the texture is enabled or not (disabled texture will not render)
  70978. */
  70979. isEnabled: boolean;
  70980. /**
  70981. * Define if the texture must be cleared before rendering (default is true)
  70982. */
  70983. autoClear: boolean;
  70984. /**
  70985. * Callback called when the texture is generated
  70986. */
  70987. onGenerated: () => void;
  70988. /**
  70989. * Event raised when the texture is generated
  70990. */
  70991. onGeneratedObservable: Observable<ProceduralTexture>;
  70992. /** @hidden */
  70993. _generateMipMaps: boolean;
  70994. /** @hidden **/
  70995. _effect: Effect;
  70996. /** @hidden */
  70997. _textures: {
  70998. [key: string]: Texture;
  70999. };
  71000. private _size;
  71001. private _currentRefreshId;
  71002. private _refreshRate;
  71003. private _vertexBuffers;
  71004. private _indexBuffer;
  71005. private _uniforms;
  71006. private _samplers;
  71007. private _fragment;
  71008. private _floats;
  71009. private _ints;
  71010. private _floatsArrays;
  71011. private _colors3;
  71012. private _colors4;
  71013. private _vectors2;
  71014. private _vectors3;
  71015. private _matrices;
  71016. private _fallbackTexture;
  71017. private _fallbackTextureUsed;
  71018. private _engine;
  71019. private _cachedDefines;
  71020. private _contentUpdateId;
  71021. private _contentData;
  71022. /**
  71023. * Instantiates a new procedural texture.
  71024. * 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.
  71025. * This is the base class of any Procedural texture and contains most of the shareable code.
  71026. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71027. * @param name Define the name of the texture
  71028. * @param size Define the size of the texture to create
  71029. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  71030. * @param scene Define the scene the texture belongs to
  71031. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  71032. * @param generateMipMaps Define if the texture should creates mip maps or not
  71033. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  71034. */
  71035. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  71036. /**
  71037. * The effect that is created when initializing the post process.
  71038. * @returns The created effect corrisponding the the postprocess.
  71039. */
  71040. getEffect(): Effect;
  71041. /**
  71042. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  71043. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  71044. */
  71045. getContent(): Nullable<ArrayBufferView>;
  71046. private _createIndexBuffer;
  71047. /** @hidden */
  71048. _rebuild(): void;
  71049. /**
  71050. * Resets the texture in order to recreate its associated resources.
  71051. * This can be called in case of context loss
  71052. */
  71053. reset(): void;
  71054. protected _getDefines(): string;
  71055. /**
  71056. * Is the texture ready to be used ? (rendered at least once)
  71057. * @returns true if ready, otherwise, false.
  71058. */
  71059. isReady(): boolean;
  71060. /**
  71061. * Resets the refresh counter of the texture and start bak from scratch.
  71062. * Could be useful to regenerate the texture if it is setup to render only once.
  71063. */
  71064. resetRefreshCounter(): void;
  71065. /**
  71066. * Set the fragment shader to use in order to render the texture.
  71067. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71068. */
  71069. setFragment(fragment: any): void;
  71070. /**
  71071. * Define the refresh rate of the texture or the rendering frequency.
  71072. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71073. */
  71074. refreshRate: number;
  71075. /** @hidden */
  71076. _shouldRender(): boolean;
  71077. /**
  71078. * Get the size the texture is rendering at.
  71079. * @returns the size (texture is always squared)
  71080. */
  71081. getRenderSize(): number;
  71082. /**
  71083. * Resize the texture to new value.
  71084. * @param size Define the new size the texture should have
  71085. * @param generateMipMaps Define whether the new texture should create mip maps
  71086. */
  71087. resize(size: number, generateMipMaps: boolean): void;
  71088. private _checkUniform;
  71089. /**
  71090. * Set a texture in the shader program used to render.
  71091. * @param name Define the name of the uniform samplers as defined in the shader
  71092. * @param texture Define the texture to bind to this sampler
  71093. * @return the texture itself allowing "fluent" like uniform updates
  71094. */
  71095. setTexture(name: string, texture: Texture): ProceduralTexture;
  71096. /**
  71097. * Set a float in the shader.
  71098. * @param name Define the name of the uniform as defined in the shader
  71099. * @param value Define the value to give to the uniform
  71100. * @return the texture itself allowing "fluent" like uniform updates
  71101. */
  71102. setFloat(name: string, value: number): ProceduralTexture;
  71103. /**
  71104. * Set a int in the shader.
  71105. * @param name Define the name of the uniform as defined in the shader
  71106. * @param value Define the value to give to the uniform
  71107. * @return the texture itself allowing "fluent" like uniform updates
  71108. */
  71109. setInt(name: string, value: number): ProceduralTexture;
  71110. /**
  71111. * Set an array of floats in the shader.
  71112. * @param name Define the name of the uniform as defined in the shader
  71113. * @param value Define the value to give to the uniform
  71114. * @return the texture itself allowing "fluent" like uniform updates
  71115. */
  71116. setFloats(name: string, value: number[]): ProceduralTexture;
  71117. /**
  71118. * Set a vec3 in the shader from a Color3.
  71119. * @param name Define the name of the uniform as defined in the shader
  71120. * @param value Define the value to give to the uniform
  71121. * @return the texture itself allowing "fluent" like uniform updates
  71122. */
  71123. setColor3(name: string, value: Color3): ProceduralTexture;
  71124. /**
  71125. * Set a vec4 in the shader from a Color4.
  71126. * @param name Define the name of the uniform as defined in the shader
  71127. * @param value Define the value to give to the uniform
  71128. * @return the texture itself allowing "fluent" like uniform updates
  71129. */
  71130. setColor4(name: string, value: Color4): ProceduralTexture;
  71131. /**
  71132. * Set a vec2 in the shader from a Vector2.
  71133. * @param name Define the name of the uniform as defined in the shader
  71134. * @param value Define the value to give to the uniform
  71135. * @return the texture itself allowing "fluent" like uniform updates
  71136. */
  71137. setVector2(name: string, value: Vector2): ProceduralTexture;
  71138. /**
  71139. * Set a vec3 in the shader from a Vector3.
  71140. * @param name Define the name of the uniform as defined in the shader
  71141. * @param value Define the value to give to the uniform
  71142. * @return the texture itself allowing "fluent" like uniform updates
  71143. */
  71144. setVector3(name: string, value: Vector3): ProceduralTexture;
  71145. /**
  71146. * Set a mat4 in the shader from a MAtrix.
  71147. * @param name Define the name of the uniform as defined in the shader
  71148. * @param value Define the value to give to the uniform
  71149. * @return the texture itself allowing "fluent" like uniform updates
  71150. */
  71151. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71152. /**
  71153. * Render the texture to its associated render target.
  71154. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71155. */
  71156. render(useCameraPostProcess?: boolean): void;
  71157. /**
  71158. * Clone the texture.
  71159. * @returns the cloned texture
  71160. */
  71161. clone(): ProceduralTexture;
  71162. /**
  71163. * Dispose the texture and release its asoociated resources.
  71164. */
  71165. dispose(): void;
  71166. }
  71167. }
  71168. declare module BABYLON {
  71169. /**
  71170. * This represents the base class for particle system in Babylon.
  71171. * 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.
  71172. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71173. * @example https://doc.babylonjs.com/babylon101/particles
  71174. */
  71175. export class BaseParticleSystem {
  71176. /**
  71177. * Source color is added to the destination color without alpha affecting the result
  71178. */
  71179. static BLENDMODE_ONEONE: number;
  71180. /**
  71181. * Blend current color and particle color using particle’s alpha
  71182. */
  71183. static BLENDMODE_STANDARD: number;
  71184. /**
  71185. * Add current color and particle color multiplied by particle’s alpha
  71186. */
  71187. static BLENDMODE_ADD: number;
  71188. /**
  71189. * Multiply current color with particle color
  71190. */
  71191. static BLENDMODE_MULTIPLY: number;
  71192. /**
  71193. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71194. */
  71195. static BLENDMODE_MULTIPLYADD: number;
  71196. /**
  71197. * List of animations used by the particle system.
  71198. */
  71199. animations: Animation[];
  71200. /**
  71201. * The id of the Particle system.
  71202. */
  71203. id: string;
  71204. /**
  71205. * The friendly name of the Particle system.
  71206. */
  71207. name: string;
  71208. /**
  71209. * The rendering group used by the Particle system to chose when to render.
  71210. */
  71211. renderingGroupId: number;
  71212. /**
  71213. * The emitter represents the Mesh or position we are attaching the particle system to.
  71214. */
  71215. emitter: Nullable<AbstractMesh | Vector3>;
  71216. /**
  71217. * The maximum number of particles to emit per frame
  71218. */
  71219. emitRate: number;
  71220. /**
  71221. * If you want to launch only a few particles at once, that can be done, as well.
  71222. */
  71223. manualEmitCount: number;
  71224. /**
  71225. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71226. */
  71227. updateSpeed: number;
  71228. /**
  71229. * The amount of time the particle system is running (depends of the overall update speed).
  71230. */
  71231. targetStopDuration: number;
  71232. /**
  71233. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71234. */
  71235. disposeOnStop: boolean;
  71236. /**
  71237. * Minimum power of emitting particles.
  71238. */
  71239. minEmitPower: number;
  71240. /**
  71241. * Maximum power of emitting particles.
  71242. */
  71243. maxEmitPower: number;
  71244. /**
  71245. * Minimum life time of emitting particles.
  71246. */
  71247. minLifeTime: number;
  71248. /**
  71249. * Maximum life time of emitting particles.
  71250. */
  71251. maxLifeTime: number;
  71252. /**
  71253. * Minimum Size of emitting particles.
  71254. */
  71255. minSize: number;
  71256. /**
  71257. * Maximum Size of emitting particles.
  71258. */
  71259. maxSize: number;
  71260. /**
  71261. * Minimum scale of emitting particles on X axis.
  71262. */
  71263. minScaleX: number;
  71264. /**
  71265. * Maximum scale of emitting particles on X axis.
  71266. */
  71267. maxScaleX: number;
  71268. /**
  71269. * Minimum scale of emitting particles on Y axis.
  71270. */
  71271. minScaleY: number;
  71272. /**
  71273. * Maximum scale of emitting particles on Y axis.
  71274. */
  71275. maxScaleY: number;
  71276. /**
  71277. * Gets or sets the minimal initial rotation in radians.
  71278. */
  71279. minInitialRotation: number;
  71280. /**
  71281. * Gets or sets the maximal initial rotation in radians.
  71282. */
  71283. maxInitialRotation: number;
  71284. /**
  71285. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71286. */
  71287. minAngularSpeed: number;
  71288. /**
  71289. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71290. */
  71291. maxAngularSpeed: number;
  71292. /**
  71293. * The texture used to render each particle. (this can be a spritesheet)
  71294. */
  71295. particleTexture: Nullable<Texture>;
  71296. /**
  71297. * The layer mask we are rendering the particles through.
  71298. */
  71299. layerMask: number;
  71300. /**
  71301. * This can help using your own shader to render the particle system.
  71302. * The according effect will be created
  71303. */
  71304. customShader: any;
  71305. /**
  71306. * By default particle system starts as soon as they are created. This prevents the
  71307. * automatic start to happen and let you decide when to start emitting particles.
  71308. */
  71309. preventAutoStart: boolean;
  71310. private _noiseTexture;
  71311. /**
  71312. * Gets or sets a texture used to add random noise to particle positions
  71313. */
  71314. noiseTexture: Nullable<ProceduralTexture>;
  71315. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71316. noiseStrength: Vector3;
  71317. /**
  71318. * Callback triggered when the particle animation is ending.
  71319. */
  71320. onAnimationEnd: Nullable<() => void>;
  71321. /**
  71322. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71323. */
  71324. blendMode: number;
  71325. /**
  71326. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71327. * to override the particles.
  71328. */
  71329. forceDepthWrite: boolean;
  71330. /** 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 */
  71331. preWarmCycles: number;
  71332. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71333. preWarmStepOffset: number;
  71334. /**
  71335. * 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)
  71336. */
  71337. spriteCellChangeSpeed: number;
  71338. /**
  71339. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71340. */
  71341. startSpriteCellID: number;
  71342. /**
  71343. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71344. */
  71345. endSpriteCellID: number;
  71346. /**
  71347. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71348. */
  71349. spriteCellWidth: number;
  71350. /**
  71351. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71352. */
  71353. spriteCellHeight: number;
  71354. /**
  71355. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71356. */
  71357. spriteRandomStartCell: boolean;
  71358. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71359. translationPivot: Vector2;
  71360. /** @hidden */
  71361. protected _isAnimationSheetEnabled: boolean;
  71362. /**
  71363. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71364. */
  71365. beginAnimationOnStart: boolean;
  71366. /**
  71367. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71368. */
  71369. beginAnimationFrom: number;
  71370. /**
  71371. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71372. */
  71373. beginAnimationTo: number;
  71374. /**
  71375. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71376. */
  71377. beginAnimationLoop: boolean;
  71378. /**
  71379. * Gets or sets a world offset applied to all particles
  71380. */
  71381. worldOffset: Vector3;
  71382. /**
  71383. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71384. */
  71385. isAnimationSheetEnabled: boolean;
  71386. /**
  71387. * Get hosting scene
  71388. * @returns the scene
  71389. */
  71390. getScene(): Scene;
  71391. /**
  71392. * You can use gravity if you want to give an orientation to your particles.
  71393. */
  71394. gravity: Vector3;
  71395. protected _colorGradients: Nullable<Array<ColorGradient>>;
  71396. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  71397. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  71398. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  71399. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  71400. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  71401. protected _dragGradients: Nullable<Array<FactorGradient>>;
  71402. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  71403. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  71404. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  71405. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  71406. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  71407. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  71408. /**
  71409. * Defines the delay in milliseconds before starting the system (0 by default)
  71410. */
  71411. startDelay: number;
  71412. /**
  71413. * Gets the current list of drag gradients.
  71414. * You must use addDragGradient and removeDragGradient to udpate this list
  71415. * @returns the list of drag gradients
  71416. */
  71417. getDragGradients(): Nullable<Array<FactorGradient>>;
  71418. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71419. limitVelocityDamping: number;
  71420. /**
  71421. * Gets the current list of limit velocity gradients.
  71422. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71423. * @returns the list of limit velocity gradients
  71424. */
  71425. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71426. /**
  71427. * Gets the current list of color gradients.
  71428. * You must use addColorGradient and removeColorGradient to udpate this list
  71429. * @returns the list of color gradients
  71430. */
  71431. getColorGradients(): Nullable<Array<ColorGradient>>;
  71432. /**
  71433. * Gets the current list of size gradients.
  71434. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71435. * @returns the list of size gradients
  71436. */
  71437. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71438. /**
  71439. * Gets the current list of color remap gradients.
  71440. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71441. * @returns the list of color remap gradients
  71442. */
  71443. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71444. /**
  71445. * Gets the current list of alpha remap gradients.
  71446. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71447. * @returns the list of alpha remap gradients
  71448. */
  71449. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71450. /**
  71451. * Gets the current list of life time gradients.
  71452. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71453. * @returns the list of life time gradients
  71454. */
  71455. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71456. /**
  71457. * Gets the current list of angular speed gradients.
  71458. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71459. * @returns the list of angular speed gradients
  71460. */
  71461. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71462. /**
  71463. * Gets the current list of velocity gradients.
  71464. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71465. * @returns the list of velocity gradients
  71466. */
  71467. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71468. /**
  71469. * Gets the current list of start size gradients.
  71470. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71471. * @returns the list of start size gradients
  71472. */
  71473. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71474. /**
  71475. * Gets the current list of emit rate gradients.
  71476. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71477. * @returns the list of emit rate gradients
  71478. */
  71479. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71480. /**
  71481. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71482. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71483. */
  71484. direction1: Vector3;
  71485. /**
  71486. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71487. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71488. */
  71489. direction2: Vector3;
  71490. /**
  71491. * 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.
  71492. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71493. */
  71494. minEmitBox: Vector3;
  71495. /**
  71496. * 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.
  71497. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71498. */
  71499. maxEmitBox: Vector3;
  71500. /**
  71501. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71502. */
  71503. color1: Color4;
  71504. /**
  71505. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71506. */
  71507. color2: Color4;
  71508. /**
  71509. * Color the particle will have at the end of its lifetime
  71510. */
  71511. colorDead: Color4;
  71512. /**
  71513. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71514. */
  71515. textureMask: Color4;
  71516. /**
  71517. * The particle emitter type defines the emitter used by the particle system.
  71518. * It can be for example box, sphere, or cone...
  71519. */
  71520. particleEmitterType: IParticleEmitterType;
  71521. /** @hidden */
  71522. _isSubEmitter: boolean;
  71523. /**
  71524. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71525. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71526. */
  71527. billboardMode: number;
  71528. protected _isBillboardBased: boolean;
  71529. /**
  71530. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71531. */
  71532. isBillboardBased: boolean;
  71533. /**
  71534. * The scene the particle system belongs to.
  71535. */
  71536. protected _scene: Scene;
  71537. /**
  71538. * Local cache of defines for image processing.
  71539. */
  71540. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71541. /**
  71542. * Default configuration related to image processing available in the standard Material.
  71543. */
  71544. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71545. /**
  71546. * Gets the image processing configuration used either in this material.
  71547. */
  71548. /**
  71549. * Sets the Default image processing configuration used either in the this material.
  71550. *
  71551. * If sets to null, the scene one is in use.
  71552. */
  71553. imageProcessingConfiguration: ImageProcessingConfiguration;
  71554. /**
  71555. * Attaches a new image processing configuration to the Standard Material.
  71556. * @param configuration
  71557. */
  71558. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71559. /** @hidden */
  71560. protected _reset(): void;
  71561. /** @hidden */
  71562. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71563. /**
  71564. * Instantiates a particle system.
  71565. * 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.
  71566. * @param name The name of the particle system
  71567. */
  71568. constructor(name: string);
  71569. /**
  71570. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71573. * @returns the emitter
  71574. */
  71575. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71576. /**
  71577. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71578. * @param radius The radius of the hemisphere to emit from
  71579. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71580. * @returns the emitter
  71581. */
  71582. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71583. /**
  71584. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71585. * @param radius The radius of the sphere to emit from
  71586. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71587. * @returns the emitter
  71588. */
  71589. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71590. /**
  71591. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71592. * @param radius The radius of the sphere to emit from
  71593. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71594. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71595. * @returns the emitter
  71596. */
  71597. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71598. /**
  71599. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71600. * @param radius The radius of the emission cylinder
  71601. * @param height The height of the emission cylinder
  71602. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71603. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71604. * @returns the emitter
  71605. */
  71606. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71607. /**
  71608. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71609. * @param radius The radius of the cylinder to emit from
  71610. * @param height The height of the emission cylinder
  71611. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71614. * @returns the emitter
  71615. */
  71616. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71617. /**
  71618. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71619. * @param radius The radius of the cone to emit from
  71620. * @param angle The base angle of the cone
  71621. * @returns the emitter
  71622. */
  71623. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71624. /**
  71625. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71628. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71629. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71630. * @returns the emitter
  71631. */
  71632. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71633. }
  71634. }
  71635. declare module BABYLON {
  71636. /**
  71637. * Type of sub emitter
  71638. */
  71639. export enum SubEmitterType {
  71640. /**
  71641. * Attached to the particle over it's lifetime
  71642. */
  71643. ATTACHED = 0,
  71644. /**
  71645. * Created when the particle dies
  71646. */
  71647. END = 1
  71648. }
  71649. /**
  71650. * Sub emitter class used to emit particles from an existing particle
  71651. */
  71652. export class SubEmitter {
  71653. /**
  71654. * the particle system to be used by the sub emitter
  71655. */
  71656. particleSystem: ParticleSystem;
  71657. /**
  71658. * Type of the submitter (Default: END)
  71659. */
  71660. type: SubEmitterType;
  71661. /**
  71662. * 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)
  71663. * Note: This only is supported when using an emitter of type Mesh
  71664. */
  71665. inheritDirection: boolean;
  71666. /**
  71667. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71668. */
  71669. inheritedVelocityAmount: number;
  71670. /**
  71671. * Creates a sub emitter
  71672. * @param particleSystem the particle system to be used by the sub emitter
  71673. */
  71674. constructor(
  71675. /**
  71676. * the particle system to be used by the sub emitter
  71677. */
  71678. particleSystem: ParticleSystem);
  71679. /**
  71680. * Clones the sub emitter
  71681. * @returns the cloned sub emitter
  71682. */
  71683. clone(): SubEmitter;
  71684. /**
  71685. * Serialize current object to a JSON object
  71686. * @returns the serialized object
  71687. */
  71688. serialize(): any;
  71689. /** @hidden */
  71690. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71691. /**
  71692. * Creates a new SubEmitter from a serialized JSON version
  71693. * @param serializationObject defines the JSON object to read from
  71694. * @param scene defines the hosting scene
  71695. * @param rootUrl defines the rootUrl for data loading
  71696. * @returns a new SubEmitter
  71697. */
  71698. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71699. /** Release associated resources */
  71700. dispose(): void;
  71701. }
  71702. }
  71703. declare module BABYLON {
  71704. /** @hidden */
  71705. export var clipPlaneFragmentDeclaration: {
  71706. name: string;
  71707. shader: string;
  71708. };
  71709. }
  71710. declare module BABYLON {
  71711. /** @hidden */
  71712. export var imageProcessingDeclaration: {
  71713. name: string;
  71714. shader: string;
  71715. };
  71716. }
  71717. declare module BABYLON {
  71718. /** @hidden */
  71719. export var imageProcessingFunctions: {
  71720. name: string;
  71721. shader: string;
  71722. };
  71723. }
  71724. declare module BABYLON {
  71725. /** @hidden */
  71726. export var clipPlaneFragment: {
  71727. name: string;
  71728. shader: string;
  71729. };
  71730. }
  71731. declare module BABYLON {
  71732. /** @hidden */
  71733. export var particlesPixelShader: {
  71734. name: string;
  71735. shader: string;
  71736. };
  71737. }
  71738. declare module BABYLON {
  71739. /** @hidden */
  71740. export var clipPlaneVertexDeclaration: {
  71741. name: string;
  71742. shader: string;
  71743. };
  71744. }
  71745. declare module BABYLON {
  71746. /** @hidden */
  71747. export var clipPlaneVertex: {
  71748. name: string;
  71749. shader: string;
  71750. };
  71751. }
  71752. declare module BABYLON {
  71753. /** @hidden */
  71754. export var particlesVertexShader: {
  71755. name: string;
  71756. shader: string;
  71757. };
  71758. }
  71759. declare module BABYLON {
  71760. /**
  71761. * This represents a particle system in Babylon.
  71762. * 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.
  71763. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71764. * @example https://doc.babylonjs.com/babylon101/particles
  71765. */
  71766. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  71767. /**
  71768. * Billboard mode will only apply to Y axis
  71769. */
  71770. static readonly BILLBOARDMODE_Y: number;
  71771. /**
  71772. * Billboard mode will apply to all axes
  71773. */
  71774. static readonly BILLBOARDMODE_ALL: number;
  71775. /**
  71776. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71777. */
  71778. static readonly BILLBOARDMODE_STRETCHED: number;
  71779. /**
  71780. * This function can be defined to provide custom update for active particles.
  71781. * This function will be called instead of regular update (age, position, color, etc.).
  71782. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  71783. */
  71784. updateFunction: (particles: Particle[]) => void;
  71785. private _emitterWorldMatrix;
  71786. /**
  71787. * This function can be defined to specify initial direction for every new particle.
  71788. * It by default use the emitterType defined function
  71789. */
  71790. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  71791. /**
  71792. * This function can be defined to specify initial position for every new particle.
  71793. * It by default use the emitterType defined function
  71794. */
  71795. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  71796. /**
  71797. * @hidden
  71798. */
  71799. _inheritedVelocityOffset: Vector3;
  71800. /**
  71801. * An event triggered when the system is disposed
  71802. */
  71803. onDisposeObservable: Observable<ParticleSystem>;
  71804. private _onDisposeObserver;
  71805. /**
  71806. * Sets a callback that will be triggered when the system is disposed
  71807. */
  71808. onDispose: () => void;
  71809. private _particles;
  71810. private _epsilon;
  71811. private _capacity;
  71812. private _stockParticles;
  71813. private _newPartsExcess;
  71814. private _vertexData;
  71815. private _vertexBuffer;
  71816. private _vertexBuffers;
  71817. private _spriteBuffer;
  71818. private _indexBuffer;
  71819. private _effect;
  71820. private _customEffect;
  71821. private _cachedDefines;
  71822. private _scaledColorStep;
  71823. private _colorDiff;
  71824. private _scaledDirection;
  71825. private _scaledGravity;
  71826. private _currentRenderId;
  71827. private _alive;
  71828. private _useInstancing;
  71829. private _started;
  71830. private _stopped;
  71831. private _actualFrame;
  71832. private _scaledUpdateSpeed;
  71833. private _vertexBufferSize;
  71834. /** @hidden */
  71835. _currentEmitRateGradient: Nullable<FactorGradient>;
  71836. /** @hidden */
  71837. _currentEmitRate1: number;
  71838. /** @hidden */
  71839. _currentEmitRate2: number;
  71840. /** @hidden */
  71841. _currentStartSizeGradient: Nullable<FactorGradient>;
  71842. /** @hidden */
  71843. _currentStartSize1: number;
  71844. /** @hidden */
  71845. _currentStartSize2: number;
  71846. private readonly _rawTextureWidth;
  71847. private _rampGradientsTexture;
  71848. private _useRampGradients;
  71849. /** Gets or sets a boolean indicating that ramp gradients must be used
  71850. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71851. */
  71852. useRampGradients: boolean;
  71853. /**
  71854. * 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.
  71855. * 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: [])
  71856. */
  71857. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  71858. private _subEmitters;
  71859. /**
  71860. * @hidden
  71861. * If the particle systems emitter should be disposed when the particle system is disposed
  71862. */
  71863. _disposeEmitterOnDispose: boolean;
  71864. /**
  71865. * The current active Sub-systems, this property is used by the root particle system only.
  71866. */
  71867. activeSubSystems: Array<ParticleSystem>;
  71868. private _rootParticleSystem;
  71869. /**
  71870. * Gets the current list of active particles
  71871. */
  71872. readonly particles: Particle[];
  71873. /**
  71874. * Returns the string "ParticleSystem"
  71875. * @returns a string containing the class name
  71876. */
  71877. getClassName(): string;
  71878. /**
  71879. * Instantiates a particle system.
  71880. * 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.
  71881. * @param name The name of the particle system
  71882. * @param capacity The max number of particles alive at the same time
  71883. * @param scene The scene the particle system belongs to
  71884. * @param customEffect a custom effect used to change the way particles are rendered by default
  71885. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71886. * @param epsilon Offset used to render the particles
  71887. */
  71888. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  71889. private _addFactorGradient;
  71890. private _removeFactorGradient;
  71891. /**
  71892. * Adds a new life time gradient
  71893. * @param gradient defines the gradient to use (between 0 and 1)
  71894. * @param factor defines the life time factor to affect to the specified gradient
  71895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71896. * @returns the current particle system
  71897. */
  71898. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71899. /**
  71900. * Remove a specific life time gradient
  71901. * @param gradient defines the gradient to remove
  71902. * @returns the current particle system
  71903. */
  71904. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71905. /**
  71906. * Adds a new size gradient
  71907. * @param gradient defines the gradient to use (between 0 and 1)
  71908. * @param factor defines the size factor to affect to the specified gradient
  71909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71910. * @returns the current particle system
  71911. */
  71912. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71913. /**
  71914. * Remove a specific size gradient
  71915. * @param gradient defines the gradient to remove
  71916. * @returns the current particle system
  71917. */
  71918. removeSizeGradient(gradient: number): IParticleSystem;
  71919. /**
  71920. * Adds a new color remap gradient
  71921. * @param gradient defines the gradient to use (between 0 and 1)
  71922. * @param min defines the color remap minimal range
  71923. * @param max defines the color remap maximal range
  71924. * @returns the current particle system
  71925. */
  71926. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71927. /**
  71928. * Remove a specific color remap gradient
  71929. * @param gradient defines the gradient to remove
  71930. * @returns the current particle system
  71931. */
  71932. removeColorRemapGradient(gradient: number): IParticleSystem;
  71933. /**
  71934. * Adds a new alpha remap gradient
  71935. * @param gradient defines the gradient to use (between 0 and 1)
  71936. * @param min defines the alpha remap minimal range
  71937. * @param max defines the alpha remap maximal range
  71938. * @returns the current particle system
  71939. */
  71940. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71941. /**
  71942. * Remove a specific alpha remap gradient
  71943. * @param gradient defines the gradient to remove
  71944. * @returns the current particle system
  71945. */
  71946. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  71947. /**
  71948. * Adds a new angular speed gradient
  71949. * @param gradient defines the gradient to use (between 0 and 1)
  71950. * @param factor defines the angular speed to affect to the specified gradient
  71951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71952. * @returns the current particle system
  71953. */
  71954. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71955. /**
  71956. * Remove a specific angular speed gradient
  71957. * @param gradient defines the gradient to remove
  71958. * @returns the current particle system
  71959. */
  71960. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  71961. /**
  71962. * Adds a new velocity gradient
  71963. * @param gradient defines the gradient to use (between 0 and 1)
  71964. * @param factor defines the velocity to affect to the specified gradient
  71965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71966. * @returns the current particle system
  71967. */
  71968. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71969. /**
  71970. * Remove a specific velocity gradient
  71971. * @param gradient defines the gradient to remove
  71972. * @returns the current particle system
  71973. */
  71974. removeVelocityGradient(gradient: number): IParticleSystem;
  71975. /**
  71976. * Adds a new limit velocity gradient
  71977. * @param gradient defines the gradient to use (between 0 and 1)
  71978. * @param factor defines the limit velocity value to affect to the specified gradient
  71979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71980. * @returns the current particle system
  71981. */
  71982. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71983. /**
  71984. * Remove a specific limit velocity gradient
  71985. * @param gradient defines the gradient to remove
  71986. * @returns the current particle system
  71987. */
  71988. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  71989. /**
  71990. * Adds a new drag gradient
  71991. * @param gradient defines the gradient to use (between 0 and 1)
  71992. * @param factor defines the drag value to affect to the specified gradient
  71993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71994. * @returns the current particle system
  71995. */
  71996. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71997. /**
  71998. * Remove a specific drag gradient
  71999. * @param gradient defines the gradient to remove
  72000. * @returns the current particle system
  72001. */
  72002. removeDragGradient(gradient: number): IParticleSystem;
  72003. /**
  72004. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72005. * @param gradient defines the gradient to use (between 0 and 1)
  72006. * @param factor defines the emit rate value to affect to the specified gradient
  72007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72008. * @returns the current particle system
  72009. */
  72010. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72011. /**
  72012. * Remove a specific emit rate gradient
  72013. * @param gradient defines the gradient to remove
  72014. * @returns the current particle system
  72015. */
  72016. removeEmitRateGradient(gradient: number): IParticleSystem;
  72017. /**
  72018. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72019. * @param gradient defines the gradient to use (between 0 and 1)
  72020. * @param factor defines the start size value to affect to the specified gradient
  72021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72022. * @returns the current particle system
  72023. */
  72024. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72025. /**
  72026. * Remove a specific start size gradient
  72027. * @param gradient defines the gradient to remove
  72028. * @returns the current particle system
  72029. */
  72030. removeStartSizeGradient(gradient: number): IParticleSystem;
  72031. private _createRampGradientTexture;
  72032. /**
  72033. * Gets the current list of ramp gradients.
  72034. * You must use addRampGradient and removeRampGradient to udpate this list
  72035. * @returns the list of ramp gradients
  72036. */
  72037. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72038. /**
  72039. * Adds a new ramp gradient used to remap particle colors
  72040. * @param gradient defines the gradient to use (between 0 and 1)
  72041. * @param color defines the color to affect to the specified gradient
  72042. * @returns the current particle system
  72043. */
  72044. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  72045. /**
  72046. * Remove a specific ramp gradient
  72047. * @param gradient defines the gradient to remove
  72048. * @returns the current particle system
  72049. */
  72050. removeRampGradient(gradient: number): ParticleSystem;
  72051. /**
  72052. * Adds a new color gradient
  72053. * @param gradient defines the gradient to use (between 0 and 1)
  72054. * @param color1 defines the color to affect to the specified gradient
  72055. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72056. * @returns this particle system
  72057. */
  72058. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72059. /**
  72060. * Remove a specific color gradient
  72061. * @param gradient defines the gradient to remove
  72062. * @returns this particle system
  72063. */
  72064. removeColorGradient(gradient: number): IParticleSystem;
  72065. private _fetchR;
  72066. protected _reset(): void;
  72067. private _resetEffect;
  72068. private _createVertexBuffers;
  72069. private _createIndexBuffer;
  72070. /**
  72071. * Gets the maximum number of particles active at the same time.
  72072. * @returns The max number of active particles.
  72073. */
  72074. getCapacity(): number;
  72075. /**
  72076. * Gets whether there are still active particles in the system.
  72077. * @returns True if it is alive, otherwise false.
  72078. */
  72079. isAlive(): boolean;
  72080. /**
  72081. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72082. * @returns True if it has been started, otherwise false.
  72083. */
  72084. isStarted(): boolean;
  72085. private _prepareSubEmitterInternalArray;
  72086. /**
  72087. * Starts the particle system and begins to emit
  72088. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72089. */
  72090. start(delay?: number): void;
  72091. /**
  72092. * Stops the particle system.
  72093. * @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.
  72094. */
  72095. stop(stopSubEmitters?: boolean): void;
  72096. /**
  72097. * Remove all active particles
  72098. */
  72099. reset(): void;
  72100. /**
  72101. * @hidden (for internal use only)
  72102. */
  72103. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72104. /**
  72105. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72106. * Its lifetime will start back at 0.
  72107. */
  72108. recycleParticle: (particle: Particle) => void;
  72109. private _stopSubEmitters;
  72110. private _createParticle;
  72111. private _removeFromRoot;
  72112. private _emitFromParticle;
  72113. private _update;
  72114. /** @hidden */
  72115. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72116. /** @hidden */
  72117. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72118. /** @hidden */
  72119. private _getEffect;
  72120. /**
  72121. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72122. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72123. */
  72124. animate(preWarmOnly?: boolean): void;
  72125. private _appendParticleVertices;
  72126. /**
  72127. * Rebuilds the particle system.
  72128. */
  72129. rebuild(): void;
  72130. /**
  72131. * Is this system ready to be used/rendered
  72132. * @return true if the system is ready
  72133. */
  72134. isReady(): boolean;
  72135. private _render;
  72136. /**
  72137. * Renders the particle system in its current state.
  72138. * @returns the current number of particles
  72139. */
  72140. render(): number;
  72141. /**
  72142. * Disposes the particle system and free the associated resources
  72143. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72144. */
  72145. dispose(disposeTexture?: boolean): void;
  72146. /**
  72147. * Clones the particle system.
  72148. * @param name The name of the cloned object
  72149. * @param newEmitter The new emitter to use
  72150. * @returns the cloned particle system
  72151. */
  72152. clone(name: string, newEmitter: any): ParticleSystem;
  72153. /**
  72154. * Serializes the particle system to a JSON object.
  72155. * @returns the JSON object
  72156. */
  72157. serialize(): any;
  72158. /** @hidden */
  72159. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72160. /** @hidden */
  72161. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72162. /**
  72163. * Parses a JSON object to create a particle system.
  72164. * @param parsedParticleSystem The JSON object to parse
  72165. * @param scene The scene to create the particle system in
  72166. * @param rootUrl The root url to use to load external dependencies like texture
  72167. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72168. * @returns the Parsed particle system
  72169. */
  72170. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72171. }
  72172. }
  72173. declare module BABYLON {
  72174. /**
  72175. * A particle represents one of the element emitted by a particle system.
  72176. * This is mainly define by its coordinates, direction, velocity and age.
  72177. */
  72178. export class Particle {
  72179. /**
  72180. * The particle system the particle belongs to.
  72181. */
  72182. particleSystem: ParticleSystem;
  72183. private static _Count;
  72184. /**
  72185. * Unique ID of the particle
  72186. */
  72187. id: number;
  72188. /**
  72189. * The world position of the particle in the scene.
  72190. */
  72191. position: Vector3;
  72192. /**
  72193. * The world direction of the particle in the scene.
  72194. */
  72195. direction: Vector3;
  72196. /**
  72197. * The color of the particle.
  72198. */
  72199. color: Color4;
  72200. /**
  72201. * The color change of the particle per step.
  72202. */
  72203. colorStep: Color4;
  72204. /**
  72205. * Defines how long will the life of the particle be.
  72206. */
  72207. lifeTime: number;
  72208. /**
  72209. * The current age of the particle.
  72210. */
  72211. age: number;
  72212. /**
  72213. * The current size of the particle.
  72214. */
  72215. size: number;
  72216. /**
  72217. * The current scale of the particle.
  72218. */
  72219. scale: Vector2;
  72220. /**
  72221. * The current angle of the particle.
  72222. */
  72223. angle: number;
  72224. /**
  72225. * Defines how fast is the angle changing.
  72226. */
  72227. angularSpeed: number;
  72228. /**
  72229. * Defines the cell index used by the particle to be rendered from a sprite.
  72230. */
  72231. cellIndex: number;
  72232. /**
  72233. * The information required to support color remapping
  72234. */
  72235. remapData: Vector4;
  72236. /** @hidden */
  72237. _randomCellOffset?: number;
  72238. /** @hidden */
  72239. _initialDirection: Nullable<Vector3>;
  72240. /** @hidden */
  72241. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72242. /** @hidden */
  72243. _initialStartSpriteCellID: number;
  72244. /** @hidden */
  72245. _initialEndSpriteCellID: number;
  72246. /** @hidden */
  72247. _currentColorGradient: Nullable<ColorGradient>;
  72248. /** @hidden */
  72249. _currentColor1: Color4;
  72250. /** @hidden */
  72251. _currentColor2: Color4;
  72252. /** @hidden */
  72253. _currentSizeGradient: Nullable<FactorGradient>;
  72254. /** @hidden */
  72255. _currentSize1: number;
  72256. /** @hidden */
  72257. _currentSize2: number;
  72258. /** @hidden */
  72259. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72260. /** @hidden */
  72261. _currentAngularSpeed1: number;
  72262. /** @hidden */
  72263. _currentAngularSpeed2: number;
  72264. /** @hidden */
  72265. _currentVelocityGradient: Nullable<FactorGradient>;
  72266. /** @hidden */
  72267. _currentVelocity1: number;
  72268. /** @hidden */
  72269. _currentVelocity2: number;
  72270. /** @hidden */
  72271. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72272. /** @hidden */
  72273. _currentLimitVelocity1: number;
  72274. /** @hidden */
  72275. _currentLimitVelocity2: number;
  72276. /** @hidden */
  72277. _currentDragGradient: Nullable<FactorGradient>;
  72278. /** @hidden */
  72279. _currentDrag1: number;
  72280. /** @hidden */
  72281. _currentDrag2: number;
  72282. /** @hidden */
  72283. _randomNoiseCoordinates1: Vector3;
  72284. /** @hidden */
  72285. _randomNoiseCoordinates2: Vector3;
  72286. /**
  72287. * Creates a new instance Particle
  72288. * @param particleSystem the particle system the particle belongs to
  72289. */
  72290. constructor(
  72291. /**
  72292. * The particle system the particle belongs to.
  72293. */
  72294. particleSystem: ParticleSystem);
  72295. private updateCellInfoFromSystem;
  72296. /**
  72297. * Defines how the sprite cell index is updated for the particle
  72298. */
  72299. updateCellIndex(): void;
  72300. /** @hidden */
  72301. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72302. /** @hidden */
  72303. _inheritParticleInfoToSubEmitters(): void;
  72304. /** @hidden */
  72305. _reset(): void;
  72306. /**
  72307. * Copy the properties of particle to another one.
  72308. * @param other the particle to copy the information to.
  72309. */
  72310. copyTo(other: Particle): void;
  72311. }
  72312. }
  72313. declare module BABYLON {
  72314. /**
  72315. * Particle emitter represents a volume emitting particles.
  72316. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72317. */
  72318. export interface IParticleEmitterType {
  72319. /**
  72320. * Called by the particle System when the direction is computed for the created particle.
  72321. * @param worldMatrix is the world matrix of the particle system
  72322. * @param directionToUpdate is the direction vector to update with the result
  72323. * @param particle is the particle we are computed the direction for
  72324. */
  72325. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72326. /**
  72327. * Called by the particle System when the position is computed for the created particle.
  72328. * @param worldMatrix is the world matrix of the particle system
  72329. * @param positionToUpdate is the position vector to update with the result
  72330. * @param particle is the particle we are computed the position for
  72331. */
  72332. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72333. /**
  72334. * Clones the current emitter and returns a copy of it
  72335. * @returns the new emitter
  72336. */
  72337. clone(): IParticleEmitterType;
  72338. /**
  72339. * Called by the GPUParticleSystem to setup the update shader
  72340. * @param effect defines the update shader
  72341. */
  72342. applyToShader(effect: Effect): void;
  72343. /**
  72344. * Returns a string to use to update the GPU particles update shader
  72345. * @returns the effect defines string
  72346. */
  72347. getEffectDefines(): string;
  72348. /**
  72349. * Returns a string representing the class name
  72350. * @returns a string containing the class name
  72351. */
  72352. getClassName(): string;
  72353. /**
  72354. * Serializes the particle system to a JSON object.
  72355. * @returns the JSON object
  72356. */
  72357. serialize(): any;
  72358. /**
  72359. * Parse properties from a JSON object
  72360. * @param serializationObject defines the JSON object
  72361. */
  72362. parse(serializationObject: any): void;
  72363. }
  72364. }
  72365. declare module BABYLON {
  72366. /**
  72367. * Particle emitter emitting particles from the inside of a box.
  72368. * It emits the particles randomly between 2 given directions.
  72369. */
  72370. export class BoxParticleEmitter implements IParticleEmitterType {
  72371. /**
  72372. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72373. */
  72374. direction1: Vector3;
  72375. /**
  72376. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72377. */
  72378. direction2: Vector3;
  72379. /**
  72380. * 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.
  72381. */
  72382. minEmitBox: Vector3;
  72383. /**
  72384. * 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.
  72385. */
  72386. maxEmitBox: Vector3;
  72387. /**
  72388. * Creates a new instance BoxParticleEmitter
  72389. */
  72390. constructor();
  72391. /**
  72392. * Called by the particle System when the direction is computed for the created particle.
  72393. * @param worldMatrix is the world matrix of the particle system
  72394. * @param directionToUpdate is the direction vector to update with the result
  72395. * @param particle is the particle we are computed the direction for
  72396. */
  72397. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72398. /**
  72399. * Called by the particle System when the position is computed for the created particle.
  72400. * @param worldMatrix is the world matrix of the particle system
  72401. * @param positionToUpdate is the position vector to update with the result
  72402. * @param particle is the particle we are computed the position for
  72403. */
  72404. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72405. /**
  72406. * Clones the current emitter and returns a copy of it
  72407. * @returns the new emitter
  72408. */
  72409. clone(): BoxParticleEmitter;
  72410. /**
  72411. * Called by the GPUParticleSystem to setup the update shader
  72412. * @param effect defines the update shader
  72413. */
  72414. applyToShader(effect: Effect): void;
  72415. /**
  72416. * Returns a string to use to update the GPU particles update shader
  72417. * @returns a string containng the defines string
  72418. */
  72419. getEffectDefines(): string;
  72420. /**
  72421. * Returns the string "BoxParticleEmitter"
  72422. * @returns a string containing the class name
  72423. */
  72424. getClassName(): string;
  72425. /**
  72426. * Serializes the particle system to a JSON object.
  72427. * @returns the JSON object
  72428. */
  72429. serialize(): any;
  72430. /**
  72431. * Parse properties from a JSON object
  72432. * @param serializationObject defines the JSON object
  72433. */
  72434. parse(serializationObject: any): void;
  72435. }
  72436. }
  72437. declare module BABYLON {
  72438. /**
  72439. * Particle emitter emitting particles from the inside of a cone.
  72440. * It emits the particles alongside the cone volume from the base to the particle.
  72441. * The emission direction might be randomized.
  72442. */
  72443. export class ConeParticleEmitter implements IParticleEmitterType {
  72444. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72445. directionRandomizer: number;
  72446. private _radius;
  72447. private _angle;
  72448. private _height;
  72449. /**
  72450. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  72451. */
  72452. radiusRange: number;
  72453. /**
  72454. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  72455. */
  72456. heightRange: number;
  72457. /**
  72458. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  72459. */
  72460. emitFromSpawnPointOnly: boolean;
  72461. /**
  72462. * Gets or sets the radius of the emission cone
  72463. */
  72464. radius: number;
  72465. /**
  72466. * Gets or sets the angle of the emission cone
  72467. */
  72468. angle: number;
  72469. private _buildHeight;
  72470. /**
  72471. * Creates a new instance ConeParticleEmitter
  72472. * @param radius the radius of the emission cone (1 by default)
  72473. * @param angle the cone base angle (PI by default)
  72474. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72475. */
  72476. constructor(radius?: number, angle?: number,
  72477. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72478. directionRandomizer?: number);
  72479. /**
  72480. * Called by the particle System when the direction is computed for the created particle.
  72481. * @param worldMatrix is the world matrix of the particle system
  72482. * @param directionToUpdate is the direction vector to update with the result
  72483. * @param particle is the particle we are computed the direction for
  72484. */
  72485. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72486. /**
  72487. * Called by the particle System when the position is computed for the created particle.
  72488. * @param worldMatrix is the world matrix of the particle system
  72489. * @param positionToUpdate is the position vector to update with the result
  72490. * @param particle is the particle we are computed the position for
  72491. */
  72492. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72493. /**
  72494. * Clones the current emitter and returns a copy of it
  72495. * @returns the new emitter
  72496. */
  72497. clone(): ConeParticleEmitter;
  72498. /**
  72499. * Called by the GPUParticleSystem to setup the update shader
  72500. * @param effect defines the update shader
  72501. */
  72502. applyToShader(effect: Effect): void;
  72503. /**
  72504. * Returns a string to use to update the GPU particles update shader
  72505. * @returns a string containng the defines string
  72506. */
  72507. getEffectDefines(): string;
  72508. /**
  72509. * Returns the string "ConeParticleEmitter"
  72510. * @returns a string containing the class name
  72511. */
  72512. getClassName(): string;
  72513. /**
  72514. * Serializes the particle system to a JSON object.
  72515. * @returns the JSON object
  72516. */
  72517. serialize(): any;
  72518. /**
  72519. * Parse properties from a JSON object
  72520. * @param serializationObject defines the JSON object
  72521. */
  72522. parse(serializationObject: any): void;
  72523. }
  72524. }
  72525. declare module BABYLON {
  72526. /**
  72527. * Particle emitter emitting particles from the inside of a cylinder.
  72528. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72529. */
  72530. export class CylinderParticleEmitter implements IParticleEmitterType {
  72531. /**
  72532. * The radius of the emission cylinder.
  72533. */
  72534. radius: number;
  72535. /**
  72536. * The height of the emission cylinder.
  72537. */
  72538. height: number;
  72539. /**
  72540. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72541. */
  72542. radiusRange: number;
  72543. /**
  72544. * How much to randomize the particle direction [0-1].
  72545. */
  72546. directionRandomizer: number;
  72547. /**
  72548. * Creates a new instance CylinderParticleEmitter
  72549. * @param radius the radius of the emission cylinder (1 by default)
  72550. * @param height the height of the emission cylinder (1 by default)
  72551. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72552. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72553. */
  72554. constructor(
  72555. /**
  72556. * The radius of the emission cylinder.
  72557. */
  72558. radius?: number,
  72559. /**
  72560. * The height of the emission cylinder.
  72561. */
  72562. height?: number,
  72563. /**
  72564. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72565. */
  72566. radiusRange?: number,
  72567. /**
  72568. * How much to randomize the particle direction [0-1].
  72569. */
  72570. directionRandomizer?: number);
  72571. /**
  72572. * Called by the particle System when the direction is computed for the created particle.
  72573. * @param worldMatrix is the world matrix of the particle system
  72574. * @param directionToUpdate is the direction vector to update with the result
  72575. * @param particle is the particle we are computed the direction for
  72576. */
  72577. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72578. /**
  72579. * Called by the particle System when the position is computed for the created particle.
  72580. * @param worldMatrix is the world matrix of the particle system
  72581. * @param positionToUpdate is the position vector to update with the result
  72582. * @param particle is the particle we are computed the position for
  72583. */
  72584. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72585. /**
  72586. * Clones the current emitter and returns a copy of it
  72587. * @returns the new emitter
  72588. */
  72589. clone(): CylinderParticleEmitter;
  72590. /**
  72591. * Called by the GPUParticleSystem to setup the update shader
  72592. * @param effect defines the update shader
  72593. */
  72594. applyToShader(effect: Effect): void;
  72595. /**
  72596. * Returns a string to use to update the GPU particles update shader
  72597. * @returns a string containng the defines string
  72598. */
  72599. getEffectDefines(): string;
  72600. /**
  72601. * Returns the string "CylinderParticleEmitter"
  72602. * @returns a string containing the class name
  72603. */
  72604. getClassName(): string;
  72605. /**
  72606. * Serializes the particle system to a JSON object.
  72607. * @returns the JSON object
  72608. */
  72609. serialize(): any;
  72610. /**
  72611. * Parse properties from a JSON object
  72612. * @param serializationObject defines the JSON object
  72613. */
  72614. parse(serializationObject: any): void;
  72615. }
  72616. /**
  72617. * Particle emitter emitting particles from the inside of a cylinder.
  72618. * It emits the particles randomly between two vectors.
  72619. */
  72620. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72621. /**
  72622. * The min limit of the emission direction.
  72623. */
  72624. direction1: Vector3;
  72625. /**
  72626. * The max limit of the emission direction.
  72627. */
  72628. direction2: Vector3;
  72629. /**
  72630. * Creates a new instance CylinderDirectedParticleEmitter
  72631. * @param radius the radius of the emission cylinder (1 by default)
  72632. * @param height the height of the emission cylinder (1 by default)
  72633. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72634. * @param direction1 the min limit of the emission direction (up vector by default)
  72635. * @param direction2 the max limit of the emission direction (up vector by default)
  72636. */
  72637. constructor(radius?: number, height?: number, radiusRange?: number,
  72638. /**
  72639. * The min limit of the emission direction.
  72640. */
  72641. direction1?: Vector3,
  72642. /**
  72643. * The max limit of the emission direction.
  72644. */
  72645. direction2?: Vector3);
  72646. /**
  72647. * Called by the particle System when the direction is computed for the created particle.
  72648. * @param worldMatrix is the world matrix of the particle system
  72649. * @param directionToUpdate is the direction vector to update with the result
  72650. * @param particle is the particle we are computed the direction for
  72651. */
  72652. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72653. /**
  72654. * Clones the current emitter and returns a copy of it
  72655. * @returns the new emitter
  72656. */
  72657. clone(): CylinderDirectedParticleEmitter;
  72658. /**
  72659. * Called by the GPUParticleSystem to setup the update shader
  72660. * @param effect defines the update shader
  72661. */
  72662. applyToShader(effect: Effect): void;
  72663. /**
  72664. * Returns a string to use to update the GPU particles update shader
  72665. * @returns a string containng the defines string
  72666. */
  72667. getEffectDefines(): string;
  72668. /**
  72669. * Returns the string "CylinderDirectedParticleEmitter"
  72670. * @returns a string containing the class name
  72671. */
  72672. getClassName(): string;
  72673. /**
  72674. * Serializes the particle system to a JSON object.
  72675. * @returns the JSON object
  72676. */
  72677. serialize(): any;
  72678. /**
  72679. * Parse properties from a JSON object
  72680. * @param serializationObject defines the JSON object
  72681. */
  72682. parse(serializationObject: any): void;
  72683. }
  72684. }
  72685. declare module BABYLON {
  72686. /**
  72687. * Particle emitter emitting particles from the inside of a hemisphere.
  72688. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72689. */
  72690. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72691. /**
  72692. * The radius of the emission hemisphere.
  72693. */
  72694. radius: number;
  72695. /**
  72696. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72697. */
  72698. radiusRange: number;
  72699. /**
  72700. * How much to randomize the particle direction [0-1].
  72701. */
  72702. directionRandomizer: number;
  72703. /**
  72704. * Creates a new instance HemisphericParticleEmitter
  72705. * @param radius the radius of the emission hemisphere (1 by default)
  72706. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72707. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72708. */
  72709. constructor(
  72710. /**
  72711. * The radius of the emission hemisphere.
  72712. */
  72713. radius?: number,
  72714. /**
  72715. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72716. */
  72717. radiusRange?: number,
  72718. /**
  72719. * How much to randomize the particle direction [0-1].
  72720. */
  72721. directionRandomizer?: number);
  72722. /**
  72723. * Called by the particle System when the direction is computed for the created particle.
  72724. * @param worldMatrix is the world matrix of the particle system
  72725. * @param directionToUpdate is the direction vector to update with the result
  72726. * @param particle is the particle we are computed the direction for
  72727. */
  72728. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72729. /**
  72730. * Called by the particle System when the position is computed for the created particle.
  72731. * @param worldMatrix is the world matrix of the particle system
  72732. * @param positionToUpdate is the position vector to update with the result
  72733. * @param particle is the particle we are computed the position for
  72734. */
  72735. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72736. /**
  72737. * Clones the current emitter and returns a copy of it
  72738. * @returns the new emitter
  72739. */
  72740. clone(): HemisphericParticleEmitter;
  72741. /**
  72742. * Called by the GPUParticleSystem to setup the update shader
  72743. * @param effect defines the update shader
  72744. */
  72745. applyToShader(effect: Effect): void;
  72746. /**
  72747. * Returns a string to use to update the GPU particles update shader
  72748. * @returns a string containng the defines string
  72749. */
  72750. getEffectDefines(): string;
  72751. /**
  72752. * Returns the string "HemisphericParticleEmitter"
  72753. * @returns a string containing the class name
  72754. */
  72755. getClassName(): string;
  72756. /**
  72757. * Serializes the particle system to a JSON object.
  72758. * @returns the JSON object
  72759. */
  72760. serialize(): any;
  72761. /**
  72762. * Parse properties from a JSON object
  72763. * @param serializationObject defines the JSON object
  72764. */
  72765. parse(serializationObject: any): void;
  72766. }
  72767. }
  72768. declare module BABYLON {
  72769. /**
  72770. * Particle emitter emitting particles from a point.
  72771. * It emits the particles randomly between 2 given directions.
  72772. */
  72773. export class PointParticleEmitter implements IParticleEmitterType {
  72774. /**
  72775. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72776. */
  72777. direction1: Vector3;
  72778. /**
  72779. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72780. */
  72781. direction2: Vector3;
  72782. /**
  72783. * Creates a new instance PointParticleEmitter
  72784. */
  72785. constructor();
  72786. /**
  72787. * Called by the particle System when the direction is computed for the created particle.
  72788. * @param worldMatrix is the world matrix of the particle system
  72789. * @param directionToUpdate is the direction vector to update with the result
  72790. * @param particle is the particle we are computed the direction for
  72791. */
  72792. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72793. /**
  72794. * Called by the particle System when the position is computed for the created particle.
  72795. * @param worldMatrix is the world matrix of the particle system
  72796. * @param positionToUpdate is the position vector to update with the result
  72797. * @param particle is the particle we are computed the position for
  72798. */
  72799. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72800. /**
  72801. * Clones the current emitter and returns a copy of it
  72802. * @returns the new emitter
  72803. */
  72804. clone(): PointParticleEmitter;
  72805. /**
  72806. * Called by the GPUParticleSystem to setup the update shader
  72807. * @param effect defines the update shader
  72808. */
  72809. applyToShader(effect: Effect): void;
  72810. /**
  72811. * Returns a string to use to update the GPU particles update shader
  72812. * @returns a string containng the defines string
  72813. */
  72814. getEffectDefines(): string;
  72815. /**
  72816. * Returns the string "PointParticleEmitter"
  72817. * @returns a string containing the class name
  72818. */
  72819. getClassName(): string;
  72820. /**
  72821. * Serializes the particle system to a JSON object.
  72822. * @returns the JSON object
  72823. */
  72824. serialize(): any;
  72825. /**
  72826. * Parse properties from a JSON object
  72827. * @param serializationObject defines the JSON object
  72828. */
  72829. parse(serializationObject: any): void;
  72830. }
  72831. }
  72832. declare module BABYLON {
  72833. /**
  72834. * Particle emitter emitting particles from the inside of a sphere.
  72835. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  72836. */
  72837. export class SphereParticleEmitter implements IParticleEmitterType {
  72838. /**
  72839. * The radius of the emission sphere.
  72840. */
  72841. radius: number;
  72842. /**
  72843. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72844. */
  72845. radiusRange: number;
  72846. /**
  72847. * How much to randomize the particle direction [0-1].
  72848. */
  72849. directionRandomizer: number;
  72850. /**
  72851. * Creates a new instance SphereParticleEmitter
  72852. * @param radius the radius of the emission sphere (1 by default)
  72853. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72854. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72855. */
  72856. constructor(
  72857. /**
  72858. * The radius of the emission sphere.
  72859. */
  72860. radius?: number,
  72861. /**
  72862. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72863. */
  72864. radiusRange?: number,
  72865. /**
  72866. * How much to randomize the particle direction [0-1].
  72867. */
  72868. directionRandomizer?: number);
  72869. /**
  72870. * Called by the particle System when the direction is computed for the created particle.
  72871. * @param worldMatrix is the world matrix of the particle system
  72872. * @param directionToUpdate is the direction vector to update with the result
  72873. * @param particle is the particle we are computed the direction for
  72874. */
  72875. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72876. /**
  72877. * Called by the particle System when the position is computed for the created particle.
  72878. * @param worldMatrix is the world matrix of the particle system
  72879. * @param positionToUpdate is the position vector to update with the result
  72880. * @param particle is the particle we are computed the position for
  72881. */
  72882. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72883. /**
  72884. * Clones the current emitter and returns a copy of it
  72885. * @returns the new emitter
  72886. */
  72887. clone(): SphereParticleEmitter;
  72888. /**
  72889. * Called by the GPUParticleSystem to setup the update shader
  72890. * @param effect defines the update shader
  72891. */
  72892. applyToShader(effect: Effect): void;
  72893. /**
  72894. * Returns a string to use to update the GPU particles update shader
  72895. * @returns a string containng the defines string
  72896. */
  72897. getEffectDefines(): string;
  72898. /**
  72899. * Returns the string "SphereParticleEmitter"
  72900. * @returns a string containing the class name
  72901. */
  72902. getClassName(): string;
  72903. /**
  72904. * Serializes the particle system to a JSON object.
  72905. * @returns the JSON object
  72906. */
  72907. serialize(): any;
  72908. /**
  72909. * Parse properties from a JSON object
  72910. * @param serializationObject defines the JSON object
  72911. */
  72912. parse(serializationObject: any): void;
  72913. }
  72914. /**
  72915. * Particle emitter emitting particles from the inside of a sphere.
  72916. * It emits the particles randomly between two vectors.
  72917. */
  72918. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  72919. /**
  72920. * The min limit of the emission direction.
  72921. */
  72922. direction1: Vector3;
  72923. /**
  72924. * The max limit of the emission direction.
  72925. */
  72926. direction2: Vector3;
  72927. /**
  72928. * Creates a new instance SphereDirectedParticleEmitter
  72929. * @param radius the radius of the emission sphere (1 by default)
  72930. * @param direction1 the min limit of the emission direction (up vector by default)
  72931. * @param direction2 the max limit of the emission direction (up vector by default)
  72932. */
  72933. constructor(radius?: number,
  72934. /**
  72935. * The min limit of the emission direction.
  72936. */
  72937. direction1?: Vector3,
  72938. /**
  72939. * The max limit of the emission direction.
  72940. */
  72941. direction2?: Vector3);
  72942. /**
  72943. * Called by the particle System when the direction is computed for the created particle.
  72944. * @param worldMatrix is the world matrix of the particle system
  72945. * @param directionToUpdate is the direction vector to update with the result
  72946. * @param particle is the particle we are computed the direction for
  72947. */
  72948. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72949. /**
  72950. * Clones the current emitter and returns a copy of it
  72951. * @returns the new emitter
  72952. */
  72953. clone(): SphereDirectedParticleEmitter;
  72954. /**
  72955. * Called by the GPUParticleSystem to setup the update shader
  72956. * @param effect defines the update shader
  72957. */
  72958. applyToShader(effect: Effect): void;
  72959. /**
  72960. * Returns a string to use to update the GPU particles update shader
  72961. * @returns a string containng the defines string
  72962. */
  72963. getEffectDefines(): string;
  72964. /**
  72965. * Returns the string "SphereDirectedParticleEmitter"
  72966. * @returns a string containing the class name
  72967. */
  72968. getClassName(): string;
  72969. /**
  72970. * Serializes the particle system to a JSON object.
  72971. * @returns the JSON object
  72972. */
  72973. serialize(): any;
  72974. /**
  72975. * Parse properties from a JSON object
  72976. * @param serializationObject defines the JSON object
  72977. */
  72978. parse(serializationObject: any): void;
  72979. }
  72980. }
  72981. declare module BABYLON {
  72982. /**
  72983. * Interface representing a particle system in Babylon.js.
  72984. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  72985. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  72986. */
  72987. export interface IParticleSystem {
  72988. /**
  72989. * List of animations used by the particle system.
  72990. */
  72991. animations: Animation[];
  72992. /**
  72993. * The id of the Particle system.
  72994. */
  72995. id: string;
  72996. /**
  72997. * The name of the Particle system.
  72998. */
  72999. name: string;
  73000. /**
  73001. * The emitter represents the Mesh or position we are attaching the particle system to.
  73002. */
  73003. emitter: Nullable<AbstractMesh | Vector3>;
  73004. /**
  73005. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73006. */
  73007. isBillboardBased: boolean;
  73008. /**
  73009. * The rendering group used by the Particle system to chose when to render.
  73010. */
  73011. renderingGroupId: number;
  73012. /**
  73013. * The layer mask we are rendering the particles through.
  73014. */
  73015. layerMask: number;
  73016. /**
  73017. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73018. */
  73019. updateSpeed: number;
  73020. /**
  73021. * The amount of time the particle system is running (depends of the overall update speed).
  73022. */
  73023. targetStopDuration: number;
  73024. /**
  73025. * The texture used to render each particle. (this can be a spritesheet)
  73026. */
  73027. particleTexture: Nullable<Texture>;
  73028. /**
  73029. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  73030. */
  73031. blendMode: number;
  73032. /**
  73033. * Minimum life time of emitting particles.
  73034. */
  73035. minLifeTime: number;
  73036. /**
  73037. * Maximum life time of emitting particles.
  73038. */
  73039. maxLifeTime: number;
  73040. /**
  73041. * Minimum Size of emitting particles.
  73042. */
  73043. minSize: number;
  73044. /**
  73045. * Maximum Size of emitting particles.
  73046. */
  73047. maxSize: number;
  73048. /**
  73049. * Minimum scale of emitting particles on X axis.
  73050. */
  73051. minScaleX: number;
  73052. /**
  73053. * Maximum scale of emitting particles on X axis.
  73054. */
  73055. maxScaleX: number;
  73056. /**
  73057. * Minimum scale of emitting particles on Y axis.
  73058. */
  73059. minScaleY: number;
  73060. /**
  73061. * Maximum scale of emitting particles on Y axis.
  73062. */
  73063. maxScaleY: number;
  73064. /**
  73065. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73066. */
  73067. color1: Color4;
  73068. /**
  73069. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73070. */
  73071. color2: Color4;
  73072. /**
  73073. * Color the particle will have at the end of its lifetime.
  73074. */
  73075. colorDead: Color4;
  73076. /**
  73077. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73078. */
  73079. emitRate: number;
  73080. /**
  73081. * You can use gravity if you want to give an orientation to your particles.
  73082. */
  73083. gravity: Vector3;
  73084. /**
  73085. * Minimum power of emitting particles.
  73086. */
  73087. minEmitPower: number;
  73088. /**
  73089. * Maximum power of emitting particles.
  73090. */
  73091. maxEmitPower: number;
  73092. /**
  73093. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73094. */
  73095. minAngularSpeed: number;
  73096. /**
  73097. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73098. */
  73099. maxAngularSpeed: number;
  73100. /**
  73101. * Gets or sets the minimal initial rotation in radians.
  73102. */
  73103. minInitialRotation: number;
  73104. /**
  73105. * Gets or sets the maximal initial rotation in radians.
  73106. */
  73107. maxInitialRotation: number;
  73108. /**
  73109. * The particle emitter type defines the emitter used by the particle system.
  73110. * It can be for example box, sphere, or cone...
  73111. */
  73112. particleEmitterType: Nullable<IParticleEmitterType>;
  73113. /**
  73114. * Defines the delay in milliseconds before starting the system (0 by default)
  73115. */
  73116. startDelay: number;
  73117. /**
  73118. * 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
  73119. */
  73120. preWarmCycles: number;
  73121. /**
  73122. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73123. */
  73124. preWarmStepOffset: number;
  73125. /**
  73126. * 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)
  73127. */
  73128. spriteCellChangeSpeed: number;
  73129. /**
  73130. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73131. */
  73132. startSpriteCellID: number;
  73133. /**
  73134. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73135. */
  73136. endSpriteCellID: number;
  73137. /**
  73138. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73139. */
  73140. spriteCellWidth: number;
  73141. /**
  73142. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73143. */
  73144. spriteCellHeight: number;
  73145. /**
  73146. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73147. */
  73148. spriteRandomStartCell: boolean;
  73149. /**
  73150. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73151. */
  73152. isAnimationSheetEnabled: boolean;
  73153. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73154. translationPivot: Vector2;
  73155. /**
  73156. * Gets or sets a texture used to add random noise to particle positions
  73157. */
  73158. noiseTexture: Nullable<BaseTexture>;
  73159. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73160. noiseStrength: Vector3;
  73161. /**
  73162. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73163. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73164. */
  73165. billboardMode: number;
  73166. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73167. limitVelocityDamping: number;
  73168. /**
  73169. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73170. */
  73171. beginAnimationOnStart: boolean;
  73172. /**
  73173. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73174. */
  73175. beginAnimationFrom: number;
  73176. /**
  73177. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73178. */
  73179. beginAnimationTo: number;
  73180. /**
  73181. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73182. */
  73183. beginAnimationLoop: boolean;
  73184. /**
  73185. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73186. */
  73187. disposeOnStop: boolean;
  73188. /**
  73189. * Gets the maximum number of particles active at the same time.
  73190. * @returns The max number of active particles.
  73191. */
  73192. getCapacity(): number;
  73193. /**
  73194. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73195. * @returns True if it has been started, otherwise false.
  73196. */
  73197. isStarted(): boolean;
  73198. /**
  73199. * Animates the particle system for this frame.
  73200. */
  73201. animate(): void;
  73202. /**
  73203. * Renders the particle system in its current state.
  73204. * @returns the current number of particles
  73205. */
  73206. render(): number;
  73207. /**
  73208. * Dispose the particle system and frees its associated resources.
  73209. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73210. */
  73211. dispose(disposeTexture?: boolean): void;
  73212. /**
  73213. * Clones the particle system.
  73214. * @param name The name of the cloned object
  73215. * @param newEmitter The new emitter to use
  73216. * @returns the cloned particle system
  73217. */
  73218. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73219. /**
  73220. * Serializes the particle system to a JSON object.
  73221. * @returns the JSON object
  73222. */
  73223. serialize(): any;
  73224. /**
  73225. * Rebuild the particle system
  73226. */
  73227. rebuild(): void;
  73228. /**
  73229. * Starts the particle system and begins to emit
  73230. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73231. */
  73232. start(delay?: number): void;
  73233. /**
  73234. * Stops the particle system.
  73235. */
  73236. stop(): void;
  73237. /**
  73238. * Remove all active particles
  73239. */
  73240. reset(): void;
  73241. /**
  73242. * Is this system ready to be used/rendered
  73243. * @return true if the system is ready
  73244. */
  73245. isReady(): boolean;
  73246. /**
  73247. * Adds a new color gradient
  73248. * @param gradient defines the gradient to use (between 0 and 1)
  73249. * @param color1 defines the color to affect to the specified gradient
  73250. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73251. * @returns the current particle system
  73252. */
  73253. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73254. /**
  73255. * Remove a specific color gradient
  73256. * @param gradient defines the gradient to remove
  73257. * @returns the current particle system
  73258. */
  73259. removeColorGradient(gradient: number): IParticleSystem;
  73260. /**
  73261. * Adds a new size gradient
  73262. * @param gradient defines the gradient to use (between 0 and 1)
  73263. * @param factor defines the size factor to affect to the specified gradient
  73264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73265. * @returns the current particle system
  73266. */
  73267. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73268. /**
  73269. * Remove a specific size gradient
  73270. * @param gradient defines the gradient to remove
  73271. * @returns the current particle system
  73272. */
  73273. removeSizeGradient(gradient: number): IParticleSystem;
  73274. /**
  73275. * Gets the current list of color gradients.
  73276. * You must use addColorGradient and removeColorGradient to udpate this list
  73277. * @returns the list of color gradients
  73278. */
  73279. getColorGradients(): Nullable<Array<ColorGradient>>;
  73280. /**
  73281. * Gets the current list of size gradients.
  73282. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73283. * @returns the list of size gradients
  73284. */
  73285. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73286. /**
  73287. * Gets the current list of angular speed gradients.
  73288. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73289. * @returns the list of angular speed gradients
  73290. */
  73291. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73292. /**
  73293. * Adds a new angular speed gradient
  73294. * @param gradient defines the gradient to use (between 0 and 1)
  73295. * @param factor defines the angular speed to affect to the specified gradient
  73296. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73297. * @returns the current particle system
  73298. */
  73299. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73300. /**
  73301. * Remove a specific angular speed gradient
  73302. * @param gradient defines the gradient to remove
  73303. * @returns the current particle system
  73304. */
  73305. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73306. /**
  73307. * Gets the current list of velocity gradients.
  73308. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73309. * @returns the list of velocity gradients
  73310. */
  73311. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73312. /**
  73313. * Adds a new velocity gradient
  73314. * @param gradient defines the gradient to use (between 0 and 1)
  73315. * @param factor defines the velocity to affect to the specified gradient
  73316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73317. * @returns the current particle system
  73318. */
  73319. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73320. /**
  73321. * Remove a specific velocity gradient
  73322. * @param gradient defines the gradient to remove
  73323. * @returns the current particle system
  73324. */
  73325. removeVelocityGradient(gradient: number): IParticleSystem;
  73326. /**
  73327. * Gets the current list of limit velocity gradients.
  73328. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73329. * @returns the list of limit velocity gradients
  73330. */
  73331. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73332. /**
  73333. * Adds a new limit velocity gradient
  73334. * @param gradient defines the gradient to use (between 0 and 1)
  73335. * @param factor defines the limit velocity to affect to the specified gradient
  73336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73337. * @returns the current particle system
  73338. */
  73339. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73340. /**
  73341. * Remove a specific limit velocity gradient
  73342. * @param gradient defines the gradient to remove
  73343. * @returns the current particle system
  73344. */
  73345. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73346. /**
  73347. * Adds a new drag gradient
  73348. * @param gradient defines the gradient to use (between 0 and 1)
  73349. * @param factor defines the drag to affect to the specified gradient
  73350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73351. * @returns the current particle system
  73352. */
  73353. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73354. /**
  73355. * Remove a specific drag gradient
  73356. * @param gradient defines the gradient to remove
  73357. * @returns the current particle system
  73358. */
  73359. removeDragGradient(gradient: number): IParticleSystem;
  73360. /**
  73361. * Gets the current list of drag gradients.
  73362. * You must use addDragGradient and removeDragGradient to udpate this list
  73363. * @returns the list of drag gradients
  73364. */
  73365. getDragGradients(): Nullable<Array<FactorGradient>>;
  73366. /**
  73367. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73368. * @param gradient defines the gradient to use (between 0 and 1)
  73369. * @param factor defines the emit rate to affect to the specified gradient
  73370. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73371. * @returns the current particle system
  73372. */
  73373. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73374. /**
  73375. * Remove a specific emit rate gradient
  73376. * @param gradient defines the gradient to remove
  73377. * @returns the current particle system
  73378. */
  73379. removeEmitRateGradient(gradient: number): IParticleSystem;
  73380. /**
  73381. * Gets the current list of emit rate gradients.
  73382. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73383. * @returns the list of emit rate gradients
  73384. */
  73385. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73386. /**
  73387. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73388. * @param gradient defines the gradient to use (between 0 and 1)
  73389. * @param factor defines the start size to affect to the specified gradient
  73390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73391. * @returns the current particle system
  73392. */
  73393. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73394. /**
  73395. * Remove a specific start size gradient
  73396. * @param gradient defines the gradient to remove
  73397. * @returns the current particle system
  73398. */
  73399. removeStartSizeGradient(gradient: number): IParticleSystem;
  73400. /**
  73401. * Gets the current list of start size gradients.
  73402. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73403. * @returns the list of start size gradients
  73404. */
  73405. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73406. /**
  73407. * Adds a new life time gradient
  73408. * @param gradient defines the gradient to use (between 0 and 1)
  73409. * @param factor defines the life time factor to affect to the specified gradient
  73410. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73411. * @returns the current particle system
  73412. */
  73413. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73414. /**
  73415. * Remove a specific life time gradient
  73416. * @param gradient defines the gradient to remove
  73417. * @returns the current particle system
  73418. */
  73419. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73420. /**
  73421. * Gets the current list of life time gradients.
  73422. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73423. * @returns the list of life time gradients
  73424. */
  73425. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73426. /**
  73427. * Gets the current list of color gradients.
  73428. * You must use addColorGradient and removeColorGradient to udpate this list
  73429. * @returns the list of color gradients
  73430. */
  73431. getColorGradients(): Nullable<Array<ColorGradient>>;
  73432. /**
  73433. * Adds a new ramp gradient used to remap particle colors
  73434. * @param gradient defines the gradient to use (between 0 and 1)
  73435. * @param color defines the color to affect to the specified gradient
  73436. * @returns the current particle system
  73437. */
  73438. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73439. /**
  73440. * Gets the current list of ramp gradients.
  73441. * You must use addRampGradient and removeRampGradient to udpate this list
  73442. * @returns the list of ramp gradients
  73443. */
  73444. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73445. /** Gets or sets a boolean indicating that ramp gradients must be used
  73446. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73447. */
  73448. useRampGradients: boolean;
  73449. /**
  73450. * Adds a new color remap gradient
  73451. * @param gradient defines the gradient to use (between 0 and 1)
  73452. * @param min defines the color remap minimal range
  73453. * @param max defines the color remap maximal range
  73454. * @returns the current particle system
  73455. */
  73456. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73457. /**
  73458. * Gets the current list of color remap gradients.
  73459. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73460. * @returns the list of color remap gradients
  73461. */
  73462. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73463. /**
  73464. * Adds a new alpha remap gradient
  73465. * @param gradient defines the gradient to use (between 0 and 1)
  73466. * @param min defines the alpha remap minimal range
  73467. * @param max defines the alpha remap maximal range
  73468. * @returns the current particle system
  73469. */
  73470. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73471. /**
  73472. * Gets the current list of alpha remap gradients.
  73473. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73474. * @returns the list of alpha remap gradients
  73475. */
  73476. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73477. /**
  73478. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73479. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73480. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73481. * @returns the emitter
  73482. */
  73483. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73484. /**
  73485. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73486. * @param radius The radius of the hemisphere to emit from
  73487. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73488. * @returns the emitter
  73489. */
  73490. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73491. /**
  73492. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73493. * @param radius The radius of the sphere to emit from
  73494. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73495. * @returns the emitter
  73496. */
  73497. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73498. /**
  73499. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73500. * @param radius The radius of the sphere to emit from
  73501. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73502. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73503. * @returns the emitter
  73504. */
  73505. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73506. /**
  73507. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73508. * @param radius The radius of the emission cylinder
  73509. * @param height The height of the emission cylinder
  73510. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73511. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73512. * @returns the emitter
  73513. */
  73514. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73515. /**
  73516. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73517. * @param radius The radius of the cylinder to emit from
  73518. * @param height The height of the emission cylinder
  73519. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73520. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73521. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73522. * @returns the emitter
  73523. */
  73524. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73525. /**
  73526. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73527. * @param radius The radius of the cone to emit from
  73528. * @param angle The base angle of the cone
  73529. * @returns the emitter
  73530. */
  73531. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73532. /**
  73533. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73534. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73535. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73536. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73537. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73538. * @returns the emitter
  73539. */
  73540. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73541. /**
  73542. * Get hosting scene
  73543. * @returns the scene
  73544. */
  73545. getScene(): Scene;
  73546. }
  73547. }
  73548. declare module BABYLON {
  73549. /**
  73550. * Creates an instance based on a source mesh.
  73551. */
  73552. export class InstancedMesh extends AbstractMesh {
  73553. private _sourceMesh;
  73554. private _currentLOD;
  73555. /** @hidden */
  73556. _indexInSourceMeshInstanceArray: number;
  73557. constructor(name: string, source: Mesh);
  73558. /**
  73559. * Returns the string "InstancedMesh".
  73560. */
  73561. getClassName(): string;
  73562. /**
  73563. * If the source mesh receives shadows
  73564. */
  73565. readonly receiveShadows: boolean;
  73566. /**
  73567. * The material of the source mesh
  73568. */
  73569. readonly material: Nullable<Material>;
  73570. /**
  73571. * Visibility of the source mesh
  73572. */
  73573. readonly visibility: number;
  73574. /**
  73575. * Skeleton of the source mesh
  73576. */
  73577. readonly skeleton: Nullable<Skeleton>;
  73578. /**
  73579. * Rendering ground id of the source mesh
  73580. */
  73581. renderingGroupId: number;
  73582. /**
  73583. * Returns the total number of vertices (integer).
  73584. */
  73585. getTotalVertices(): number;
  73586. /**
  73587. * Returns a positive integer : the total number of indices in this mesh geometry.
  73588. * @returns the numner of indices or zero if the mesh has no geometry.
  73589. */
  73590. getTotalIndices(): number;
  73591. /**
  73592. * The source mesh of the instance
  73593. */
  73594. readonly sourceMesh: Mesh;
  73595. /**
  73596. * Is this node ready to be used/rendered
  73597. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  73598. * @return {boolean} is it ready
  73599. */
  73600. isReady(completeCheck?: boolean): boolean;
  73601. /**
  73602. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  73603. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  73604. * @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.
  73605. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  73606. */
  73607. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  73608. /**
  73609. * Sets the vertex data of the mesh geometry for the requested `kind`.
  73610. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  73611. * The `data` are either a numeric array either a Float32Array.
  73612. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  73613. * 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).
  73614. * Note that a new underlying VertexBuffer object is created each call.
  73615. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  73616. *
  73617. * Possible `kind` values :
  73618. * - VertexBuffer.PositionKind
  73619. * - VertexBuffer.UVKind
  73620. * - VertexBuffer.UV2Kind
  73621. * - VertexBuffer.UV3Kind
  73622. * - VertexBuffer.UV4Kind
  73623. * - VertexBuffer.UV5Kind
  73624. * - VertexBuffer.UV6Kind
  73625. * - VertexBuffer.ColorKind
  73626. * - VertexBuffer.MatricesIndicesKind
  73627. * - VertexBuffer.MatricesIndicesExtraKind
  73628. * - VertexBuffer.MatricesWeightsKind
  73629. * - VertexBuffer.MatricesWeightsExtraKind
  73630. *
  73631. * Returns the Mesh.
  73632. */
  73633. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  73634. /**
  73635. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  73636. * If the mesh has no geometry, it is simply returned as it is.
  73637. * The `data` are either a numeric array either a Float32Array.
  73638. * No new underlying VertexBuffer object is created.
  73639. * 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.
  73640. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  73641. *
  73642. * Possible `kind` values :
  73643. * - VertexBuffer.PositionKind
  73644. * - VertexBuffer.UVKind
  73645. * - VertexBuffer.UV2Kind
  73646. * - VertexBuffer.UV3Kind
  73647. * - VertexBuffer.UV4Kind
  73648. * - VertexBuffer.UV5Kind
  73649. * - VertexBuffer.UV6Kind
  73650. * - VertexBuffer.ColorKind
  73651. * - VertexBuffer.MatricesIndicesKind
  73652. * - VertexBuffer.MatricesIndicesExtraKind
  73653. * - VertexBuffer.MatricesWeightsKind
  73654. * - VertexBuffer.MatricesWeightsExtraKind
  73655. *
  73656. * Returns the Mesh.
  73657. */
  73658. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  73659. /**
  73660. * Sets the mesh indices.
  73661. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  73662. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  73663. * This method creates a new index buffer each call.
  73664. * Returns the Mesh.
  73665. */
  73666. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  73667. /**
  73668. * Boolean : True if the mesh owns the requested kind of data.
  73669. */
  73670. isVerticesDataPresent(kind: string): boolean;
  73671. /**
  73672. * Returns an array of indices (IndicesArray).
  73673. */
  73674. getIndices(): Nullable<IndicesArray>;
  73675. readonly _positions: Nullable<Vector3[]>;
  73676. /**
  73677. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  73678. * This means the mesh underlying bounding box and sphere are recomputed.
  73679. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  73680. * @returns the current mesh
  73681. */
  73682. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  73683. /** @hidden */
  73684. _preActivate(): InstancedMesh;
  73685. /** @hidden */
  73686. _activate(renderId: number): InstancedMesh;
  73687. /**
  73688. * Returns the current associated LOD AbstractMesh.
  73689. */
  73690. getLOD(camera: Camera): AbstractMesh;
  73691. /** @hidden */
  73692. _syncSubMeshes(): InstancedMesh;
  73693. /** @hidden */
  73694. _generatePointsArray(): boolean;
  73695. /**
  73696. * Creates a new InstancedMesh from the current mesh.
  73697. * - name (string) : the cloned mesh name
  73698. * - newParent (optional Node) : the optional Node to parent the clone to.
  73699. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  73700. *
  73701. * Returns the clone.
  73702. */
  73703. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  73704. /**
  73705. * Disposes the InstancedMesh.
  73706. * Returns nothing.
  73707. */
  73708. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73709. }
  73710. }
  73711. declare module BABYLON {
  73712. /**
  73713. * Defines the options associated with the creation of a shader material.
  73714. */
  73715. export interface IShaderMaterialOptions {
  73716. /**
  73717. * Does the material work in alpha blend mode
  73718. */
  73719. needAlphaBlending: boolean;
  73720. /**
  73721. * Does the material work in alpha test mode
  73722. */
  73723. needAlphaTesting: boolean;
  73724. /**
  73725. * The list of attribute names used in the shader
  73726. */
  73727. attributes: string[];
  73728. /**
  73729. * The list of unifrom names used in the shader
  73730. */
  73731. uniforms: string[];
  73732. /**
  73733. * The list of UBO names used in the shader
  73734. */
  73735. uniformBuffers: string[];
  73736. /**
  73737. * The list of sampler names used in the shader
  73738. */
  73739. samplers: string[];
  73740. /**
  73741. * The list of defines used in the shader
  73742. */
  73743. defines: string[];
  73744. }
  73745. /**
  73746. * 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.
  73747. *
  73748. * This returned material effects how the mesh will look based on the code in the shaders.
  73749. *
  73750. * @see http://doc.babylonjs.com/how_to/shader_material
  73751. */
  73752. export class ShaderMaterial extends Material {
  73753. private _shaderPath;
  73754. private _options;
  73755. private _textures;
  73756. private _textureArrays;
  73757. private _floats;
  73758. private _ints;
  73759. private _floatsArrays;
  73760. private _colors3;
  73761. private _colors3Arrays;
  73762. private _colors4;
  73763. private _vectors2;
  73764. private _vectors3;
  73765. private _vectors4;
  73766. private _matrices;
  73767. private _matrices3x3;
  73768. private _matrices2x2;
  73769. private _vectors2Arrays;
  73770. private _vectors3Arrays;
  73771. private _cachedWorldViewMatrix;
  73772. private _renderId;
  73773. /**
  73774. * Instantiate a new shader material.
  73775. * 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.
  73776. * This returned material effects how the mesh will look based on the code in the shaders.
  73777. * @see http://doc.babylonjs.com/how_to/shader_material
  73778. * @param name Define the name of the material in the scene
  73779. * @param scene Define the scene the material belongs to
  73780. * @param shaderPath Defines the route to the shader code in one of three ways:
  73781. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  73782. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  73783. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  73784. * @param options Define the options used to create the shader
  73785. */
  73786. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  73787. /**
  73788. * Gets the current class name of the material e.g. "ShaderMaterial"
  73789. * Mainly use in serialization.
  73790. * @returns the class name
  73791. */
  73792. getClassName(): string;
  73793. /**
  73794. * Specifies if the material will require alpha blending
  73795. * @returns a boolean specifying if alpha blending is needed
  73796. */
  73797. needAlphaBlending(): boolean;
  73798. /**
  73799. * Specifies if this material should be rendered in alpha test mode
  73800. * @returns a boolean specifying if an alpha test is needed.
  73801. */
  73802. needAlphaTesting(): boolean;
  73803. private _checkUniform;
  73804. /**
  73805. * Set a texture in the shader.
  73806. * @param name Define the name of the uniform samplers as defined in the shader
  73807. * @param texture Define the texture to bind to this sampler
  73808. * @return the material itself allowing "fluent" like uniform updates
  73809. */
  73810. setTexture(name: string, texture: Texture): ShaderMaterial;
  73811. /**
  73812. * Set a texture array in the shader.
  73813. * @param name Define the name of the uniform sampler array as defined in the shader
  73814. * @param textures Define the list of textures to bind to this sampler
  73815. * @return the material itself allowing "fluent" like uniform updates
  73816. */
  73817. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  73818. /**
  73819. * Set a float in the shader.
  73820. * @param name Define the name of the uniform as defined in the shader
  73821. * @param value Define the value to give to the uniform
  73822. * @return the material itself allowing "fluent" like uniform updates
  73823. */
  73824. setFloat(name: string, value: number): ShaderMaterial;
  73825. /**
  73826. * Set a int in the shader.
  73827. * @param name Define the name of the uniform as defined in the shader
  73828. * @param value Define the value to give to the uniform
  73829. * @return the material itself allowing "fluent" like uniform updates
  73830. */
  73831. setInt(name: string, value: number): ShaderMaterial;
  73832. /**
  73833. * Set an array of floats in the shader.
  73834. * @param name Define the name of the uniform as defined in the shader
  73835. * @param value Define the value to give to the uniform
  73836. * @return the material itself allowing "fluent" like uniform updates
  73837. */
  73838. setFloats(name: string, value: number[]): ShaderMaterial;
  73839. /**
  73840. * Set a vec3 in the shader from a Color3.
  73841. * @param name Define the name of the uniform as defined in the shader
  73842. * @param value Define the value to give to the uniform
  73843. * @return the material itself allowing "fluent" like uniform updates
  73844. */
  73845. setColor3(name: string, value: Color3): ShaderMaterial;
  73846. /**
  73847. * Set a vec3 array in the shader from a Color3 array.
  73848. * @param name Define the name of the uniform as defined in the shader
  73849. * @param value Define the value to give to the uniform
  73850. * @return the material itself allowing "fluent" like uniform updates
  73851. */
  73852. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  73853. /**
  73854. * Set a vec4 in the shader from a Color4.
  73855. * @param name Define the name of the uniform as defined in the shader
  73856. * @param value Define the value to give to the uniform
  73857. * @return the material itself allowing "fluent" like uniform updates
  73858. */
  73859. setColor4(name: string, value: Color4): ShaderMaterial;
  73860. /**
  73861. * Set a vec2 in the shader from a Vector2.
  73862. * @param name Define the name of the uniform as defined in the shader
  73863. * @param value Define the value to give to the uniform
  73864. * @return the material itself allowing "fluent" like uniform updates
  73865. */
  73866. setVector2(name: string, value: Vector2): ShaderMaterial;
  73867. /**
  73868. * Set a vec3 in the shader from a Vector3.
  73869. * @param name Define the name of the uniform as defined in the shader
  73870. * @param value Define the value to give to the uniform
  73871. * @return the material itself allowing "fluent" like uniform updates
  73872. */
  73873. setVector3(name: string, value: Vector3): ShaderMaterial;
  73874. /**
  73875. * Set a vec4 in the shader from a Vector4.
  73876. * @param name Define the name of the uniform as defined in the shader
  73877. * @param value Define the value to give to the uniform
  73878. * @return the material itself allowing "fluent" like uniform updates
  73879. */
  73880. setVector4(name: string, value: Vector4): ShaderMaterial;
  73881. /**
  73882. * Set a mat4 in the shader from a Matrix.
  73883. * @param name Define the name of the uniform as defined in the shader
  73884. * @param value Define the value to give to the uniform
  73885. * @return the material itself allowing "fluent" like uniform updates
  73886. */
  73887. setMatrix(name: string, value: Matrix): ShaderMaterial;
  73888. /**
  73889. * Set a mat3 in the shader from a Float32Array.
  73890. * @param name Define the name of the uniform as defined in the shader
  73891. * @param value Define the value to give to the uniform
  73892. * @return the material itself allowing "fluent" like uniform updates
  73893. */
  73894. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  73895. /**
  73896. * Set a mat2 in the shader from a Float32Array.
  73897. * @param name Define the name of the uniform as defined in the shader
  73898. * @param value Define the value to give to the uniform
  73899. * @return the material itself allowing "fluent" like uniform updates
  73900. */
  73901. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  73902. /**
  73903. * Set a vec2 array in the shader from a number array.
  73904. * @param name Define the name of the uniform as defined in the shader
  73905. * @param value Define the value to give to the uniform
  73906. * @return the material itself allowing "fluent" like uniform updates
  73907. */
  73908. setArray2(name: string, value: number[]): ShaderMaterial;
  73909. /**
  73910. * Set a vec3 array in the shader from a number array.
  73911. * @param name Define the name of the uniform as defined in the shader
  73912. * @param value Define the value to give to the uniform
  73913. * @return the material itself allowing "fluent" like uniform updates
  73914. */
  73915. setArray3(name: string, value: number[]): ShaderMaterial;
  73916. private _checkCache;
  73917. /**
  73918. * Checks if the material is ready to render the requested mesh
  73919. * @param mesh Define the mesh to render
  73920. * @param useInstances Define whether or not the material is used with instances
  73921. * @returns true if ready, otherwise false
  73922. */
  73923. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  73924. /**
  73925. * Binds the world matrix to the material
  73926. * @param world defines the world transformation matrix
  73927. */
  73928. bindOnlyWorldMatrix(world: Matrix): void;
  73929. /**
  73930. * Binds the material to the mesh
  73931. * @param world defines the world transformation matrix
  73932. * @param mesh defines the mesh to bind the material to
  73933. */
  73934. bind(world: Matrix, mesh?: Mesh): void;
  73935. /**
  73936. * Gets the active textures from the material
  73937. * @returns an array of textures
  73938. */
  73939. getActiveTextures(): BaseTexture[];
  73940. /**
  73941. * Specifies if the material uses a texture
  73942. * @param texture defines the texture to check against the material
  73943. * @returns a boolean specifying if the material uses the texture
  73944. */
  73945. hasTexture(texture: BaseTexture): boolean;
  73946. /**
  73947. * Makes a duplicate of the material, and gives it a new name
  73948. * @param name defines the new name for the duplicated material
  73949. * @returns the cloned material
  73950. */
  73951. clone(name: string): ShaderMaterial;
  73952. /**
  73953. * Disposes the material
  73954. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  73955. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  73956. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  73957. */
  73958. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  73959. /**
  73960. * Serializes this material in a JSON representation
  73961. * @returns the serialized material object
  73962. */
  73963. serialize(): any;
  73964. /**
  73965. * Creates a shader material from parsed shader material data
  73966. * @param source defines the JSON represnetation of the material
  73967. * @param scene defines the hosting scene
  73968. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73969. * @returns a new material
  73970. */
  73971. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  73972. }
  73973. }
  73974. declare module BABYLON {
  73975. /** @hidden */
  73976. export var colorPixelShader: {
  73977. name: string;
  73978. shader: string;
  73979. };
  73980. }
  73981. declare module BABYLON {
  73982. /** @hidden */
  73983. export var colorVertexShader: {
  73984. name: string;
  73985. shader: string;
  73986. };
  73987. }
  73988. declare module BABYLON {
  73989. /**
  73990. * Line mesh
  73991. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  73992. */
  73993. export class LinesMesh extends Mesh {
  73994. /**
  73995. * If vertex color should be applied to the mesh
  73996. */
  73997. useVertexColor?: boolean | undefined;
  73998. /**
  73999. * If vertex alpha should be applied to the mesh
  74000. */
  74001. useVertexAlpha?: boolean | undefined;
  74002. /**
  74003. * Color of the line (Default: White)
  74004. */
  74005. color: Color3;
  74006. /**
  74007. * Alpha of the line (Default: 1)
  74008. */
  74009. alpha: number;
  74010. /**
  74011. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74012. * This margin is expressed in world space coordinates, so its value may vary.
  74013. * Default value is 0.1
  74014. */
  74015. intersectionThreshold: number;
  74016. private _colorShader;
  74017. /**
  74018. * Creates a new LinesMesh
  74019. * @param name defines the name
  74020. * @param scene defines the hosting scene
  74021. * @param parent defines the parent mesh if any
  74022. * @param source defines the optional source LinesMesh used to clone data from
  74023. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74024. * When false, achieved by calling a clone(), also passing False.
  74025. * This will make creation of children, recursive.
  74026. * @param useVertexColor defines if this LinesMesh supports vertex color
  74027. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74028. */
  74029. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74030. /**
  74031. * If vertex color should be applied to the mesh
  74032. */
  74033. useVertexColor?: boolean | undefined,
  74034. /**
  74035. * If vertex alpha should be applied to the mesh
  74036. */
  74037. useVertexAlpha?: boolean | undefined);
  74038. /**
  74039. * Returns the string "LineMesh"
  74040. */
  74041. getClassName(): string;
  74042. /**
  74043. * @hidden
  74044. */
  74045. /**
  74046. * @hidden
  74047. */
  74048. material: Material;
  74049. /**
  74050. * @hidden
  74051. */
  74052. readonly checkCollisions: boolean;
  74053. /** @hidden */
  74054. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74055. /** @hidden */
  74056. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74057. /**
  74058. * Disposes of the line mesh
  74059. * @param doNotRecurse If children should be disposed
  74060. */
  74061. dispose(doNotRecurse?: boolean): void;
  74062. /**
  74063. * Returns a new LineMesh object cloned from the current one.
  74064. */
  74065. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74066. /**
  74067. * Creates a new InstancedLinesMesh object from the mesh model.
  74068. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74069. * @param name defines the name of the new instance
  74070. * @returns a new InstancedLinesMesh
  74071. */
  74072. createInstance(name: string): InstancedLinesMesh;
  74073. }
  74074. /**
  74075. * Creates an instance based on a source LinesMesh
  74076. */
  74077. export class InstancedLinesMesh extends InstancedMesh {
  74078. /**
  74079. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74080. * This margin is expressed in world space coordinates, so its value may vary.
  74081. * Initilized with the intersectionThreshold value of the source LinesMesh
  74082. */
  74083. intersectionThreshold: number;
  74084. constructor(name: string, source: LinesMesh);
  74085. /**
  74086. * Returns the string "InstancedLinesMesh".
  74087. */
  74088. getClassName(): string;
  74089. }
  74090. }
  74091. declare module BABYLON {
  74092. /** @hidden */
  74093. export var linePixelShader: {
  74094. name: string;
  74095. shader: string;
  74096. };
  74097. }
  74098. declare module BABYLON {
  74099. /** @hidden */
  74100. export var lineVertexShader: {
  74101. name: string;
  74102. shader: string;
  74103. };
  74104. }
  74105. declare module BABYLON {
  74106. interface AbstractMesh {
  74107. /**
  74108. * Disables the mesh edge rendering mode
  74109. * @returns the currentAbstractMesh
  74110. */
  74111. disableEdgesRendering(): AbstractMesh;
  74112. /**
  74113. * Enables the edge rendering mode on the mesh.
  74114. * This mode makes the mesh edges visible
  74115. * @param epsilon defines the maximal distance between two angles to detect a face
  74116. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74117. * @returns the currentAbstractMesh
  74118. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74119. */
  74120. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74121. /**
  74122. * Gets the edgesRenderer associated with the mesh
  74123. */
  74124. edgesRenderer: Nullable<EdgesRenderer>;
  74125. }
  74126. interface LinesMesh {
  74127. /**
  74128. * Enables the edge rendering mode on the mesh.
  74129. * This mode makes the mesh edges visible
  74130. * @param epsilon defines the maximal distance between two angles to detect a face
  74131. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74132. * @returns the currentAbstractMesh
  74133. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74134. */
  74135. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74136. }
  74137. interface InstancedLinesMesh {
  74138. /**
  74139. * Enables the edge rendering mode on the mesh.
  74140. * This mode makes the mesh edges visible
  74141. * @param epsilon defines the maximal distance between two angles to detect a face
  74142. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74143. * @returns the current InstancedLinesMesh
  74144. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74145. */
  74146. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74147. }
  74148. /**
  74149. * Defines the minimum contract an Edges renderer should follow.
  74150. */
  74151. export interface IEdgesRenderer extends IDisposable {
  74152. /**
  74153. * Gets or sets a boolean indicating if the edgesRenderer is active
  74154. */
  74155. isEnabled: boolean;
  74156. /**
  74157. * Renders the edges of the attached mesh,
  74158. */
  74159. render(): void;
  74160. /**
  74161. * Checks wether or not the edges renderer is ready to render.
  74162. * @return true if ready, otherwise false.
  74163. */
  74164. isReady(): boolean;
  74165. }
  74166. /**
  74167. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74168. */
  74169. export class EdgesRenderer implements IEdgesRenderer {
  74170. /**
  74171. * Define the size of the edges with an orthographic camera
  74172. */
  74173. edgesWidthScalerForOrthographic: number;
  74174. /**
  74175. * Define the size of the edges with a perspective camera
  74176. */
  74177. edgesWidthScalerForPerspective: number;
  74178. protected _source: AbstractMesh;
  74179. protected _linesPositions: number[];
  74180. protected _linesNormals: number[];
  74181. protected _linesIndices: number[];
  74182. protected _epsilon: number;
  74183. protected _indicesCount: number;
  74184. protected _lineShader: ShaderMaterial;
  74185. protected _ib: WebGLBuffer;
  74186. protected _buffers: {
  74187. [key: string]: Nullable<VertexBuffer>;
  74188. };
  74189. protected _checkVerticesInsteadOfIndices: boolean;
  74190. private _meshRebuildObserver;
  74191. private _meshDisposeObserver;
  74192. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74193. isEnabled: boolean;
  74194. /**
  74195. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74196. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74197. * @param source Mesh used to create edges
  74198. * @param epsilon sum of angles in adjacency to check for edge
  74199. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74200. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74201. */
  74202. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74203. protected _prepareRessources(): void;
  74204. /** @hidden */
  74205. _rebuild(): void;
  74206. /**
  74207. * Releases the required resources for the edges renderer
  74208. */
  74209. dispose(): void;
  74210. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74211. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74212. /**
  74213. * Checks if the pair of p0 and p1 is en edge
  74214. * @param faceIndex
  74215. * @param edge
  74216. * @param faceNormals
  74217. * @param p0
  74218. * @param p1
  74219. * @private
  74220. */
  74221. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74222. /**
  74223. * push line into the position, normal and index buffer
  74224. * @protected
  74225. */
  74226. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74227. /**
  74228. * Generates lines edges from adjacencjes
  74229. * @private
  74230. */
  74231. _generateEdgesLines(): void;
  74232. /**
  74233. * Checks wether or not the edges renderer is ready to render.
  74234. * @return true if ready, otherwise false.
  74235. */
  74236. isReady(): boolean;
  74237. /**
  74238. * Renders the edges of the attached mesh,
  74239. */
  74240. render(): void;
  74241. }
  74242. /**
  74243. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74244. */
  74245. export class LineEdgesRenderer extends EdgesRenderer {
  74246. /**
  74247. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74248. * @param source LineMesh used to generate edges
  74249. * @param epsilon not important (specified angle for edge detection)
  74250. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74251. */
  74252. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74253. /**
  74254. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74255. */
  74256. _generateEdgesLines(): void;
  74257. }
  74258. }
  74259. declare module BABYLON {
  74260. /**
  74261. * This represents the object necessary to create a rendering group.
  74262. * This is exclusively used and created by the rendering manager.
  74263. * To modify the behavior, you use the available helpers in your scene or meshes.
  74264. * @hidden
  74265. */
  74266. export class RenderingGroup {
  74267. index: number;
  74268. private _scene;
  74269. private _opaqueSubMeshes;
  74270. private _transparentSubMeshes;
  74271. private _alphaTestSubMeshes;
  74272. private _depthOnlySubMeshes;
  74273. private _particleSystems;
  74274. private _spriteManagers;
  74275. private _opaqueSortCompareFn;
  74276. private _alphaTestSortCompareFn;
  74277. private _transparentSortCompareFn;
  74278. private _renderOpaque;
  74279. private _renderAlphaTest;
  74280. private _renderTransparent;
  74281. private _edgesRenderers;
  74282. onBeforeTransparentRendering: () => void;
  74283. /**
  74284. * Set the opaque sort comparison function.
  74285. * If null the sub meshes will be render in the order they were created
  74286. */
  74287. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74288. /**
  74289. * Set the alpha test sort comparison function.
  74290. * If null the sub meshes will be render in the order they were created
  74291. */
  74292. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74293. /**
  74294. * Set the transparent sort comparison function.
  74295. * If null the sub meshes will be render in the order they were created
  74296. */
  74297. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74298. /**
  74299. * Creates a new rendering group.
  74300. * @param index The rendering group index
  74301. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74302. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74303. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74304. */
  74305. 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>);
  74306. /**
  74307. * Render all the sub meshes contained in the group.
  74308. * @param customRenderFunction Used to override the default render behaviour of the group.
  74309. * @returns true if rendered some submeshes.
  74310. */
  74311. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74312. /**
  74313. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74314. * @param subMeshes The submeshes to render
  74315. */
  74316. private renderOpaqueSorted;
  74317. /**
  74318. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74319. * @param subMeshes The submeshes to render
  74320. */
  74321. private renderAlphaTestSorted;
  74322. /**
  74323. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74324. * @param subMeshes The submeshes to render
  74325. */
  74326. private renderTransparentSorted;
  74327. /**
  74328. * Renders the submeshes in a specified order.
  74329. * @param subMeshes The submeshes to sort before render
  74330. * @param sortCompareFn The comparison function use to sort
  74331. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74332. * @param transparent Specifies to activate blending if true
  74333. */
  74334. private static renderSorted;
  74335. /**
  74336. * Renders the submeshes in the order they were dispatched (no sort applied).
  74337. * @param subMeshes The submeshes to render
  74338. */
  74339. private static renderUnsorted;
  74340. /**
  74341. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74342. * are rendered back to front if in the same alpha index.
  74343. *
  74344. * @param a The first submesh
  74345. * @param b The second submesh
  74346. * @returns The result of the comparison
  74347. */
  74348. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74349. /**
  74350. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74351. * are rendered back to front.
  74352. *
  74353. * @param a The first submesh
  74354. * @param b The second submesh
  74355. * @returns The result of the comparison
  74356. */
  74357. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74358. /**
  74359. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74360. * are rendered front to back (prevent overdraw).
  74361. *
  74362. * @param a The first submesh
  74363. * @param b The second submesh
  74364. * @returns The result of the comparison
  74365. */
  74366. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74367. /**
  74368. * Resets the different lists of submeshes to prepare a new frame.
  74369. */
  74370. prepare(): void;
  74371. dispose(): void;
  74372. /**
  74373. * Inserts the submesh in its correct queue depending on its material.
  74374. * @param subMesh The submesh to dispatch
  74375. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74376. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74377. */
  74378. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74379. dispatchSprites(spriteManager: ISpriteManager): void;
  74380. dispatchParticles(particleSystem: IParticleSystem): void;
  74381. private _renderParticles;
  74382. private _renderSprites;
  74383. }
  74384. }
  74385. declare module BABYLON {
  74386. /**
  74387. * Interface describing the different options available in the rendering manager
  74388. * regarding Auto Clear between groups.
  74389. */
  74390. export interface IRenderingManagerAutoClearSetup {
  74391. /**
  74392. * Defines whether or not autoclear is enable.
  74393. */
  74394. autoClear: boolean;
  74395. /**
  74396. * Defines whether or not to autoclear the depth buffer.
  74397. */
  74398. depth: boolean;
  74399. /**
  74400. * Defines whether or not to autoclear the stencil buffer.
  74401. */
  74402. stencil: boolean;
  74403. }
  74404. /**
  74405. * This class is used by the onRenderingGroupObservable
  74406. */
  74407. export class RenderingGroupInfo {
  74408. /**
  74409. * The Scene that being rendered
  74410. */
  74411. scene: Scene;
  74412. /**
  74413. * The camera currently used for the rendering pass
  74414. */
  74415. camera: Nullable<Camera>;
  74416. /**
  74417. * The ID of the renderingGroup being processed
  74418. */
  74419. renderingGroupId: number;
  74420. }
  74421. /**
  74422. * This is the manager responsible of all the rendering for meshes sprites and particles.
  74423. * It is enable to manage the different groups as well as the different necessary sort functions.
  74424. * This should not be used directly aside of the few static configurations
  74425. */
  74426. export class RenderingManager {
  74427. /**
  74428. * The max id used for rendering groups (not included)
  74429. */
  74430. static MAX_RENDERINGGROUPS: number;
  74431. /**
  74432. * The min id used for rendering groups (included)
  74433. */
  74434. static MIN_RENDERINGGROUPS: number;
  74435. /**
  74436. * Used to globally prevent autoclearing scenes.
  74437. */
  74438. static AUTOCLEAR: boolean;
  74439. /**
  74440. * @hidden
  74441. */
  74442. _useSceneAutoClearSetup: boolean;
  74443. private _scene;
  74444. private _renderingGroups;
  74445. private _depthStencilBufferAlreadyCleaned;
  74446. private _autoClearDepthStencil;
  74447. private _customOpaqueSortCompareFn;
  74448. private _customAlphaTestSortCompareFn;
  74449. private _customTransparentSortCompareFn;
  74450. private _renderingGroupInfo;
  74451. /**
  74452. * Instantiates a new rendering group for a particular scene
  74453. * @param scene Defines the scene the groups belongs to
  74454. */
  74455. constructor(scene: Scene);
  74456. private _clearDepthStencilBuffer;
  74457. /**
  74458. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  74459. * @hidden
  74460. */
  74461. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  74462. /**
  74463. * Resets the different information of the group to prepare a new frame
  74464. * @hidden
  74465. */
  74466. reset(): void;
  74467. /**
  74468. * Dispose and release the group and its associated resources.
  74469. * @hidden
  74470. */
  74471. dispose(): void;
  74472. /**
  74473. * Clear the info related to rendering groups preventing retention points during dispose.
  74474. */
  74475. freeRenderingGroups(): void;
  74476. private _prepareRenderingGroup;
  74477. /**
  74478. * Add a sprite manager to the rendering manager in order to render it this frame.
  74479. * @param spriteManager Define the sprite manager to render
  74480. */
  74481. dispatchSprites(spriteManager: ISpriteManager): void;
  74482. /**
  74483. * Add a particle system to the rendering manager in order to render it this frame.
  74484. * @param particleSystem Define the particle system to render
  74485. */
  74486. dispatchParticles(particleSystem: IParticleSystem): void;
  74487. /**
  74488. * Add a submesh to the manager in order to render it this frame
  74489. * @param subMesh The submesh to dispatch
  74490. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74491. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74492. */
  74493. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74494. /**
  74495. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74496. * This allowed control for front to back rendering or reversly depending of the special needs.
  74497. *
  74498. * @param renderingGroupId The rendering group id corresponding to its index
  74499. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74500. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74501. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74502. */
  74503. 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;
  74504. /**
  74505. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74506. *
  74507. * @param renderingGroupId The rendering group id corresponding to its index
  74508. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74509. * @param depth Automatically clears depth between groups if true and autoClear is true.
  74510. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  74511. */
  74512. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  74513. /**
  74514. * Gets the current auto clear configuration for one rendering group of the rendering
  74515. * manager.
  74516. * @param index the rendering group index to get the information for
  74517. * @returns The auto clear setup for the requested rendering group
  74518. */
  74519. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  74520. }
  74521. }
  74522. declare module BABYLON {
  74523. /**
  74524. * This Helps creating a texture that will be created from a camera in your scene.
  74525. * It is basically a dynamic texture that could be used to create special effects for instance.
  74526. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  74527. */
  74528. export class RenderTargetTexture extends Texture {
  74529. isCube: boolean;
  74530. /**
  74531. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  74532. */
  74533. static readonly REFRESHRATE_RENDER_ONCE: number;
  74534. /**
  74535. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  74536. */
  74537. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  74538. /**
  74539. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  74540. * the central point of your effect and can save a lot of performances.
  74541. */
  74542. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  74543. /**
  74544. * Use this predicate to dynamically define the list of mesh you want to render.
  74545. * If set, the renderList property will be overwritten.
  74546. */
  74547. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  74548. private _renderList;
  74549. /**
  74550. * Use this list to define the list of mesh you want to render.
  74551. */
  74552. renderList: Nullable<Array<AbstractMesh>>;
  74553. private _hookArray;
  74554. /**
  74555. * Define if particles should be rendered in your texture.
  74556. */
  74557. renderParticles: boolean;
  74558. /**
  74559. * Define if sprites should be rendered in your texture.
  74560. */
  74561. renderSprites: boolean;
  74562. /**
  74563. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  74564. */
  74565. coordinatesMode: number;
  74566. /**
  74567. * Define the camera used to render the texture.
  74568. */
  74569. activeCamera: Nullable<Camera>;
  74570. /**
  74571. * Override the render function of the texture with your own one.
  74572. */
  74573. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  74574. /**
  74575. * Define if camera post processes should be use while rendering the texture.
  74576. */
  74577. useCameraPostProcesses: boolean;
  74578. /**
  74579. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  74580. */
  74581. ignoreCameraViewport: boolean;
  74582. private _postProcessManager;
  74583. private _postProcesses;
  74584. private _resizeObserver;
  74585. /**
  74586. * An event triggered when the texture is unbind.
  74587. */
  74588. onBeforeBindObservable: Observable<RenderTargetTexture>;
  74589. /**
  74590. * An event triggered when the texture is unbind.
  74591. */
  74592. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  74593. private _onAfterUnbindObserver;
  74594. /**
  74595. * Set a after unbind callback in the texture.
  74596. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  74597. */
  74598. onAfterUnbind: () => void;
  74599. /**
  74600. * An event triggered before rendering the texture
  74601. */
  74602. onBeforeRenderObservable: Observable<number>;
  74603. private _onBeforeRenderObserver;
  74604. /**
  74605. * Set a before render callback in the texture.
  74606. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  74607. */
  74608. onBeforeRender: (faceIndex: number) => void;
  74609. /**
  74610. * An event triggered after rendering the texture
  74611. */
  74612. onAfterRenderObservable: Observable<number>;
  74613. private _onAfterRenderObserver;
  74614. /**
  74615. * Set a after render callback in the texture.
  74616. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  74617. */
  74618. onAfterRender: (faceIndex: number) => void;
  74619. /**
  74620. * An event triggered after the texture clear
  74621. */
  74622. onClearObservable: Observable<Engine>;
  74623. private _onClearObserver;
  74624. /**
  74625. * Set a clear callback in the texture.
  74626. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  74627. */
  74628. onClear: (Engine: Engine) => void;
  74629. /**
  74630. * Define the clear color of the Render Target if it should be different from the scene.
  74631. */
  74632. clearColor: Color4;
  74633. protected _size: number | {
  74634. width: number;
  74635. height: number;
  74636. };
  74637. protected _initialSizeParameter: number | {
  74638. width: number;
  74639. height: number;
  74640. } | {
  74641. ratio: number;
  74642. };
  74643. protected _sizeRatio: Nullable<number>;
  74644. /** @hidden */
  74645. _generateMipMaps: boolean;
  74646. protected _renderingManager: RenderingManager;
  74647. /** @hidden */
  74648. _waitingRenderList: string[];
  74649. protected _doNotChangeAspectRatio: boolean;
  74650. protected _currentRefreshId: number;
  74651. protected _refreshRate: number;
  74652. protected _textureMatrix: Matrix;
  74653. protected _samples: number;
  74654. protected _renderTargetOptions: RenderTargetCreationOptions;
  74655. /**
  74656. * Gets render target creation options that were used.
  74657. */
  74658. readonly renderTargetOptions: RenderTargetCreationOptions;
  74659. protected _engine: Engine;
  74660. protected _onRatioRescale(): void;
  74661. /**
  74662. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  74663. * It must define where the camera used to render the texture is set
  74664. */
  74665. boundingBoxPosition: Vector3;
  74666. private _boundingBoxSize;
  74667. /**
  74668. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  74669. * When defined, the cubemap will switch to local mode
  74670. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74671. * @example https://www.babylonjs-playground.com/#RNASML
  74672. */
  74673. boundingBoxSize: Vector3;
  74674. /**
  74675. * In case the RTT has been created with a depth texture, get the associated
  74676. * depth texture.
  74677. * Otherwise, return null.
  74678. */
  74679. depthStencilTexture: Nullable<InternalTexture>;
  74680. /**
  74681. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  74682. * or used a shadow, depth texture...
  74683. * @param name The friendly name of the texture
  74684. * @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)
  74685. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  74686. * @param generateMipMaps True if mip maps need to be generated after render.
  74687. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  74688. * @param type The type of the buffer in the RTT (int, half float, float...)
  74689. * @param isCube True if a cube texture needs to be created
  74690. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  74691. * @param generateDepthBuffer True to generate a depth buffer
  74692. * @param generateStencilBuffer True to generate a stencil buffer
  74693. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  74694. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  74695. * @param delayAllocation if the texture allocation should be delayed (default: false)
  74696. */
  74697. constructor(name: string, size: number | {
  74698. width: number;
  74699. height: number;
  74700. } | {
  74701. ratio: number;
  74702. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  74703. /**
  74704. * Creates a depth stencil texture.
  74705. * This is only available in WebGL 2 or with the depth texture extension available.
  74706. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  74707. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  74708. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  74709. */
  74710. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  74711. private _processSizeParameter;
  74712. /**
  74713. * Define the number of samples to use in case of MSAA.
  74714. * It defaults to one meaning no MSAA has been enabled.
  74715. */
  74716. samples: number;
  74717. /**
  74718. * Resets the refresh counter of the texture and start bak from scratch.
  74719. * Could be useful to regenerate the texture if it is setup to render only once.
  74720. */
  74721. resetRefreshCounter(): void;
  74722. /**
  74723. * Define the refresh rate of the texture or the rendering frequency.
  74724. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74725. */
  74726. refreshRate: number;
  74727. /**
  74728. * Adds a post process to the render target rendering passes.
  74729. * @param postProcess define the post process to add
  74730. */
  74731. addPostProcess(postProcess: PostProcess): void;
  74732. /**
  74733. * Clear all the post processes attached to the render target
  74734. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  74735. */
  74736. clearPostProcesses(dispose?: boolean): void;
  74737. /**
  74738. * Remove one of the post process from the list of attached post processes to the texture
  74739. * @param postProcess define the post process to remove from the list
  74740. */
  74741. removePostProcess(postProcess: PostProcess): void;
  74742. /** @hidden */
  74743. _shouldRender(): boolean;
  74744. /**
  74745. * Gets the actual render size of the texture.
  74746. * @returns the width of the render size
  74747. */
  74748. getRenderSize(): number;
  74749. /**
  74750. * Gets the actual render width of the texture.
  74751. * @returns the width of the render size
  74752. */
  74753. getRenderWidth(): number;
  74754. /**
  74755. * Gets the actual render height of the texture.
  74756. * @returns the height of the render size
  74757. */
  74758. getRenderHeight(): number;
  74759. /**
  74760. * Get if the texture can be rescaled or not.
  74761. */
  74762. readonly canRescale: boolean;
  74763. /**
  74764. * Resize the texture using a ratio.
  74765. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  74766. */
  74767. scale(ratio: number): void;
  74768. /**
  74769. * Get the texture reflection matrix used to rotate/transform the reflection.
  74770. * @returns the reflection matrix
  74771. */
  74772. getReflectionTextureMatrix(): Matrix;
  74773. /**
  74774. * Resize the texture to a new desired size.
  74775. * Be carrefull as it will recreate all the data in the new texture.
  74776. * @param size Define the new size. It can be:
  74777. * - a number for squared texture,
  74778. * - an object containing { width: number, height: number }
  74779. * - or an object containing a ratio { ratio: number }
  74780. */
  74781. resize(size: number | {
  74782. width: number;
  74783. height: number;
  74784. } | {
  74785. ratio: number;
  74786. }): void;
  74787. /**
  74788. * Renders all the objects from the render list into the texture.
  74789. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  74790. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  74791. */
  74792. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  74793. private _bestReflectionRenderTargetDimension;
  74794. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  74795. private renderToTarget;
  74796. /**
  74797. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74798. * This allowed control for front to back rendering or reversly depending of the special needs.
  74799. *
  74800. * @param renderingGroupId The rendering group id corresponding to its index
  74801. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74802. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74803. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74804. */
  74805. 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;
  74806. /**
  74807. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74808. *
  74809. * @param renderingGroupId The rendering group id corresponding to its index
  74810. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74811. */
  74812. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  74813. /**
  74814. * Clones the texture.
  74815. * @returns the cloned texture
  74816. */
  74817. clone(): RenderTargetTexture;
  74818. /**
  74819. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74820. * @returns The JSON representation of the texture
  74821. */
  74822. serialize(): any;
  74823. /**
  74824. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  74825. */
  74826. disposeFramebufferObjects(): void;
  74827. /**
  74828. * Dispose the texture and release its associated resources.
  74829. */
  74830. dispose(): void;
  74831. /** @hidden */
  74832. _rebuild(): void;
  74833. /**
  74834. * Clear the info related to rendering groups preventing retention point in material dispose.
  74835. */
  74836. freeRenderingGroups(): void;
  74837. }
  74838. }
  74839. declare module BABYLON {
  74840. /**
  74841. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74842. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74843. * You can then easily use it as a reflectionTexture on a flat surface.
  74844. * In case the surface is not a plane, please consider relying on reflection probes.
  74845. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74846. */
  74847. export class MirrorTexture extends RenderTargetTexture {
  74848. private scene;
  74849. /**
  74850. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  74851. * 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.
  74852. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74853. */
  74854. mirrorPlane: Plane;
  74855. /**
  74856. * Define the blur ratio used to blur the reflection if needed.
  74857. */
  74858. blurRatio: number;
  74859. /**
  74860. * Define the adaptive blur kernel used to blur the reflection if needed.
  74861. * This will autocompute the closest best match for the `blurKernel`
  74862. */
  74863. adaptiveBlurKernel: number;
  74864. /**
  74865. * Define the blur kernel used to blur the reflection if needed.
  74866. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74867. */
  74868. blurKernel: number;
  74869. /**
  74870. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  74871. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74872. */
  74873. blurKernelX: number;
  74874. /**
  74875. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  74876. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74877. */
  74878. blurKernelY: number;
  74879. private _autoComputeBlurKernel;
  74880. protected _onRatioRescale(): void;
  74881. private _updateGammaSpace;
  74882. private _imageProcessingConfigChangeObserver;
  74883. private _transformMatrix;
  74884. private _mirrorMatrix;
  74885. private _savedViewMatrix;
  74886. private _blurX;
  74887. private _blurY;
  74888. private _adaptiveBlurKernel;
  74889. private _blurKernelX;
  74890. private _blurKernelY;
  74891. private _blurRatio;
  74892. /**
  74893. * Instantiates a Mirror Texture.
  74894. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74895. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74896. * You can then easily use it as a reflectionTexture on a flat surface.
  74897. * In case the surface is not a plane, please consider relying on reflection probes.
  74898. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74899. * @param name
  74900. * @param size
  74901. * @param scene
  74902. * @param generateMipMaps
  74903. * @param type
  74904. * @param samplingMode
  74905. * @param generateDepthBuffer
  74906. */
  74907. constructor(name: string, size: number | {
  74908. width: number;
  74909. height: number;
  74910. } | {
  74911. ratio: number;
  74912. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  74913. private _preparePostProcesses;
  74914. /**
  74915. * Clone the mirror texture.
  74916. * @returns the cloned texture
  74917. */
  74918. clone(): MirrorTexture;
  74919. /**
  74920. * Serialize the texture to a JSON representation you could use in Parse later on
  74921. * @returns the serialized JSON representation
  74922. */
  74923. serialize(): any;
  74924. /**
  74925. * Dispose the texture and release its associated resources.
  74926. */
  74927. dispose(): void;
  74928. }
  74929. }
  74930. declare module BABYLON {
  74931. /**
  74932. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74933. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74934. */
  74935. export class Texture extends BaseTexture {
  74936. /** @hidden */
  74937. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  74938. /** @hidden */
  74939. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  74940. /** @hidden */
  74941. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  74942. /** nearest is mag = nearest and min = nearest and mip = linear */
  74943. static readonly NEAREST_SAMPLINGMODE: number;
  74944. /** nearest is mag = nearest and min = nearest and mip = linear */
  74945. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  74946. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74947. static readonly BILINEAR_SAMPLINGMODE: number;
  74948. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74949. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  74950. /** Trilinear is mag = linear and min = linear and mip = linear */
  74951. static readonly TRILINEAR_SAMPLINGMODE: number;
  74952. /** Trilinear is mag = linear and min = linear and mip = linear */
  74953. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  74954. /** mag = nearest and min = nearest and mip = nearest */
  74955. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  74956. /** mag = nearest and min = linear and mip = nearest */
  74957. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  74958. /** mag = nearest and min = linear and mip = linear */
  74959. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  74960. /** mag = nearest and min = linear and mip = none */
  74961. static readonly NEAREST_LINEAR: number;
  74962. /** mag = nearest and min = nearest and mip = none */
  74963. static readonly NEAREST_NEAREST: number;
  74964. /** mag = linear and min = nearest and mip = nearest */
  74965. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  74966. /** mag = linear and min = nearest and mip = linear */
  74967. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  74968. /** mag = linear and min = linear and mip = none */
  74969. static readonly LINEAR_LINEAR: number;
  74970. /** mag = linear and min = nearest and mip = none */
  74971. static readonly LINEAR_NEAREST: number;
  74972. /** Explicit coordinates mode */
  74973. static readonly EXPLICIT_MODE: number;
  74974. /** Spherical coordinates mode */
  74975. static readonly SPHERICAL_MODE: number;
  74976. /** Planar coordinates mode */
  74977. static readonly PLANAR_MODE: number;
  74978. /** Cubic coordinates mode */
  74979. static readonly CUBIC_MODE: number;
  74980. /** Projection coordinates mode */
  74981. static readonly PROJECTION_MODE: number;
  74982. /** Inverse Cubic coordinates mode */
  74983. static readonly SKYBOX_MODE: number;
  74984. /** Inverse Cubic coordinates mode */
  74985. static readonly INVCUBIC_MODE: number;
  74986. /** Equirectangular coordinates mode */
  74987. static readonly EQUIRECTANGULAR_MODE: number;
  74988. /** Equirectangular Fixed coordinates mode */
  74989. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  74990. /** Equirectangular Fixed Mirrored coordinates mode */
  74991. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74992. /** Texture is not repeating outside of 0..1 UVs */
  74993. static readonly CLAMP_ADDRESSMODE: number;
  74994. /** Texture is repeating outside of 0..1 UVs */
  74995. static readonly WRAP_ADDRESSMODE: number;
  74996. /** Texture is repeating and mirrored */
  74997. static readonly MIRROR_ADDRESSMODE: number;
  74998. /**
  74999. * 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
  75000. */
  75001. static UseSerializedUrlIfAny: boolean;
  75002. /**
  75003. * Define the url of the texture.
  75004. */
  75005. url: Nullable<string>;
  75006. /**
  75007. * Define an offset on the texture to offset the u coordinates of the UVs
  75008. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75009. */
  75010. uOffset: number;
  75011. /**
  75012. * Define an offset on the texture to offset the v coordinates of the UVs
  75013. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75014. */
  75015. vOffset: number;
  75016. /**
  75017. * Define an offset on the texture to scale the u coordinates of the UVs
  75018. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75019. */
  75020. uScale: number;
  75021. /**
  75022. * Define an offset on the texture to scale the v coordinates of the UVs
  75023. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75024. */
  75025. vScale: number;
  75026. /**
  75027. * Define an offset on the texture to rotate around the u coordinates of the UVs
  75028. * @see http://doc.babylonjs.com/how_to/more_materials
  75029. */
  75030. uAng: number;
  75031. /**
  75032. * Define an offset on the texture to rotate around the v coordinates of the UVs
  75033. * @see http://doc.babylonjs.com/how_to/more_materials
  75034. */
  75035. vAng: number;
  75036. /**
  75037. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  75038. * @see http://doc.babylonjs.com/how_to/more_materials
  75039. */
  75040. wAng: number;
  75041. /**
  75042. * Defines the center of rotation (U)
  75043. */
  75044. uRotationCenter: number;
  75045. /**
  75046. * Defines the center of rotation (V)
  75047. */
  75048. vRotationCenter: number;
  75049. /**
  75050. * Defines the center of rotation (W)
  75051. */
  75052. wRotationCenter: number;
  75053. /**
  75054. * Are mip maps generated for this texture or not.
  75055. */
  75056. readonly noMipmap: boolean;
  75057. private _noMipmap;
  75058. /** @hidden */
  75059. _invertY: boolean;
  75060. private _rowGenerationMatrix;
  75061. private _cachedTextureMatrix;
  75062. private _projectionModeMatrix;
  75063. private _t0;
  75064. private _t1;
  75065. private _t2;
  75066. private _cachedUOffset;
  75067. private _cachedVOffset;
  75068. private _cachedUScale;
  75069. private _cachedVScale;
  75070. private _cachedUAng;
  75071. private _cachedVAng;
  75072. private _cachedWAng;
  75073. private _cachedProjectionMatrixId;
  75074. private _cachedCoordinatesMode;
  75075. /** @hidden */
  75076. protected _initialSamplingMode: number;
  75077. /** @hidden */
  75078. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75079. private _deleteBuffer;
  75080. protected _format: Nullable<number>;
  75081. private _delayedOnLoad;
  75082. private _delayedOnError;
  75083. /**
  75084. * Observable triggered once the texture has been loaded.
  75085. */
  75086. onLoadObservable: Observable<Texture>;
  75087. protected _isBlocking: boolean;
  75088. /**
  75089. * Is the texture preventing material to render while loading.
  75090. * If false, a default texture will be used instead of the loading one during the preparation step.
  75091. */
  75092. isBlocking: boolean;
  75093. /**
  75094. * Get the current sampling mode associated with the texture.
  75095. */
  75096. readonly samplingMode: number;
  75097. /**
  75098. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75099. */
  75100. readonly invertY: boolean;
  75101. /**
  75102. * Instantiates a new texture.
  75103. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75104. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75105. * @param url define the url of the picture to load as a texture
  75106. * @param scene define the scene the texture will belong to
  75107. * @param noMipmap define if the texture will require mip maps or not
  75108. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75109. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75110. * @param onLoad define a callback triggered when the texture has been loaded
  75111. * @param onError define a callback triggered when an error occurred during the loading session
  75112. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75113. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75114. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75115. */
  75116. 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);
  75117. /**
  75118. * Update the url (and optional buffer) of this texture if url was null during construction.
  75119. * @param url the url of the texture
  75120. * @param buffer the buffer of the texture (defaults to null)
  75121. * @param onLoad callback called when the texture is loaded (defaults to null)
  75122. */
  75123. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75124. /**
  75125. * Finish the loading sequence of a texture flagged as delayed load.
  75126. * @hidden
  75127. */
  75128. delayLoad(): void;
  75129. private _prepareRowForTextureGeneration;
  75130. /**
  75131. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75132. * @returns the transform matrix of the texture.
  75133. */
  75134. getTextureMatrix(): Matrix;
  75135. /**
  75136. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75137. * @returns The reflection texture transform
  75138. */
  75139. getReflectionTextureMatrix(): Matrix;
  75140. /**
  75141. * Clones the texture.
  75142. * @returns the cloned texture
  75143. */
  75144. clone(): Texture;
  75145. /**
  75146. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75147. * @returns The JSON representation of the texture
  75148. */
  75149. serialize(): any;
  75150. /**
  75151. * Get the current class name of the texture useful for serialization or dynamic coding.
  75152. * @returns "Texture"
  75153. */
  75154. getClassName(): string;
  75155. /**
  75156. * Dispose the texture and release its associated resources.
  75157. */
  75158. dispose(): void;
  75159. /**
  75160. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75161. * @param parsedTexture Define the JSON representation of the texture
  75162. * @param scene Define the scene the parsed texture should be instantiated in
  75163. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75164. * @returns The parsed texture if successful
  75165. */
  75166. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75167. /**
  75168. * Creates a texture from its base 64 representation.
  75169. * @param data Define the base64 payload without the data: prefix
  75170. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75171. * @param scene Define the scene the texture should belong to
  75172. * @param noMipmap Forces the texture to not create mip map information if true
  75173. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75174. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75175. * @param onLoad define a callback triggered when the texture has been loaded
  75176. * @param onError define a callback triggered when an error occurred during the loading session
  75177. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75178. * @returns the created texture
  75179. */
  75180. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75181. /**
  75182. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75183. * @param data Define the base64 payload without the data: prefix
  75184. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75185. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75186. * @param scene Define the scene the texture should belong to
  75187. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75188. * @param noMipmap Forces the texture to not create mip map information if true
  75189. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75190. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75191. * @param onLoad define a callback triggered when the texture has been loaded
  75192. * @param onError define a callback triggered when an error occurred during the loading session
  75193. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75194. * @returns the created texture
  75195. */
  75196. 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;
  75197. }
  75198. }
  75199. declare module BABYLON {
  75200. /**
  75201. * Raw texture can help creating a texture directly from an array of data.
  75202. * This can be super useful if you either get the data from an uncompressed source or
  75203. * if you wish to create your texture pixel by pixel.
  75204. */
  75205. export class RawTexture extends Texture {
  75206. /**
  75207. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75208. */
  75209. format: number;
  75210. private _engine;
  75211. /**
  75212. * Instantiates a new RawTexture.
  75213. * Raw texture can help creating a texture directly from an array of data.
  75214. * This can be super useful if you either get the data from an uncompressed source or
  75215. * if you wish to create your texture pixel by pixel.
  75216. * @param data define the array of data to use to create the texture
  75217. * @param width define the width of the texture
  75218. * @param height define the height of the texture
  75219. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75220. * @param scene define the scene the texture belongs to
  75221. * @param generateMipMaps define whether mip maps should be generated or not
  75222. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75223. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75224. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75225. */
  75226. constructor(data: ArrayBufferView, width: number, height: number,
  75227. /**
  75228. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75229. */
  75230. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75231. /**
  75232. * Updates the texture underlying data.
  75233. * @param data Define the new data of the texture
  75234. */
  75235. update(data: ArrayBufferView): void;
  75236. /**
  75237. * Creates a luminance texture from some data.
  75238. * @param data Define the texture data
  75239. * @param width Define the width of the texture
  75240. * @param height Define the height of the texture
  75241. * @param scene Define the scene the texture belongs to
  75242. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75243. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75244. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75245. * @returns the luminance texture
  75246. */
  75247. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75248. /**
  75249. * Creates a luminance alpha texture from some data.
  75250. * @param data Define the texture data
  75251. * @param width Define the width of the texture
  75252. * @param height Define the height of the texture
  75253. * @param scene Define the scene the texture belongs to
  75254. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75255. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75256. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75257. * @returns the luminance alpha texture
  75258. */
  75259. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75260. /**
  75261. * Creates an alpha texture from some data.
  75262. * @param data Define the texture data
  75263. * @param width Define the width of the texture
  75264. * @param height Define the height of the texture
  75265. * @param scene Define the scene the texture belongs to
  75266. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75267. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75268. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75269. * @returns the alpha texture
  75270. */
  75271. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75272. /**
  75273. * Creates a RGB texture from some data.
  75274. * @param data Define the texture data
  75275. * @param width Define the width of the texture
  75276. * @param height Define the height of the texture
  75277. * @param scene Define the scene the texture belongs to
  75278. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75279. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75280. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75281. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75282. * @returns the RGB alpha texture
  75283. */
  75284. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75285. /**
  75286. * Creates a RGBA texture from some data.
  75287. * @param data Define the texture data
  75288. * @param width Define the width of the texture
  75289. * @param height Define the height of the texture
  75290. * @param scene Define the scene the texture belongs to
  75291. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75292. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75293. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75294. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75295. * @returns the RGBA texture
  75296. */
  75297. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75298. /**
  75299. * Creates a R texture from some data.
  75300. * @param data Define the texture data
  75301. * @param width Define the width of the texture
  75302. * @param height Define the height of the texture
  75303. * @param scene Define the scene the texture belongs to
  75304. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75305. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75306. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75307. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75308. * @returns the R texture
  75309. */
  75310. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75311. }
  75312. }
  75313. declare module BABYLON {
  75314. /**
  75315. * Defines a runtime animation
  75316. */
  75317. export class RuntimeAnimation {
  75318. private _events;
  75319. /**
  75320. * The current frame of the runtime animation
  75321. */
  75322. private _currentFrame;
  75323. /**
  75324. * The animation used by the runtime animation
  75325. */
  75326. private _animation;
  75327. /**
  75328. * The target of the runtime animation
  75329. */
  75330. private _target;
  75331. /**
  75332. * The initiating animatable
  75333. */
  75334. private _host;
  75335. /**
  75336. * The original value of the runtime animation
  75337. */
  75338. private _originalValue;
  75339. /**
  75340. * The original blend value of the runtime animation
  75341. */
  75342. private _originalBlendValue;
  75343. /**
  75344. * The offsets cache of the runtime animation
  75345. */
  75346. private _offsetsCache;
  75347. /**
  75348. * The high limits cache of the runtime animation
  75349. */
  75350. private _highLimitsCache;
  75351. /**
  75352. * Specifies if the runtime animation has been stopped
  75353. */
  75354. private _stopped;
  75355. /**
  75356. * The blending factor of the runtime animation
  75357. */
  75358. private _blendingFactor;
  75359. /**
  75360. * The BabylonJS scene
  75361. */
  75362. private _scene;
  75363. /**
  75364. * The current value of the runtime animation
  75365. */
  75366. private _currentValue;
  75367. /** @hidden */
  75368. _workValue: any;
  75369. /**
  75370. * The active target of the runtime animation
  75371. */
  75372. private _activeTarget;
  75373. /**
  75374. * The target path of the runtime animation
  75375. */
  75376. private _targetPath;
  75377. /**
  75378. * The weight of the runtime animation
  75379. */
  75380. private _weight;
  75381. /**
  75382. * The ratio offset of the runtime animation
  75383. */
  75384. private _ratioOffset;
  75385. /**
  75386. * The previous delay of the runtime animation
  75387. */
  75388. private _previousDelay;
  75389. /**
  75390. * The previous ratio of the runtime animation
  75391. */
  75392. private _previousRatio;
  75393. /**
  75394. * Gets the current frame of the runtime animation
  75395. */
  75396. readonly currentFrame: number;
  75397. /**
  75398. * Gets the weight of the runtime animation
  75399. */
  75400. readonly weight: number;
  75401. /**
  75402. * Gets the current value of the runtime animation
  75403. */
  75404. readonly currentValue: any;
  75405. /**
  75406. * Gets the target path of the runtime animation
  75407. */
  75408. readonly targetPath: string;
  75409. /**
  75410. * Gets the actual target of the runtime animation
  75411. */
  75412. readonly target: any;
  75413. /**
  75414. * Create a new RuntimeAnimation object
  75415. * @param target defines the target of the animation
  75416. * @param animation defines the source animation object
  75417. * @param scene defines the hosting scene
  75418. * @param host defines the initiating Animatable
  75419. */
  75420. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  75421. /**
  75422. * Gets the animation from the runtime animation
  75423. */
  75424. readonly animation: Animation;
  75425. /**
  75426. * Resets the runtime animation to the beginning
  75427. * @param restoreOriginal defines whether to restore the target property to the original value
  75428. */
  75429. reset(restoreOriginal?: boolean): void;
  75430. /**
  75431. * Specifies if the runtime animation is stopped
  75432. * @returns Boolean specifying if the runtime animation is stopped
  75433. */
  75434. isStopped(): boolean;
  75435. /**
  75436. * Disposes of the runtime animation
  75437. */
  75438. dispose(): void;
  75439. /**
  75440. * Interpolates the animation from the current frame
  75441. * @param currentFrame The frame to interpolate the animation to
  75442. * @param repeatCount The number of times that the animation should loop
  75443. * @param loopMode The type of looping mode to use
  75444. * @param offsetValue Animation offset value
  75445. * @param highLimitValue The high limit value
  75446. * @returns The interpolated value
  75447. */
  75448. private _interpolate;
  75449. /**
  75450. * Apply the interpolated value to the target
  75451. * @param currentValue defines the value computed by the animation
  75452. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  75453. */
  75454. setValue(currentValue: any, weight?: number): void;
  75455. private _setValue;
  75456. /**
  75457. * Gets the loop pmode of the runtime animation
  75458. * @returns Loop Mode
  75459. */
  75460. private _getCorrectLoopMode;
  75461. /**
  75462. * Move the current animation to a given frame
  75463. * @param frame defines the frame to move to
  75464. */
  75465. goToFrame(frame: number): void;
  75466. /**
  75467. * @hidden Internal use only
  75468. */
  75469. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  75470. /**
  75471. * Execute the current animation
  75472. * @param delay defines the delay to add to the current frame
  75473. * @param from defines the lower bound of the animation range
  75474. * @param to defines the upper bound of the animation range
  75475. * @param loop defines if the current animation must loop
  75476. * @param speedRatio defines the current speed ratio
  75477. * @param weight defines the weight of the animation (default is -1 so no weight)
  75478. * @param onLoop optional callback called when animation loops
  75479. * @returns a boolean indicating if the animation is running
  75480. */
  75481. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  75482. }
  75483. }
  75484. declare module BABYLON {
  75485. /**
  75486. * Class used to store an actual running animation
  75487. */
  75488. export class Animatable {
  75489. /** defines the target object */
  75490. target: any;
  75491. /** defines the starting frame number (default is 0) */
  75492. fromFrame: number;
  75493. /** defines the ending frame number (default is 100) */
  75494. toFrame: number;
  75495. /** defines if the animation must loop (default is false) */
  75496. loopAnimation: boolean;
  75497. /** defines a callback to call when animation ends if it is not looping */
  75498. onAnimationEnd?: (() => void) | null | undefined;
  75499. /** defines a callback to call when animation loops */
  75500. onAnimationLoop?: (() => void) | null | undefined;
  75501. private _localDelayOffset;
  75502. private _pausedDelay;
  75503. private _runtimeAnimations;
  75504. private _paused;
  75505. private _scene;
  75506. private _speedRatio;
  75507. private _weight;
  75508. private _syncRoot;
  75509. /**
  75510. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75511. * This will only apply for non looping animation (default is true)
  75512. */
  75513. disposeOnEnd: boolean;
  75514. /**
  75515. * Gets a boolean indicating if the animation has started
  75516. */
  75517. animationStarted: boolean;
  75518. /**
  75519. * Observer raised when the animation ends
  75520. */
  75521. onAnimationEndObservable: Observable<Animatable>;
  75522. /**
  75523. * Observer raised when the animation loops
  75524. */
  75525. onAnimationLoopObservable: Observable<Animatable>;
  75526. /**
  75527. * Gets the root Animatable used to synchronize and normalize animations
  75528. */
  75529. readonly syncRoot: Animatable;
  75530. /**
  75531. * Gets the current frame of the first RuntimeAnimation
  75532. * Used to synchronize Animatables
  75533. */
  75534. readonly masterFrame: number;
  75535. /**
  75536. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  75537. */
  75538. weight: number;
  75539. /**
  75540. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  75541. */
  75542. speedRatio: number;
  75543. /**
  75544. * Creates a new Animatable
  75545. * @param scene defines the hosting scene
  75546. * @param target defines the target object
  75547. * @param fromFrame defines the starting frame number (default is 0)
  75548. * @param toFrame defines the ending frame number (default is 100)
  75549. * @param loopAnimation defines if the animation must loop (default is false)
  75550. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  75551. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  75552. * @param animations defines a group of animation to add to the new Animatable
  75553. * @param onAnimationLoop defines a callback to call when animation loops
  75554. */
  75555. constructor(scene: Scene,
  75556. /** defines the target object */
  75557. target: any,
  75558. /** defines the starting frame number (default is 0) */
  75559. fromFrame?: number,
  75560. /** defines the ending frame number (default is 100) */
  75561. toFrame?: number,
  75562. /** defines if the animation must loop (default is false) */
  75563. loopAnimation?: boolean, speedRatio?: number,
  75564. /** defines a callback to call when animation ends if it is not looping */
  75565. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  75566. /** defines a callback to call when animation loops */
  75567. onAnimationLoop?: (() => void) | null | undefined);
  75568. /**
  75569. * Synchronize and normalize current Animatable with a source Animatable
  75570. * This is useful when using animation weights and when animations are not of the same length
  75571. * @param root defines the root Animatable to synchronize with
  75572. * @returns the current Animatable
  75573. */
  75574. syncWith(root: Animatable): Animatable;
  75575. /**
  75576. * Gets the list of runtime animations
  75577. * @returns an array of RuntimeAnimation
  75578. */
  75579. getAnimations(): RuntimeAnimation[];
  75580. /**
  75581. * Adds more animations to the current animatable
  75582. * @param target defines the target of the animations
  75583. * @param animations defines the new animations to add
  75584. */
  75585. appendAnimations(target: any, animations: Animation[]): void;
  75586. /**
  75587. * Gets the source animation for a specific property
  75588. * @param property defines the propertyu to look for
  75589. * @returns null or the source animation for the given property
  75590. */
  75591. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  75592. /**
  75593. * Gets the runtime animation for a specific property
  75594. * @param property defines the propertyu to look for
  75595. * @returns null or the runtime animation for the given property
  75596. */
  75597. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  75598. /**
  75599. * Resets the animatable to its original state
  75600. */
  75601. reset(): void;
  75602. /**
  75603. * Allows the animatable to blend with current running animations
  75604. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75605. * @param blendingSpeed defines the blending speed to use
  75606. */
  75607. enableBlending(blendingSpeed: number): void;
  75608. /**
  75609. * Disable animation blending
  75610. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75611. */
  75612. disableBlending(): void;
  75613. /**
  75614. * Jump directly to a given frame
  75615. * @param frame defines the frame to jump to
  75616. */
  75617. goToFrame(frame: number): void;
  75618. /**
  75619. * Pause the animation
  75620. */
  75621. pause(): void;
  75622. /**
  75623. * Restart the animation
  75624. */
  75625. restart(): void;
  75626. private _raiseOnAnimationEnd;
  75627. /**
  75628. * Stop and delete the current animation
  75629. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  75630. * @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)
  75631. */
  75632. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  75633. /**
  75634. * Wait asynchronously for the animation to end
  75635. * @returns a promise which will be fullfilled when the animation ends
  75636. */
  75637. waitAsync(): Promise<Animatable>;
  75638. /** @hidden */
  75639. _animate(delay: number): boolean;
  75640. }
  75641. interface Scene {
  75642. /** @hidden */
  75643. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  75644. /** @hidden */
  75645. _processLateAnimationBindingsForMatrices(holder: {
  75646. totalWeight: number;
  75647. animations: RuntimeAnimation[];
  75648. originalValue: Matrix;
  75649. }): any;
  75650. /** @hidden */
  75651. _processLateAnimationBindingsForQuaternions(holder: {
  75652. totalWeight: number;
  75653. animations: RuntimeAnimation[];
  75654. originalValue: Quaternion;
  75655. }, refQuaternion: Quaternion): Quaternion;
  75656. /** @hidden */
  75657. _processLateAnimationBindings(): void;
  75658. /**
  75659. * Will start the animation sequence of a given target
  75660. * @param target defines the target
  75661. * @param from defines from which frame should animation start
  75662. * @param to defines until which frame should animation run.
  75663. * @param weight defines the weight to apply to the animation (1.0 by default)
  75664. * @param loop defines if the animation loops
  75665. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75666. * @param onAnimationEnd defines the function to be executed when the animation ends
  75667. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75668. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75669. * @param onAnimationLoop defines the callback to call when an animation loops
  75670. * @returns the animatable object created for this animation
  75671. */
  75672. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75673. /**
  75674. * Will start the animation sequence of a given target
  75675. * @param target defines the target
  75676. * @param from defines from which frame should animation start
  75677. * @param to defines until which frame should animation run.
  75678. * @param loop defines if the animation loops
  75679. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75680. * @param onAnimationEnd defines the function to be executed when the animation ends
  75681. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75682. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75683. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  75684. * @param onAnimationLoop defines the callback to call when an animation loops
  75685. * @returns the animatable object created for this animation
  75686. */
  75687. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75688. /**
  75689. * Will start the animation sequence of a given target and its hierarchy
  75690. * @param target defines the target
  75691. * @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.
  75692. * @param from defines from which frame should animation start
  75693. * @param to defines until which frame should animation run.
  75694. * @param loop defines if the animation loops
  75695. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75696. * @param onAnimationEnd defines the function to be executed when the animation ends
  75697. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75698. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75699. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75700. * @param onAnimationLoop defines the callback to call when an animation loops
  75701. * @returns the list of created animatables
  75702. */
  75703. 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[];
  75704. /**
  75705. * Begin a new animation on a given node
  75706. * @param target defines the target where the animation will take place
  75707. * @param animations defines the list of animations to start
  75708. * @param from defines the initial value
  75709. * @param to defines the final value
  75710. * @param loop defines if you want animation to loop (off by default)
  75711. * @param speedRatio defines the speed ratio to apply to all animations
  75712. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75713. * @param onAnimationLoop defines the callback to call when an animation loops
  75714. * @returns the list of created animatables
  75715. */
  75716. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  75717. /**
  75718. * Begin a new animation on a given node and its hierarchy
  75719. * @param target defines the root node where the animation will take place
  75720. * @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.
  75721. * @param animations defines the list of animations to start
  75722. * @param from defines the initial value
  75723. * @param to defines the final value
  75724. * @param loop defines if you want animation to loop (off by default)
  75725. * @param speedRatio defines the speed ratio to apply to all animations
  75726. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75727. * @param onAnimationLoop defines the callback to call when an animation loops
  75728. * @returns the list of animatables created for all nodes
  75729. */
  75730. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  75731. /**
  75732. * Gets the animatable associated with a specific target
  75733. * @param target defines the target of the animatable
  75734. * @returns the required animatable if found
  75735. */
  75736. getAnimatableByTarget(target: any): Nullable<Animatable>;
  75737. /**
  75738. * Gets all animatables associated with a given target
  75739. * @param target defines the target to look animatables for
  75740. * @returns an array of Animatables
  75741. */
  75742. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  75743. /**
  75744. * Will stop the animation of the given target
  75745. * @param target - the target
  75746. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  75747. * @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)
  75748. */
  75749. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  75750. /**
  75751. * Stops and removes all animations that have been applied to the scene
  75752. */
  75753. stopAllAnimations(): void;
  75754. }
  75755. interface Bone {
  75756. /**
  75757. * Copy an animation range from another bone
  75758. * @param source defines the source bone
  75759. * @param rangeName defines the range name to copy
  75760. * @param frameOffset defines the frame offset
  75761. * @param rescaleAsRequired defines if rescaling must be applied if required
  75762. * @param skelDimensionsRatio defines the scaling ratio
  75763. * @returns true if operation was successful
  75764. */
  75765. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  75766. }
  75767. }
  75768. declare module BABYLON {
  75769. /**
  75770. * Class used to handle skinning animations
  75771. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  75772. */
  75773. export class Skeleton implements IAnimatable {
  75774. /** defines the skeleton name */
  75775. name: string;
  75776. /** defines the skeleton Id */
  75777. id: string;
  75778. /**
  75779. * Defines the list of child bones
  75780. */
  75781. bones: Bone[];
  75782. /**
  75783. * Defines an estimate of the dimension of the skeleton at rest
  75784. */
  75785. dimensionsAtRest: Vector3;
  75786. /**
  75787. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  75788. */
  75789. needInitialSkinMatrix: boolean;
  75790. /**
  75791. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  75792. */
  75793. overrideMesh: Nullable<AbstractMesh>;
  75794. /**
  75795. * Gets the list of animations attached to this skeleton
  75796. */
  75797. animations: Array<Animation>;
  75798. private _scene;
  75799. private _isDirty;
  75800. private _transformMatrices;
  75801. private _transformMatrixTexture;
  75802. private _meshesWithPoseMatrix;
  75803. private _animatables;
  75804. private _identity;
  75805. private _synchronizedWithMesh;
  75806. private _ranges;
  75807. private _lastAbsoluteTransformsUpdateId;
  75808. private _canUseTextureForBones;
  75809. /** @hidden */
  75810. _numBonesWithLinkedTransformNode: number;
  75811. /**
  75812. * Specifies if the skeleton should be serialized
  75813. */
  75814. doNotSerialize: boolean;
  75815. /**
  75816. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  75817. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  75818. */
  75819. useTextureToStoreBoneMatrices: boolean;
  75820. private _animationPropertiesOverride;
  75821. /**
  75822. * Gets or sets the animation properties override
  75823. */
  75824. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  75825. /**
  75826. * An observable triggered before computing the skeleton's matrices
  75827. */
  75828. onBeforeComputeObservable: Observable<Skeleton>;
  75829. /**
  75830. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  75831. */
  75832. readonly isUsingTextureForMatrices: boolean;
  75833. /**
  75834. * Creates a new skeleton
  75835. * @param name defines the skeleton name
  75836. * @param id defines the skeleton Id
  75837. * @param scene defines the hosting scene
  75838. */
  75839. constructor(
  75840. /** defines the skeleton name */
  75841. name: string,
  75842. /** defines the skeleton Id */
  75843. id: string, scene: Scene);
  75844. /**
  75845. * Gets the current object class name.
  75846. * @return the class name
  75847. */
  75848. getClassName(): string;
  75849. /**
  75850. * Returns an array containing the root bones
  75851. * @returns an array containing the root bones
  75852. */
  75853. getChildren(): Array<Bone>;
  75854. /**
  75855. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  75856. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  75857. * @returns a Float32Array containing matrices data
  75858. */
  75859. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  75860. /**
  75861. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  75862. * @returns a raw texture containing the data
  75863. */
  75864. getTransformMatrixTexture(): Nullable<RawTexture>;
  75865. /**
  75866. * Gets the current hosting scene
  75867. * @returns a scene object
  75868. */
  75869. getScene(): Scene;
  75870. /**
  75871. * Gets a string representing the current skeleton data
  75872. * @param fullDetails defines a boolean indicating if we want a verbose version
  75873. * @returns a string representing the current skeleton data
  75874. */
  75875. toString(fullDetails?: boolean): string;
  75876. /**
  75877. * Get bone's index searching by name
  75878. * @param name defines bone's name to search for
  75879. * @return the indice of the bone. Returns -1 if not found
  75880. */
  75881. getBoneIndexByName(name: string): number;
  75882. /**
  75883. * Creater a new animation range
  75884. * @param name defines the name of the range
  75885. * @param from defines the start key
  75886. * @param to defines the end key
  75887. */
  75888. createAnimationRange(name: string, from: number, to: number): void;
  75889. /**
  75890. * Delete a specific animation range
  75891. * @param name defines the name of the range
  75892. * @param deleteFrames defines if frames must be removed as well
  75893. */
  75894. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  75895. /**
  75896. * Gets a specific animation range
  75897. * @param name defines the name of the range to look for
  75898. * @returns the requested animation range or null if not found
  75899. */
  75900. getAnimationRange(name: string): Nullable<AnimationRange>;
  75901. /**
  75902. * Gets the list of all animation ranges defined on this skeleton
  75903. * @returns an array
  75904. */
  75905. getAnimationRanges(): Nullable<AnimationRange>[];
  75906. /**
  75907. * Copy animation range from a source skeleton.
  75908. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  75909. * @param source defines the source skeleton
  75910. * @param name defines the name of the range to copy
  75911. * @param rescaleAsRequired defines if rescaling must be applied if required
  75912. * @returns true if operation was successful
  75913. */
  75914. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  75915. /**
  75916. * Forces the skeleton to go to rest pose
  75917. */
  75918. returnToRest(): void;
  75919. private _getHighestAnimationFrame;
  75920. /**
  75921. * Begin a specific animation range
  75922. * @param name defines the name of the range to start
  75923. * @param loop defines if looping must be turned on (false by default)
  75924. * @param speedRatio defines the speed ratio to apply (1 by default)
  75925. * @param onAnimationEnd defines a callback which will be called when animation will end
  75926. * @returns a new animatable
  75927. */
  75928. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  75929. /** @hidden */
  75930. _markAsDirty(): void;
  75931. /** @hidden */
  75932. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75933. /** @hidden */
  75934. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75935. private _computeTransformMatrices;
  75936. /**
  75937. * Build all resources required to render a skeleton
  75938. */
  75939. prepare(): void;
  75940. /**
  75941. * Gets the list of animatables currently running for this skeleton
  75942. * @returns an array of animatables
  75943. */
  75944. getAnimatables(): IAnimatable[];
  75945. /**
  75946. * Clone the current skeleton
  75947. * @param name defines the name of the new skeleton
  75948. * @param id defines the id of the enw skeleton
  75949. * @returns the new skeleton
  75950. */
  75951. clone(name: string, id: string): Skeleton;
  75952. /**
  75953. * Enable animation blending for this skeleton
  75954. * @param blendingSpeed defines the blending speed to apply
  75955. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75956. */
  75957. enableBlending(blendingSpeed?: number): void;
  75958. /**
  75959. * Releases all resources associated with the current skeleton
  75960. */
  75961. dispose(): void;
  75962. /**
  75963. * Serialize the skeleton in a JSON object
  75964. * @returns a JSON object
  75965. */
  75966. serialize(): any;
  75967. /**
  75968. * Creates a new skeleton from serialized data
  75969. * @param parsedSkeleton defines the serialized data
  75970. * @param scene defines the hosting scene
  75971. * @returns a new skeleton
  75972. */
  75973. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  75974. /**
  75975. * Compute all node absolute transforms
  75976. * @param forceUpdate defines if computation must be done even if cache is up to date
  75977. */
  75978. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  75979. /**
  75980. * Gets the root pose matrix
  75981. * @returns a matrix
  75982. */
  75983. getPoseMatrix(): Nullable<Matrix>;
  75984. /**
  75985. * Sorts bones per internal index
  75986. */
  75987. sortBones(): void;
  75988. private _sortBones;
  75989. }
  75990. }
  75991. declare module BABYLON {
  75992. /**
  75993. * Defines a target to use with MorphTargetManager
  75994. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  75995. */
  75996. export class MorphTarget implements IAnimatable {
  75997. /** defines the name of the target */
  75998. name: string;
  75999. /**
  76000. * Gets or sets the list of animations
  76001. */
  76002. animations: Animation[];
  76003. private _scene;
  76004. private _positions;
  76005. private _normals;
  76006. private _tangents;
  76007. private _influence;
  76008. /**
  76009. * Observable raised when the influence changes
  76010. */
  76011. onInfluenceChanged: Observable<boolean>;
  76012. /** @hidden */
  76013. _onDataLayoutChanged: Observable<void>;
  76014. /**
  76015. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  76016. */
  76017. influence: number;
  76018. /**
  76019. * Gets or sets the id of the morph Target
  76020. */
  76021. id: string;
  76022. private _animationPropertiesOverride;
  76023. /**
  76024. * Gets or sets the animation properties override
  76025. */
  76026. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76027. /**
  76028. * Creates a new MorphTarget
  76029. * @param name defines the name of the target
  76030. * @param influence defines the influence to use
  76031. * @param scene defines the scene the morphtarget belongs to
  76032. */
  76033. constructor(
  76034. /** defines the name of the target */
  76035. name: string, influence?: number, scene?: Nullable<Scene>);
  76036. /**
  76037. * Gets a boolean defining if the target contains position data
  76038. */
  76039. readonly hasPositions: boolean;
  76040. /**
  76041. * Gets a boolean defining if the target contains normal data
  76042. */
  76043. readonly hasNormals: boolean;
  76044. /**
  76045. * Gets a boolean defining if the target contains tangent data
  76046. */
  76047. readonly hasTangents: boolean;
  76048. /**
  76049. * Affects position data to this target
  76050. * @param data defines the position data to use
  76051. */
  76052. setPositions(data: Nullable<FloatArray>): void;
  76053. /**
  76054. * Gets the position data stored in this target
  76055. * @returns a FloatArray containing the position data (or null if not present)
  76056. */
  76057. getPositions(): Nullable<FloatArray>;
  76058. /**
  76059. * Affects normal data to this target
  76060. * @param data defines the normal data to use
  76061. */
  76062. setNormals(data: Nullable<FloatArray>): void;
  76063. /**
  76064. * Gets the normal data stored in this target
  76065. * @returns a FloatArray containing the normal data (or null if not present)
  76066. */
  76067. getNormals(): Nullable<FloatArray>;
  76068. /**
  76069. * Affects tangent data to this target
  76070. * @param data defines the tangent data to use
  76071. */
  76072. setTangents(data: Nullable<FloatArray>): void;
  76073. /**
  76074. * Gets the tangent data stored in this target
  76075. * @returns a FloatArray containing the tangent data (or null if not present)
  76076. */
  76077. getTangents(): Nullable<FloatArray>;
  76078. /**
  76079. * Serializes the current target into a Serialization object
  76080. * @returns the serialized object
  76081. */
  76082. serialize(): any;
  76083. /**
  76084. * Returns the string "MorphTarget"
  76085. * @returns "MorphTarget"
  76086. */
  76087. getClassName(): string;
  76088. /**
  76089. * Creates a new target from serialized data
  76090. * @param serializationObject defines the serialized data to use
  76091. * @returns a new MorphTarget
  76092. */
  76093. static Parse(serializationObject: any): MorphTarget;
  76094. /**
  76095. * Creates a MorphTarget from mesh data
  76096. * @param mesh defines the source mesh
  76097. * @param name defines the name to use for the new target
  76098. * @param influence defines the influence to attach to the target
  76099. * @returns a new MorphTarget
  76100. */
  76101. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76102. }
  76103. }
  76104. declare module BABYLON {
  76105. /**
  76106. * This class is used to deform meshes using morphing between different targets
  76107. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76108. */
  76109. export class MorphTargetManager {
  76110. private _targets;
  76111. private _targetInfluenceChangedObservers;
  76112. private _targetDataLayoutChangedObservers;
  76113. private _activeTargets;
  76114. private _scene;
  76115. private _influences;
  76116. private _supportsNormals;
  76117. private _supportsTangents;
  76118. private _vertexCount;
  76119. private _uniqueId;
  76120. private _tempInfluences;
  76121. /**
  76122. * Creates a new MorphTargetManager
  76123. * @param scene defines the current scene
  76124. */
  76125. constructor(scene?: Nullable<Scene>);
  76126. /**
  76127. * Gets the unique ID of this manager
  76128. */
  76129. readonly uniqueId: number;
  76130. /**
  76131. * Gets the number of vertices handled by this manager
  76132. */
  76133. readonly vertexCount: number;
  76134. /**
  76135. * Gets a boolean indicating if this manager supports morphing of normals
  76136. */
  76137. readonly supportsNormals: boolean;
  76138. /**
  76139. * Gets a boolean indicating if this manager supports morphing of tangents
  76140. */
  76141. readonly supportsTangents: boolean;
  76142. /**
  76143. * Gets the number of targets stored in this manager
  76144. */
  76145. readonly numTargets: number;
  76146. /**
  76147. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76148. */
  76149. readonly numInfluencers: number;
  76150. /**
  76151. * Gets the list of influences (one per target)
  76152. */
  76153. readonly influences: Float32Array;
  76154. /**
  76155. * Gets the active target at specified index. An active target is a target with an influence > 0
  76156. * @param index defines the index to check
  76157. * @returns the requested target
  76158. */
  76159. getActiveTarget(index: number): MorphTarget;
  76160. /**
  76161. * Gets the target at specified index
  76162. * @param index defines the index to check
  76163. * @returns the requested target
  76164. */
  76165. getTarget(index: number): MorphTarget;
  76166. /**
  76167. * Add a new target to this manager
  76168. * @param target defines the target to add
  76169. */
  76170. addTarget(target: MorphTarget): void;
  76171. /**
  76172. * Removes a target from the manager
  76173. * @param target defines the target to remove
  76174. */
  76175. removeTarget(target: MorphTarget): void;
  76176. /**
  76177. * Serializes the current manager into a Serialization object
  76178. * @returns the serialized object
  76179. */
  76180. serialize(): any;
  76181. private _syncActiveTargets;
  76182. /**
  76183. * Syncrhonize the targets with all the meshes using this morph target manager
  76184. */
  76185. synchronize(): void;
  76186. /**
  76187. * Creates a new MorphTargetManager from serialized data
  76188. * @param serializationObject defines the serialized data
  76189. * @param scene defines the hosting scene
  76190. * @returns the new MorphTargetManager
  76191. */
  76192. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76193. }
  76194. }
  76195. declare module BABYLON {
  76196. /**
  76197. * Mesh representing the gorund
  76198. */
  76199. export class GroundMesh extends Mesh {
  76200. /** If octree should be generated */
  76201. generateOctree: boolean;
  76202. private _heightQuads;
  76203. /** @hidden */
  76204. _subdivisionsX: number;
  76205. /** @hidden */
  76206. _subdivisionsY: number;
  76207. /** @hidden */
  76208. _width: number;
  76209. /** @hidden */
  76210. _height: number;
  76211. /** @hidden */
  76212. _minX: number;
  76213. /** @hidden */
  76214. _maxX: number;
  76215. /** @hidden */
  76216. _minZ: number;
  76217. /** @hidden */
  76218. _maxZ: number;
  76219. constructor(name: string, scene: Scene);
  76220. /**
  76221. * "GroundMesh"
  76222. * @returns "GroundMesh"
  76223. */
  76224. getClassName(): string;
  76225. /**
  76226. * The minimum of x and y subdivisions
  76227. */
  76228. readonly subdivisions: number;
  76229. /**
  76230. * X subdivisions
  76231. */
  76232. readonly subdivisionsX: number;
  76233. /**
  76234. * Y subdivisions
  76235. */
  76236. readonly subdivisionsY: number;
  76237. /**
  76238. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76239. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76240. * @param chunksCount the number of subdivisions for x and y
  76241. * @param octreeBlocksSize (Default: 32)
  76242. */
  76243. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76244. /**
  76245. * Returns a height (y) value in the Worl system :
  76246. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76247. * @param x x coordinate
  76248. * @param z z coordinate
  76249. * @returns the ground y position if (x, z) are outside the ground surface.
  76250. */
  76251. getHeightAtCoordinates(x: number, z: number): number;
  76252. /**
  76253. * Returns a normalized vector (Vector3) orthogonal to the ground
  76254. * at the ground coordinates (x, z) expressed in the World system.
  76255. * @param x x coordinate
  76256. * @param z z coordinate
  76257. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76258. */
  76259. getNormalAtCoordinates(x: number, z: number): Vector3;
  76260. /**
  76261. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76262. * at the ground coordinates (x, z) expressed in the World system.
  76263. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76264. * @param x x coordinate
  76265. * @param z z coordinate
  76266. * @param ref vector to store the result
  76267. * @returns the GroundMesh.
  76268. */
  76269. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76270. /**
  76271. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76272. * if the ground has been updated.
  76273. * This can be used in the render loop.
  76274. * @returns the GroundMesh.
  76275. */
  76276. updateCoordinateHeights(): GroundMesh;
  76277. private _getFacetAt;
  76278. private _initHeightQuads;
  76279. private _computeHeightQuads;
  76280. /**
  76281. * Serializes this ground mesh
  76282. * @param serializationObject object to write serialization to
  76283. */
  76284. serialize(serializationObject: any): void;
  76285. /**
  76286. * Parses a serialized ground mesh
  76287. * @param parsedMesh the serialized mesh
  76288. * @param scene the scene to create the ground mesh in
  76289. * @returns the created ground mesh
  76290. */
  76291. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76292. }
  76293. }
  76294. declare module BABYLON {
  76295. /**
  76296. * Interface for Physics-Joint data
  76297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76298. */
  76299. export interface PhysicsJointData {
  76300. /**
  76301. * The main pivot of the joint
  76302. */
  76303. mainPivot?: Vector3;
  76304. /**
  76305. * The connected pivot of the joint
  76306. */
  76307. connectedPivot?: Vector3;
  76308. /**
  76309. * The main axis of the joint
  76310. */
  76311. mainAxis?: Vector3;
  76312. /**
  76313. * The connected axis of the joint
  76314. */
  76315. connectedAxis?: Vector3;
  76316. /**
  76317. * The collision of the joint
  76318. */
  76319. collision?: boolean;
  76320. /**
  76321. * Native Oimo/Cannon/Energy data
  76322. */
  76323. nativeParams?: any;
  76324. }
  76325. /**
  76326. * This is a holder class for the physics joint created by the physics plugin
  76327. * It holds a set of functions to control the underlying joint
  76328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76329. */
  76330. export class PhysicsJoint {
  76331. /**
  76332. * The type of the physics joint
  76333. */
  76334. type: number;
  76335. /**
  76336. * The data for the physics joint
  76337. */
  76338. jointData: PhysicsJointData;
  76339. private _physicsJoint;
  76340. protected _physicsPlugin: IPhysicsEnginePlugin;
  76341. /**
  76342. * Initializes the physics joint
  76343. * @param type The type of the physics joint
  76344. * @param jointData The data for the physics joint
  76345. */
  76346. constructor(
  76347. /**
  76348. * The type of the physics joint
  76349. */
  76350. type: number,
  76351. /**
  76352. * The data for the physics joint
  76353. */
  76354. jointData: PhysicsJointData);
  76355. /**
  76356. * Gets the physics joint
  76357. */
  76358. /**
  76359. * Sets the physics joint
  76360. */
  76361. physicsJoint: any;
  76362. /**
  76363. * Sets the physics plugin
  76364. */
  76365. physicsPlugin: IPhysicsEnginePlugin;
  76366. /**
  76367. * Execute a function that is physics-plugin specific.
  76368. * @param {Function} func the function that will be executed.
  76369. * It accepts two parameters: the physics world and the physics joint
  76370. */
  76371. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76372. /**
  76373. * Distance-Joint type
  76374. */
  76375. static DistanceJoint: number;
  76376. /**
  76377. * Hinge-Joint type
  76378. */
  76379. static HingeJoint: number;
  76380. /**
  76381. * Ball-and-Socket joint type
  76382. */
  76383. static BallAndSocketJoint: number;
  76384. /**
  76385. * Wheel-Joint type
  76386. */
  76387. static WheelJoint: number;
  76388. /**
  76389. * Slider-Joint type
  76390. */
  76391. static SliderJoint: number;
  76392. /**
  76393. * Prismatic-Joint type
  76394. */
  76395. static PrismaticJoint: number;
  76396. /**
  76397. * Universal-Joint type
  76398. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  76399. */
  76400. static UniversalJoint: number;
  76401. /**
  76402. * Hinge-Joint 2 type
  76403. */
  76404. static Hinge2Joint: number;
  76405. /**
  76406. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  76407. */
  76408. static PointToPointJoint: number;
  76409. /**
  76410. * Spring-Joint type
  76411. */
  76412. static SpringJoint: number;
  76413. /**
  76414. * Lock-Joint type
  76415. */
  76416. static LockJoint: number;
  76417. }
  76418. /**
  76419. * A class representing a physics distance joint
  76420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76421. */
  76422. export class DistanceJoint extends PhysicsJoint {
  76423. /**
  76424. *
  76425. * @param jointData The data for the Distance-Joint
  76426. */
  76427. constructor(jointData: DistanceJointData);
  76428. /**
  76429. * Update the predefined distance.
  76430. * @param maxDistance The maximum preferred distance
  76431. * @param minDistance The minimum preferred distance
  76432. */
  76433. updateDistance(maxDistance: number, minDistance?: number): void;
  76434. }
  76435. /**
  76436. * Represents a Motor-Enabled Joint
  76437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76438. */
  76439. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  76440. /**
  76441. * Initializes the Motor-Enabled Joint
  76442. * @param type The type of the joint
  76443. * @param jointData The physica joint data for the joint
  76444. */
  76445. constructor(type: number, jointData: PhysicsJointData);
  76446. /**
  76447. * Set the motor values.
  76448. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76449. * @param force the force to apply
  76450. * @param maxForce max force for this motor.
  76451. */
  76452. setMotor(force?: number, maxForce?: number): void;
  76453. /**
  76454. * Set the motor's limits.
  76455. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76456. * @param upperLimit The upper limit of the motor
  76457. * @param lowerLimit The lower limit of the motor
  76458. */
  76459. setLimit(upperLimit: number, lowerLimit?: number): void;
  76460. }
  76461. /**
  76462. * This class represents a single physics Hinge-Joint
  76463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76464. */
  76465. export class HingeJoint extends MotorEnabledJoint {
  76466. /**
  76467. * Initializes the Hinge-Joint
  76468. * @param jointData The joint data for the Hinge-Joint
  76469. */
  76470. constructor(jointData: PhysicsJointData);
  76471. /**
  76472. * Set the motor values.
  76473. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76474. * @param {number} force the force to apply
  76475. * @param {number} maxForce max force for this motor.
  76476. */
  76477. setMotor(force?: number, maxForce?: number): void;
  76478. /**
  76479. * Set the motor's limits.
  76480. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76481. * @param upperLimit The upper limit of the motor
  76482. * @param lowerLimit The lower limit of the motor
  76483. */
  76484. setLimit(upperLimit: number, lowerLimit?: number): void;
  76485. }
  76486. /**
  76487. * This class represents a dual hinge physics joint (same as wheel joint)
  76488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76489. */
  76490. export class Hinge2Joint extends MotorEnabledJoint {
  76491. /**
  76492. * Initializes the Hinge2-Joint
  76493. * @param jointData The joint data for the Hinge2-Joint
  76494. */
  76495. constructor(jointData: PhysicsJointData);
  76496. /**
  76497. * Set the motor values.
  76498. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76499. * @param {number} targetSpeed the speed the motor is to reach
  76500. * @param {number} maxForce max force for this motor.
  76501. * @param {motorIndex} the motor's index, 0 or 1.
  76502. */
  76503. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  76504. /**
  76505. * Set the motor limits.
  76506. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76507. * @param {number} upperLimit the upper limit
  76508. * @param {number} lowerLimit lower limit
  76509. * @param {motorIndex} the motor's index, 0 or 1.
  76510. */
  76511. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76512. }
  76513. /**
  76514. * Interface for a motor enabled joint
  76515. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76516. */
  76517. export interface IMotorEnabledJoint {
  76518. /**
  76519. * Physics joint
  76520. */
  76521. physicsJoint: any;
  76522. /**
  76523. * Sets the motor of the motor-enabled joint
  76524. * @param force The force of the motor
  76525. * @param maxForce The maximum force of the motor
  76526. * @param motorIndex The index of the motor
  76527. */
  76528. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76529. /**
  76530. * Sets the limit of the motor
  76531. * @param upperLimit The upper limit of the motor
  76532. * @param lowerLimit The lower limit of the motor
  76533. * @param motorIndex The index of the motor
  76534. */
  76535. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76536. }
  76537. /**
  76538. * Joint data for a Distance-Joint
  76539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76540. */
  76541. export interface DistanceJointData extends PhysicsJointData {
  76542. /**
  76543. * Max distance the 2 joint objects can be apart
  76544. */
  76545. maxDistance: number;
  76546. }
  76547. /**
  76548. * Joint data from a spring joint
  76549. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76550. */
  76551. export interface SpringJointData extends PhysicsJointData {
  76552. /**
  76553. * Length of the spring
  76554. */
  76555. length: number;
  76556. /**
  76557. * Stiffness of the spring
  76558. */
  76559. stiffness: number;
  76560. /**
  76561. * Damping of the spring
  76562. */
  76563. damping: number;
  76564. /** this callback will be called when applying the force to the impostors. */
  76565. forceApplicationCallback: () => void;
  76566. }
  76567. }
  76568. declare module BABYLON {
  76569. /**
  76570. * Interface used to describe a physics joint
  76571. */
  76572. export interface PhysicsImpostorJoint {
  76573. /** Defines the main impostor to which the joint is linked */
  76574. mainImpostor: PhysicsImpostor;
  76575. /** Defines the impostor that is connected to the main impostor using this joint */
  76576. connectedImpostor: PhysicsImpostor;
  76577. /** Defines the joint itself */
  76578. joint: PhysicsJoint;
  76579. }
  76580. /** @hidden */
  76581. export interface IPhysicsEnginePlugin {
  76582. world: any;
  76583. name: string;
  76584. setGravity(gravity: Vector3): void;
  76585. setTimeStep(timeStep: number): void;
  76586. getTimeStep(): number;
  76587. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76588. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76589. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76590. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76591. removePhysicsBody(impostor: PhysicsImpostor): void;
  76592. generateJoint(joint: PhysicsImpostorJoint): void;
  76593. removeJoint(joint: PhysicsImpostorJoint): void;
  76594. isSupported(): boolean;
  76595. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76596. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76597. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76598. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76599. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76600. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76601. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76602. getBodyMass(impostor: PhysicsImpostor): number;
  76603. getBodyFriction(impostor: PhysicsImpostor): number;
  76604. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76605. getBodyRestitution(impostor: PhysicsImpostor): number;
  76606. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76607. sleepBody(impostor: PhysicsImpostor): void;
  76608. wakeUpBody(impostor: PhysicsImpostor): void;
  76609. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76610. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76611. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76612. getRadius(impostor: PhysicsImpostor): number;
  76613. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76614. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76615. dispose(): void;
  76616. }
  76617. /**
  76618. * Interface used to define a physics engine
  76619. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76620. */
  76621. export interface IPhysicsEngine {
  76622. /**
  76623. * Gets the gravity vector used by the simulation
  76624. */
  76625. gravity: Vector3;
  76626. /**
  76627. * Sets the gravity vector used by the simulation
  76628. * @param gravity defines the gravity vector to use
  76629. */
  76630. setGravity(gravity: Vector3): void;
  76631. /**
  76632. * Set the time step of the physics engine.
  76633. * Default is 1/60.
  76634. * To slow it down, enter 1/600 for example.
  76635. * To speed it up, 1/30
  76636. * @param newTimeStep the new timestep to apply to this world.
  76637. */
  76638. setTimeStep(newTimeStep: number): void;
  76639. /**
  76640. * Get the time step of the physics engine.
  76641. * @returns the current time step
  76642. */
  76643. getTimeStep(): number;
  76644. /**
  76645. * Release all resources
  76646. */
  76647. dispose(): void;
  76648. /**
  76649. * Gets the name of the current physics plugin
  76650. * @returns the name of the plugin
  76651. */
  76652. getPhysicsPluginName(): string;
  76653. /**
  76654. * Adding a new impostor for the impostor tracking.
  76655. * This will be done by the impostor itself.
  76656. * @param impostor the impostor to add
  76657. */
  76658. addImpostor(impostor: PhysicsImpostor): void;
  76659. /**
  76660. * Remove an impostor from the engine.
  76661. * This impostor and its mesh will not longer be updated by the physics engine.
  76662. * @param impostor the impostor to remove
  76663. */
  76664. removeImpostor(impostor: PhysicsImpostor): void;
  76665. /**
  76666. * Add a joint to the physics engine
  76667. * @param mainImpostor defines the main impostor to which the joint is added.
  76668. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76669. * @param joint defines the joint that will connect both impostors.
  76670. */
  76671. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76672. /**
  76673. * Removes a joint from the simulation
  76674. * @param mainImpostor defines the impostor used with the joint
  76675. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76676. * @param joint defines the joint to remove
  76677. */
  76678. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76679. /**
  76680. * Gets the current plugin used to run the simulation
  76681. * @returns current plugin
  76682. */
  76683. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76684. /**
  76685. * Gets the list of physic impostors
  76686. * @returns an array of PhysicsImpostor
  76687. */
  76688. getImpostors(): Array<PhysicsImpostor>;
  76689. /**
  76690. * Gets the impostor for a physics enabled object
  76691. * @param object defines the object impersonated by the impostor
  76692. * @returns the PhysicsImpostor or null if not found
  76693. */
  76694. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76695. /**
  76696. * Gets the impostor for a physics body object
  76697. * @param body defines physics body used by the impostor
  76698. * @returns the PhysicsImpostor or null if not found
  76699. */
  76700. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76701. /**
  76702. * Called by the scene. No need to call it.
  76703. * @param delta defines the timespam between frames
  76704. */
  76705. _step(delta: number): void;
  76706. }
  76707. }
  76708. declare module BABYLON {
  76709. /**
  76710. * The interface for the physics imposter parameters
  76711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76712. */
  76713. export interface PhysicsImpostorParameters {
  76714. /**
  76715. * The mass of the physics imposter
  76716. */
  76717. mass: number;
  76718. /**
  76719. * The friction of the physics imposter
  76720. */
  76721. friction?: number;
  76722. /**
  76723. * The coefficient of restitution of the physics imposter
  76724. */
  76725. restitution?: number;
  76726. /**
  76727. * The native options of the physics imposter
  76728. */
  76729. nativeOptions?: any;
  76730. /**
  76731. * Specifies if the parent should be ignored
  76732. */
  76733. ignoreParent?: boolean;
  76734. /**
  76735. * Specifies if bi-directional transformations should be disabled
  76736. */
  76737. disableBidirectionalTransformation?: boolean;
  76738. }
  76739. /**
  76740. * Interface for a physics-enabled object
  76741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76742. */
  76743. export interface IPhysicsEnabledObject {
  76744. /**
  76745. * The position of the physics-enabled object
  76746. */
  76747. position: Vector3;
  76748. /**
  76749. * The rotation of the physics-enabled object
  76750. */
  76751. rotationQuaternion: Nullable<Quaternion>;
  76752. /**
  76753. * The scale of the physics-enabled object
  76754. */
  76755. scaling: Vector3;
  76756. /**
  76757. * The rotation of the physics-enabled object
  76758. */
  76759. rotation?: Vector3;
  76760. /**
  76761. * The parent of the physics-enabled object
  76762. */
  76763. parent?: any;
  76764. /**
  76765. * The bounding info of the physics-enabled object
  76766. * @returns The bounding info of the physics-enabled object
  76767. */
  76768. getBoundingInfo(): BoundingInfo;
  76769. /**
  76770. * Computes the world matrix
  76771. * @param force Specifies if the world matrix should be computed by force
  76772. * @returns A world matrix
  76773. */
  76774. computeWorldMatrix(force: boolean): Matrix;
  76775. /**
  76776. * Gets the world matrix
  76777. * @returns A world matrix
  76778. */
  76779. getWorldMatrix?(): Matrix;
  76780. /**
  76781. * Gets the child meshes
  76782. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76783. * @returns An array of abstract meshes
  76784. */
  76785. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76786. /**
  76787. * Gets the vertex data
  76788. * @param kind The type of vertex data
  76789. * @returns A nullable array of numbers, or a float32 array
  76790. */
  76791. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76792. /**
  76793. * Gets the indices from the mesh
  76794. * @returns A nullable array of index arrays
  76795. */
  76796. getIndices?(): Nullable<IndicesArray>;
  76797. /**
  76798. * Gets the scene from the mesh
  76799. * @returns the indices array or null
  76800. */
  76801. getScene?(): Scene;
  76802. /**
  76803. * Gets the absolute position from the mesh
  76804. * @returns the absolute position
  76805. */
  76806. getAbsolutePosition(): Vector3;
  76807. /**
  76808. * Gets the absolute pivot point from the mesh
  76809. * @returns the absolute pivot point
  76810. */
  76811. getAbsolutePivotPoint(): Vector3;
  76812. /**
  76813. * Rotates the mesh
  76814. * @param axis The axis of rotation
  76815. * @param amount The amount of rotation
  76816. * @param space The space of the rotation
  76817. * @returns The rotation transform node
  76818. */
  76819. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76820. /**
  76821. * Translates the mesh
  76822. * @param axis The axis of translation
  76823. * @param distance The distance of translation
  76824. * @param space The space of the translation
  76825. * @returns The transform node
  76826. */
  76827. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76828. /**
  76829. * Sets the absolute position of the mesh
  76830. * @param absolutePosition The absolute position of the mesh
  76831. * @returns The transform node
  76832. */
  76833. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76834. /**
  76835. * Gets the class name of the mesh
  76836. * @returns The class name
  76837. */
  76838. getClassName(): string;
  76839. }
  76840. /**
  76841. * Represents a physics imposter
  76842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76843. */
  76844. export class PhysicsImpostor {
  76845. /**
  76846. * The physics-enabled object used as the physics imposter
  76847. */
  76848. object: IPhysicsEnabledObject;
  76849. /**
  76850. * The type of the physics imposter
  76851. */
  76852. type: number;
  76853. private _options;
  76854. private _scene?;
  76855. /**
  76856. * The default object size of the imposter
  76857. */
  76858. static DEFAULT_OBJECT_SIZE: Vector3;
  76859. /**
  76860. * The identity quaternion of the imposter
  76861. */
  76862. static IDENTITY_QUATERNION: Quaternion;
  76863. /** @hidden */
  76864. _pluginData: any;
  76865. private _physicsEngine;
  76866. private _physicsBody;
  76867. private _bodyUpdateRequired;
  76868. private _onBeforePhysicsStepCallbacks;
  76869. private _onAfterPhysicsStepCallbacks;
  76870. /** @hidden */
  76871. _onPhysicsCollideCallbacks: Array<{
  76872. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76873. otherImpostors: Array<PhysicsImpostor>;
  76874. }>;
  76875. private _deltaPosition;
  76876. private _deltaRotation;
  76877. private _deltaRotationConjugated;
  76878. private _parent;
  76879. private _isDisposed;
  76880. private static _tmpVecs;
  76881. private static _tmpQuat;
  76882. /**
  76883. * Specifies if the physics imposter is disposed
  76884. */
  76885. readonly isDisposed: boolean;
  76886. /**
  76887. * Gets the mass of the physics imposter
  76888. */
  76889. mass: number;
  76890. /**
  76891. * Gets the coefficient of friction
  76892. */
  76893. /**
  76894. * Sets the coefficient of friction
  76895. */
  76896. friction: number;
  76897. /**
  76898. * Gets the coefficient of restitution
  76899. */
  76900. /**
  76901. * Sets the coefficient of restitution
  76902. */
  76903. restitution: number;
  76904. /**
  76905. * The unique id of the physics imposter
  76906. * set by the physics engine when adding this impostor to the array
  76907. */
  76908. uniqueId: number;
  76909. private _joints;
  76910. /**
  76911. * Initializes the physics imposter
  76912. * @param object The physics-enabled object used as the physics imposter
  76913. * @param type The type of the physics imposter
  76914. * @param _options The options for the physics imposter
  76915. * @param _scene The Babylon scene
  76916. */
  76917. constructor(
  76918. /**
  76919. * The physics-enabled object used as the physics imposter
  76920. */
  76921. object: IPhysicsEnabledObject,
  76922. /**
  76923. * The type of the physics imposter
  76924. */
  76925. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76926. /**
  76927. * This function will completly initialize this impostor.
  76928. * It will create a new body - but only if this mesh has no parent.
  76929. * If it has, this impostor will not be used other than to define the impostor
  76930. * of the child mesh.
  76931. * @hidden
  76932. */
  76933. _init(): void;
  76934. private _getPhysicsParent;
  76935. /**
  76936. * Should a new body be generated.
  76937. * @returns boolean specifying if body initialization is required
  76938. */
  76939. isBodyInitRequired(): boolean;
  76940. /**
  76941. * Sets the updated scaling
  76942. * @param updated Specifies if the scaling is updated
  76943. */
  76944. setScalingUpdated(): void;
  76945. /**
  76946. * Force a regeneration of this or the parent's impostor's body.
  76947. * Use under cautious - This will remove all joints already implemented.
  76948. */
  76949. forceUpdate(): void;
  76950. /**
  76951. * Gets the body that holds this impostor. Either its own, or its parent.
  76952. */
  76953. /**
  76954. * Set the physics body. Used mainly by the physics engine/plugin
  76955. */
  76956. physicsBody: any;
  76957. /**
  76958. * Get the parent of the physics imposter
  76959. * @returns Physics imposter or null
  76960. */
  76961. /**
  76962. * Sets the parent of the physics imposter
  76963. */
  76964. parent: Nullable<PhysicsImpostor>;
  76965. /**
  76966. * Resets the update flags
  76967. */
  76968. resetUpdateFlags(): void;
  76969. /**
  76970. * Gets the object extend size
  76971. * @returns the object extend size
  76972. */
  76973. getObjectExtendSize(): Vector3;
  76974. /**
  76975. * Gets the object center
  76976. * @returns The object center
  76977. */
  76978. getObjectCenter(): Vector3;
  76979. /**
  76980. * Get a specific parametes from the options parameter
  76981. * @param paramName The object parameter name
  76982. * @returns The object parameter
  76983. */
  76984. getParam(paramName: string): any;
  76985. /**
  76986. * Sets a specific parameter in the options given to the physics plugin
  76987. * @param paramName The parameter name
  76988. * @param value The value of the parameter
  76989. */
  76990. setParam(paramName: string, value: number): void;
  76991. /**
  76992. * Specifically change the body's mass option. Won't recreate the physics body object
  76993. * @param mass The mass of the physics imposter
  76994. */
  76995. setMass(mass: number): void;
  76996. /**
  76997. * Gets the linear velocity
  76998. * @returns linear velocity or null
  76999. */
  77000. getLinearVelocity(): Nullable<Vector3>;
  77001. /**
  77002. * Sets the linear velocity
  77003. * @param velocity linear velocity or null
  77004. */
  77005. setLinearVelocity(velocity: Nullable<Vector3>): void;
  77006. /**
  77007. * Gets the angular velocity
  77008. * @returns angular velocity or null
  77009. */
  77010. getAngularVelocity(): Nullable<Vector3>;
  77011. /**
  77012. * Sets the angular velocity
  77013. * @param velocity The velocity or null
  77014. */
  77015. setAngularVelocity(velocity: Nullable<Vector3>): void;
  77016. /**
  77017. * Execute a function with the physics plugin native code
  77018. * Provide a function the will have two variables - the world object and the physics body object
  77019. * @param func The function to execute with the physics plugin native code
  77020. */
  77021. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  77022. /**
  77023. * Register a function that will be executed before the physics world is stepping forward
  77024. * @param func The function to execute before the physics world is stepped forward
  77025. */
  77026. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77027. /**
  77028. * Unregister a function that will be executed before the physics world is stepping forward
  77029. * @param func The function to execute before the physics world is stepped forward
  77030. */
  77031. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77032. /**
  77033. * Register a function that will be executed after the physics step
  77034. * @param func The function to execute after physics step
  77035. */
  77036. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77037. /**
  77038. * Unregisters a function that will be executed after the physics step
  77039. * @param func The function to execute after physics step
  77040. */
  77041. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77042. /**
  77043. * register a function that will be executed when this impostor collides against a different body
  77044. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  77045. * @param func Callback that is executed on collision
  77046. */
  77047. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  77048. /**
  77049. * Unregisters the physics imposter on contact
  77050. * @param collideAgainst The physics object to collide against
  77051. * @param func Callback to execute on collision
  77052. */
  77053. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  77054. private _tmpQuat;
  77055. private _tmpQuat2;
  77056. /**
  77057. * Get the parent rotation
  77058. * @returns The parent rotation
  77059. */
  77060. getParentsRotation(): Quaternion;
  77061. /**
  77062. * this function is executed by the physics engine.
  77063. */
  77064. beforeStep: () => void;
  77065. /**
  77066. * this function is executed by the physics engine
  77067. */
  77068. afterStep: () => void;
  77069. /**
  77070. * Legacy collision detection event support
  77071. */
  77072. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77073. /**
  77074. * event and body object due to cannon's event-based architecture.
  77075. */
  77076. onCollide: (e: {
  77077. body: any;
  77078. }) => void;
  77079. /**
  77080. * Apply a force
  77081. * @param force The force to apply
  77082. * @param contactPoint The contact point for the force
  77083. * @returns The physics imposter
  77084. */
  77085. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77086. /**
  77087. * Apply an impulse
  77088. * @param force The impulse force
  77089. * @param contactPoint The contact point for the impulse force
  77090. * @returns The physics imposter
  77091. */
  77092. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77093. /**
  77094. * A help function to create a joint
  77095. * @param otherImpostor A physics imposter used to create a joint
  77096. * @param jointType The type of joint
  77097. * @param jointData The data for the joint
  77098. * @returns The physics imposter
  77099. */
  77100. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77101. /**
  77102. * Add a joint to this impostor with a different impostor
  77103. * @param otherImpostor A physics imposter used to add a joint
  77104. * @param joint The joint to add
  77105. * @returns The physics imposter
  77106. */
  77107. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77108. /**
  77109. * Will keep this body still, in a sleep mode.
  77110. * @returns the physics imposter
  77111. */
  77112. sleep(): PhysicsImpostor;
  77113. /**
  77114. * Wake the body up.
  77115. * @returns The physics imposter
  77116. */
  77117. wakeUp(): PhysicsImpostor;
  77118. /**
  77119. * Clones the physics imposter
  77120. * @param newObject The physics imposter clones to this physics-enabled object
  77121. * @returns A nullable physics imposter
  77122. */
  77123. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77124. /**
  77125. * Disposes the physics imposter
  77126. */
  77127. dispose(): void;
  77128. /**
  77129. * Sets the delta position
  77130. * @param position The delta position amount
  77131. */
  77132. setDeltaPosition(position: Vector3): void;
  77133. /**
  77134. * Sets the delta rotation
  77135. * @param rotation The delta rotation amount
  77136. */
  77137. setDeltaRotation(rotation: Quaternion): void;
  77138. /**
  77139. * Gets the box size of the physics imposter and stores the result in the input parameter
  77140. * @param result Stores the box size
  77141. * @returns The physics imposter
  77142. */
  77143. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77144. /**
  77145. * Gets the radius of the physics imposter
  77146. * @returns Radius of the physics imposter
  77147. */
  77148. getRadius(): number;
  77149. /**
  77150. * Sync a bone with this impostor
  77151. * @param bone The bone to sync to the impostor.
  77152. * @param boneMesh The mesh that the bone is influencing.
  77153. * @param jointPivot The pivot of the joint / bone in local space.
  77154. * @param distToJoint Optional distance from the impostor to the joint.
  77155. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77156. */
  77157. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77158. /**
  77159. * Sync impostor to a bone
  77160. * @param bone The bone that the impostor will be synced to.
  77161. * @param boneMesh The mesh that the bone is influencing.
  77162. * @param jointPivot The pivot of the joint / bone in local space.
  77163. * @param distToJoint Optional distance from the impostor to the joint.
  77164. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77165. * @param boneAxis Optional vector3 axis the bone is aligned with
  77166. */
  77167. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77168. /**
  77169. * No-Imposter type
  77170. */
  77171. static NoImpostor: number;
  77172. /**
  77173. * Sphere-Imposter type
  77174. */
  77175. static SphereImpostor: number;
  77176. /**
  77177. * Box-Imposter type
  77178. */
  77179. static BoxImpostor: number;
  77180. /**
  77181. * Plane-Imposter type
  77182. */
  77183. static PlaneImpostor: number;
  77184. /**
  77185. * Mesh-imposter type
  77186. */
  77187. static MeshImpostor: number;
  77188. /**
  77189. * Cylinder-Imposter type
  77190. */
  77191. static CylinderImpostor: number;
  77192. /**
  77193. * Particle-Imposter type
  77194. */
  77195. static ParticleImpostor: number;
  77196. /**
  77197. * Heightmap-Imposter type
  77198. */
  77199. static HeightmapImpostor: number;
  77200. }
  77201. }
  77202. declare module BABYLON {
  77203. /**
  77204. * Class used to represent a specific level of detail of a mesh
  77205. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77206. */
  77207. export class MeshLODLevel {
  77208. /** Defines the distance where this level should star being displayed */
  77209. distance: number;
  77210. /** Defines the mesh to use to render this level */
  77211. mesh: Nullable<Mesh>;
  77212. /**
  77213. * Creates a new LOD level
  77214. * @param distance defines the distance where this level should star being displayed
  77215. * @param mesh defines the mesh to use to render this level
  77216. */
  77217. constructor(
  77218. /** Defines the distance where this level should star being displayed */
  77219. distance: number,
  77220. /** Defines the mesh to use to render this level */
  77221. mesh: Nullable<Mesh>);
  77222. }
  77223. /**
  77224. * @hidden
  77225. **/
  77226. export class _CreationDataStorage {
  77227. closePath?: boolean;
  77228. closeArray?: boolean;
  77229. idx: number[];
  77230. dashSize: number;
  77231. gapSize: number;
  77232. path3D: Path3D;
  77233. pathArray: Vector3[][];
  77234. arc: number;
  77235. radius: number;
  77236. cap: number;
  77237. tessellation: number;
  77238. }
  77239. /**
  77240. * @hidden
  77241. **/
  77242. class _InstanceDataStorage {
  77243. visibleInstances: any;
  77244. renderIdForInstances: number[];
  77245. batchCache: _InstancesBatch;
  77246. instancesBufferSize: number;
  77247. instancesBuffer: Nullable<Buffer>;
  77248. instancesData: Float32Array;
  77249. overridenInstanceCount: number;
  77250. }
  77251. /**
  77252. * @hidden
  77253. **/
  77254. export class _InstancesBatch {
  77255. mustReturn: boolean;
  77256. visibleInstances: Nullable<InstancedMesh[]>[];
  77257. renderSelf: boolean[];
  77258. }
  77259. /**
  77260. * Class used to represent renderable models
  77261. */
  77262. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77263. /**
  77264. * Mesh side orientation : usually the external or front surface
  77265. */
  77266. static readonly FRONTSIDE: number;
  77267. /**
  77268. * Mesh side orientation : usually the internal or back surface
  77269. */
  77270. static readonly BACKSIDE: number;
  77271. /**
  77272. * Mesh side orientation : both internal and external or front and back surfaces
  77273. */
  77274. static readonly DOUBLESIDE: number;
  77275. /**
  77276. * Mesh side orientation : by default, `FRONTSIDE`
  77277. */
  77278. static readonly DEFAULTSIDE: number;
  77279. /**
  77280. * Mesh cap setting : no cap
  77281. */
  77282. static readonly NO_CAP: number;
  77283. /**
  77284. * Mesh cap setting : one cap at the beginning of the mesh
  77285. */
  77286. static readonly CAP_START: number;
  77287. /**
  77288. * Mesh cap setting : one cap at the end of the mesh
  77289. */
  77290. static readonly CAP_END: number;
  77291. /**
  77292. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77293. */
  77294. static readonly CAP_ALL: number;
  77295. /**
  77296. * Gets the default side orientation.
  77297. * @param orientation the orientation to value to attempt to get
  77298. * @returns the default orientation
  77299. * @hidden
  77300. */
  77301. static _GetDefaultSideOrientation(orientation?: number): number;
  77302. private _onBeforeRenderObservable;
  77303. private _onBeforeBindObservable;
  77304. private _onAfterRenderObservable;
  77305. private _onBeforeDrawObservable;
  77306. /**
  77307. * An event triggered before rendering the mesh
  77308. */
  77309. readonly onBeforeRenderObservable: Observable<Mesh>;
  77310. /**
  77311. * An event triggered before binding the mesh
  77312. */
  77313. readonly onBeforeBindObservable: Observable<Mesh>;
  77314. /**
  77315. * An event triggered after rendering the mesh
  77316. */
  77317. readonly onAfterRenderObservable: Observable<Mesh>;
  77318. /**
  77319. * An event triggered before drawing the mesh
  77320. */
  77321. readonly onBeforeDrawObservable: Observable<Mesh>;
  77322. private _onBeforeDrawObserver;
  77323. /**
  77324. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77325. */
  77326. onBeforeDraw: () => void;
  77327. /**
  77328. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77329. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77330. */
  77331. delayLoadState: number;
  77332. /**
  77333. * Gets the list of instances created from this mesh
  77334. * it is not supposed to be modified manually.
  77335. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77336. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77337. */
  77338. instances: InstancedMesh[];
  77339. /**
  77340. * Gets the file containing delay loading data for this mesh
  77341. */
  77342. delayLoadingFile: string;
  77343. /** @hidden */
  77344. _binaryInfo: any;
  77345. private _LODLevels;
  77346. /**
  77347. * User defined function used to change how LOD level selection is done
  77348. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77349. */
  77350. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77351. private _morphTargetManager;
  77352. /**
  77353. * Gets or sets the morph target manager
  77354. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77355. */
  77356. morphTargetManager: Nullable<MorphTargetManager>;
  77357. /** @hidden */
  77358. _creationDataStorage: Nullable<_CreationDataStorage>;
  77359. /** @hidden */
  77360. _geometry: Nullable<Geometry>;
  77361. /** @hidden */
  77362. _delayInfo: Array<string>;
  77363. /** @hidden */
  77364. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77365. /** @hidden */
  77366. _instanceDataStorage: _InstanceDataStorage;
  77367. private _effectiveMaterial;
  77368. /** @hidden */
  77369. _shouldGenerateFlatShading: boolean;
  77370. private _preActivateId;
  77371. /** @hidden */
  77372. _originalBuilderSideOrientation: number;
  77373. /**
  77374. * Use this property to change the original side orientation defined at construction time
  77375. */
  77376. overrideMaterialSideOrientation: Nullable<number>;
  77377. private _areNormalsFrozen;
  77378. private _sourcePositions;
  77379. private _sourceNormals;
  77380. private _source;
  77381. private meshMap;
  77382. /**
  77383. * Gets the source mesh (the one used to clone this one from)
  77384. */
  77385. readonly source: Nullable<Mesh>;
  77386. /**
  77387. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77388. */
  77389. isUnIndexed: boolean;
  77390. /**
  77391. * @constructor
  77392. * @param name The value used by scene.getMeshByName() to do a lookup.
  77393. * @param scene The scene to add this mesh to.
  77394. * @param parent The parent of this mesh, if it has one
  77395. * @param source An optional Mesh from which geometry is shared, cloned.
  77396. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77397. * When false, achieved by calling a clone(), also passing False.
  77398. * This will make creation of children, recursive.
  77399. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77400. */
  77401. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77402. /**
  77403. * Gets the class name
  77404. * @returns the string "Mesh".
  77405. */
  77406. getClassName(): string;
  77407. /** @hidden */
  77408. readonly _isMesh: boolean;
  77409. /**
  77410. * Returns a description of this mesh
  77411. * @param fullDetails define if full details about this mesh must be used
  77412. * @returns a descriptive string representing this mesh
  77413. */
  77414. toString(fullDetails?: boolean): string;
  77415. /** @hidden */
  77416. _unBindEffect(): void;
  77417. /**
  77418. * Gets a boolean indicating if this mesh has LOD
  77419. */
  77420. readonly hasLODLevels: boolean;
  77421. /**
  77422. * Gets the list of MeshLODLevel associated with the current mesh
  77423. * @returns an array of MeshLODLevel
  77424. */
  77425. getLODLevels(): MeshLODLevel[];
  77426. private _sortLODLevels;
  77427. /**
  77428. * Add a mesh as LOD level triggered at the given distance.
  77429. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77430. * @param distance The distance from the center of the object to show this level
  77431. * @param mesh The mesh to be added as LOD level (can be null)
  77432. * @return This mesh (for chaining)
  77433. */
  77434. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77435. /**
  77436. * Returns the LOD level mesh at the passed distance or null if not found.
  77437. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77438. * @param distance The distance from the center of the object to show this level
  77439. * @returns a Mesh or `null`
  77440. */
  77441. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77442. /**
  77443. * Remove a mesh from the LOD array
  77444. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77445. * @param mesh defines the mesh to be removed
  77446. * @return This mesh (for chaining)
  77447. */
  77448. removeLODLevel(mesh: Mesh): Mesh;
  77449. /**
  77450. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77451. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77452. * @param camera defines the camera to use to compute distance
  77453. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77454. * @return This mesh (for chaining)
  77455. */
  77456. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77457. /**
  77458. * Gets the mesh internal Geometry object
  77459. */
  77460. readonly geometry: Nullable<Geometry>;
  77461. /**
  77462. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77463. * @returns the total number of vertices
  77464. */
  77465. getTotalVertices(): number;
  77466. /**
  77467. * Returns the content of an associated vertex buffer
  77468. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77469. * - VertexBuffer.PositionKind
  77470. * - VertexBuffer.UVKind
  77471. * - VertexBuffer.UV2Kind
  77472. * - VertexBuffer.UV3Kind
  77473. * - VertexBuffer.UV4Kind
  77474. * - VertexBuffer.UV5Kind
  77475. * - VertexBuffer.UV6Kind
  77476. * - VertexBuffer.ColorKind
  77477. * - VertexBuffer.MatricesIndicesKind
  77478. * - VertexBuffer.MatricesIndicesExtraKind
  77479. * - VertexBuffer.MatricesWeightsKind
  77480. * - VertexBuffer.MatricesWeightsExtraKind
  77481. * @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
  77482. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77483. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77484. */
  77485. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77486. /**
  77487. * Returns the mesh VertexBuffer object from the requested `kind`
  77488. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77489. * - VertexBuffer.PositionKind
  77490. * - VertexBuffer.UVKind
  77491. * - VertexBuffer.UV2Kind
  77492. * - VertexBuffer.UV3Kind
  77493. * - VertexBuffer.UV4Kind
  77494. * - VertexBuffer.UV5Kind
  77495. * - VertexBuffer.UV6Kind
  77496. * - VertexBuffer.ColorKind
  77497. * - VertexBuffer.MatricesIndicesKind
  77498. * - VertexBuffer.MatricesIndicesExtraKind
  77499. * - VertexBuffer.MatricesWeightsKind
  77500. * - VertexBuffer.MatricesWeightsExtraKind
  77501. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77502. */
  77503. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77504. /**
  77505. * Tests if a specific vertex buffer is associated with this mesh
  77506. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77507. * - VertexBuffer.PositionKind
  77508. * - VertexBuffer.UVKind
  77509. * - VertexBuffer.UV2Kind
  77510. * - VertexBuffer.UV3Kind
  77511. * - VertexBuffer.UV4Kind
  77512. * - VertexBuffer.UV5Kind
  77513. * - VertexBuffer.UV6Kind
  77514. * - VertexBuffer.ColorKind
  77515. * - VertexBuffer.MatricesIndicesKind
  77516. * - VertexBuffer.MatricesIndicesExtraKind
  77517. * - VertexBuffer.MatricesWeightsKind
  77518. * - VertexBuffer.MatricesWeightsExtraKind
  77519. * @returns a boolean
  77520. */
  77521. isVerticesDataPresent(kind: string): boolean;
  77522. /**
  77523. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77524. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77525. * - VertexBuffer.PositionKind
  77526. * - VertexBuffer.UVKind
  77527. * - VertexBuffer.UV2Kind
  77528. * - VertexBuffer.UV3Kind
  77529. * - VertexBuffer.UV4Kind
  77530. * - VertexBuffer.UV5Kind
  77531. * - VertexBuffer.UV6Kind
  77532. * - VertexBuffer.ColorKind
  77533. * - VertexBuffer.MatricesIndicesKind
  77534. * - VertexBuffer.MatricesIndicesExtraKind
  77535. * - VertexBuffer.MatricesWeightsKind
  77536. * - VertexBuffer.MatricesWeightsExtraKind
  77537. * @returns a boolean
  77538. */
  77539. isVertexBufferUpdatable(kind: string): boolean;
  77540. /**
  77541. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77542. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77543. * - VertexBuffer.PositionKind
  77544. * - VertexBuffer.UVKind
  77545. * - VertexBuffer.UV2Kind
  77546. * - VertexBuffer.UV3Kind
  77547. * - VertexBuffer.UV4Kind
  77548. * - VertexBuffer.UV5Kind
  77549. * - VertexBuffer.UV6Kind
  77550. * - VertexBuffer.ColorKind
  77551. * - VertexBuffer.MatricesIndicesKind
  77552. * - VertexBuffer.MatricesIndicesExtraKind
  77553. * - VertexBuffer.MatricesWeightsKind
  77554. * - VertexBuffer.MatricesWeightsExtraKind
  77555. * @returns an array of strings
  77556. */
  77557. getVerticesDataKinds(): string[];
  77558. /**
  77559. * Returns a positive integer : the total number of indices in this mesh geometry.
  77560. * @returns the numner of indices or zero if the mesh has no geometry.
  77561. */
  77562. getTotalIndices(): number;
  77563. /**
  77564. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77565. * @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.
  77566. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77567. * @returns the indices array or an empty array if the mesh has no geometry
  77568. */
  77569. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77570. readonly isBlocked: boolean;
  77571. /**
  77572. * Determine if the current mesh is ready to be rendered
  77573. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77574. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77575. * @returns true if all associated assets are ready (material, textures, shaders)
  77576. */
  77577. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77578. /**
  77579. * 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.
  77580. */
  77581. readonly areNormalsFrozen: boolean;
  77582. /**
  77583. * 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.
  77584. * @returns the current mesh
  77585. */
  77586. freezeNormals(): Mesh;
  77587. /**
  77588. * 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
  77589. * @returns the current mesh
  77590. */
  77591. unfreezeNormals(): Mesh;
  77592. /**
  77593. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77594. */
  77595. overridenInstanceCount: number;
  77596. /** @hidden */
  77597. _preActivate(): Mesh;
  77598. /** @hidden */
  77599. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77600. /** @hidden */
  77601. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77602. /**
  77603. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77604. * This means the mesh underlying bounding box and sphere are recomputed.
  77605. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77606. * @returns the current mesh
  77607. */
  77608. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77609. /** @hidden */
  77610. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77611. /**
  77612. * This function will subdivide the mesh into multiple submeshes
  77613. * @param count defines the expected number of submeshes
  77614. */
  77615. subdivide(count: number): void;
  77616. /**
  77617. * Copy a FloatArray into a specific associated vertex buffer
  77618. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77619. * - VertexBuffer.PositionKind
  77620. * - VertexBuffer.UVKind
  77621. * - VertexBuffer.UV2Kind
  77622. * - VertexBuffer.UV3Kind
  77623. * - VertexBuffer.UV4Kind
  77624. * - VertexBuffer.UV5Kind
  77625. * - VertexBuffer.UV6Kind
  77626. * - VertexBuffer.ColorKind
  77627. * - VertexBuffer.MatricesIndicesKind
  77628. * - VertexBuffer.MatricesIndicesExtraKind
  77629. * - VertexBuffer.MatricesWeightsKind
  77630. * - VertexBuffer.MatricesWeightsExtraKind
  77631. * @param data defines the data source
  77632. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77633. * @param stride defines the data stride size (can be null)
  77634. * @returns the current mesh
  77635. */
  77636. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77637. /**
  77638. * Flags an associated vertex buffer as updatable
  77639. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77640. * - VertexBuffer.PositionKind
  77641. * - VertexBuffer.UVKind
  77642. * - VertexBuffer.UV2Kind
  77643. * - VertexBuffer.UV3Kind
  77644. * - VertexBuffer.UV4Kind
  77645. * - VertexBuffer.UV5Kind
  77646. * - VertexBuffer.UV6Kind
  77647. * - VertexBuffer.ColorKind
  77648. * - VertexBuffer.MatricesIndicesKind
  77649. * - VertexBuffer.MatricesIndicesExtraKind
  77650. * - VertexBuffer.MatricesWeightsKind
  77651. * - VertexBuffer.MatricesWeightsExtraKind
  77652. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77653. */
  77654. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77655. /**
  77656. * Sets the mesh global Vertex Buffer
  77657. * @param buffer defines the buffer to use
  77658. * @returns the current mesh
  77659. */
  77660. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77661. /**
  77662. * Update a specific associated vertex buffer
  77663. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77664. * - VertexBuffer.PositionKind
  77665. * - VertexBuffer.UVKind
  77666. * - VertexBuffer.UV2Kind
  77667. * - VertexBuffer.UV3Kind
  77668. * - VertexBuffer.UV4Kind
  77669. * - VertexBuffer.UV5Kind
  77670. * - VertexBuffer.UV6Kind
  77671. * - VertexBuffer.ColorKind
  77672. * - VertexBuffer.MatricesIndicesKind
  77673. * - VertexBuffer.MatricesIndicesExtraKind
  77674. * - VertexBuffer.MatricesWeightsKind
  77675. * - VertexBuffer.MatricesWeightsExtraKind
  77676. * @param data defines the data source
  77677. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77678. * @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)
  77679. * @returns the current mesh
  77680. */
  77681. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77682. /**
  77683. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77684. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77685. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77686. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77687. * @returns the current mesh
  77688. */
  77689. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77690. /**
  77691. * Creates a un-shared specific occurence of the geometry for the mesh.
  77692. * @returns the current mesh
  77693. */
  77694. makeGeometryUnique(): Mesh;
  77695. /**
  77696. * Set the index buffer of this mesh
  77697. * @param indices defines the source data
  77698. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77699. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77700. * @returns the current mesh
  77701. */
  77702. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77703. /**
  77704. * Update the current index buffer
  77705. * @param indices defines the source data
  77706. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77707. * @returns the current mesh
  77708. */
  77709. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  77710. /**
  77711. * Invert the geometry to move from a right handed system to a left handed one.
  77712. * @returns the current mesh
  77713. */
  77714. toLeftHanded(): Mesh;
  77715. /** @hidden */
  77716. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77717. /** @hidden */
  77718. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  77719. /**
  77720. * Registers for this mesh a javascript function called just before the rendering process
  77721. * @param func defines the function to call before rendering this mesh
  77722. * @returns the current mesh
  77723. */
  77724. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77725. /**
  77726. * Disposes a previously registered javascript function called before the rendering
  77727. * @param func defines the function to remove
  77728. * @returns the current mesh
  77729. */
  77730. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77731. /**
  77732. * Registers for this mesh a javascript function called just after the rendering is complete
  77733. * @param func defines the function to call after rendering this mesh
  77734. * @returns the current mesh
  77735. */
  77736. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77737. /**
  77738. * Disposes a previously registered javascript function called after the rendering.
  77739. * @param func defines the function to remove
  77740. * @returns the current mesh
  77741. */
  77742. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77743. /** @hidden */
  77744. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77745. /** @hidden */
  77746. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77747. /** @hidden */
  77748. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77749. /**
  77750. * 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
  77751. * @param subMesh defines the subMesh to render
  77752. * @param enableAlphaMode defines if alpha mode can be changed
  77753. * @returns the current mesh
  77754. */
  77755. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77756. private _onBeforeDraw;
  77757. /**
  77758. * Renormalize the mesh and patch it up if there are no weights
  77759. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77760. * However in the case of zero weights then we set just a single influence to 1.
  77761. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77762. */
  77763. cleanMatrixWeights(): void;
  77764. private normalizeSkinFourWeights;
  77765. private normalizeSkinWeightsAndExtra;
  77766. /**
  77767. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77768. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77769. * the user know there was an issue with importing the mesh
  77770. * @returns a validation object with skinned, valid and report string
  77771. */
  77772. validateSkinning(): {
  77773. skinned: boolean;
  77774. valid: boolean;
  77775. report: string;
  77776. };
  77777. /** @hidden */
  77778. _checkDelayState(): Mesh;
  77779. private _queueLoad;
  77780. /**
  77781. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77782. * A mesh is in the frustum if its bounding box intersects the frustum
  77783. * @param frustumPlanes defines the frustum to test
  77784. * @returns true if the mesh is in the frustum planes
  77785. */
  77786. isInFrustum(frustumPlanes: Plane[]): boolean;
  77787. /**
  77788. * Sets the mesh material by the material or multiMaterial `id` property
  77789. * @param id is a string identifying the material or the multiMaterial
  77790. * @returns the current mesh
  77791. */
  77792. setMaterialByID(id: string): Mesh;
  77793. /**
  77794. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77795. * @returns an array of IAnimatable
  77796. */
  77797. getAnimatables(): IAnimatable[];
  77798. /**
  77799. * Modifies the mesh geometry according to the passed transformation matrix.
  77800. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77801. * The mesh normals are modified using the same transformation.
  77802. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77803. * @param transform defines the transform matrix to use
  77804. * @see http://doc.babylonjs.com/resources/baking_transformations
  77805. * @returns the current mesh
  77806. */
  77807. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77808. /**
  77809. * Modifies the mesh geometry according to its own current World Matrix.
  77810. * The mesh World Matrix is then reset.
  77811. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77812. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77813. * @see http://doc.babylonjs.com/resources/baking_transformations
  77814. * @returns the current mesh
  77815. */
  77816. bakeCurrentTransformIntoVertices(): Mesh;
  77817. /** @hidden */
  77818. readonly _positions: Nullable<Vector3[]>;
  77819. /** @hidden */
  77820. _resetPointsArrayCache(): Mesh;
  77821. /** @hidden */
  77822. _generatePointsArray(): boolean;
  77823. /**
  77824. * Returns a new Mesh object generated from the current mesh properties.
  77825. * This method must not get confused with createInstance()
  77826. * @param name is a string, the name given to the new mesh
  77827. * @param newParent can be any Node object (default `null`)
  77828. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77829. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77830. * @returns a new mesh
  77831. */
  77832. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77833. /**
  77834. * Releases resources associated with this mesh.
  77835. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77836. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77837. */
  77838. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77839. /**
  77840. * Modifies the mesh geometry according to a displacement map.
  77841. * 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.
  77842. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77843. * @param url is a string, the URL from the image file is to be downloaded.
  77844. * @param minHeight is the lower limit of the displacement.
  77845. * @param maxHeight is the upper limit of the displacement.
  77846. * @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.
  77847. * @param uvOffset is an optional vector2 used to offset UV.
  77848. * @param uvScale is an optional vector2 used to scale UV.
  77849. * @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.
  77850. * @returns the Mesh.
  77851. */
  77852. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77853. /**
  77854. * Modifies the mesh geometry according to a displacementMap buffer.
  77855. * 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.
  77856. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77857. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77858. * @param heightMapWidth is the width of the buffer image.
  77859. * @param heightMapHeight is the height of the buffer image.
  77860. * @param minHeight is the lower limit of the displacement.
  77861. * @param maxHeight is the upper limit of the displacement.
  77862. * @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.
  77863. * @param uvOffset is an optional vector2 used to offset UV.
  77864. * @param uvScale is an optional vector2 used to scale UV.
  77865. * @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.
  77866. * @returns the Mesh.
  77867. */
  77868. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77869. /**
  77870. * Modify the mesh to get a flat shading rendering.
  77871. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77872. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77873. * @returns current mesh
  77874. */
  77875. convertToFlatShadedMesh(): Mesh;
  77876. /**
  77877. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77878. * In other words, more vertices, no more indices and a single bigger VBO.
  77879. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77880. * @returns current mesh
  77881. */
  77882. convertToUnIndexedMesh(): Mesh;
  77883. /**
  77884. * Inverses facet orientations.
  77885. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77886. * @param flipNormals will also inverts the normals
  77887. * @returns current mesh
  77888. */
  77889. flipFaces(flipNormals?: boolean): Mesh;
  77890. /** @hidden */
  77891. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77892. /** @hidden */
  77893. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77894. /**
  77895. * Creates a new InstancedMesh object from the mesh model.
  77896. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77897. * @param name defines the name of the new instance
  77898. * @returns a new InstancedMesh
  77899. */
  77900. createInstance(name: string): InstancedMesh;
  77901. /**
  77902. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77903. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77904. * @returns the current mesh
  77905. */
  77906. synchronizeInstances(): Mesh;
  77907. /**
  77908. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77909. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77910. * This should be used together with the simplification to avoid disappearing triangles.
  77911. * @param successCallback an optional success callback to be called after the optimization finished.
  77912. * @returns the current mesh
  77913. */
  77914. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77915. /**
  77916. * Serialize current mesh
  77917. * @param serializationObject defines the object which will receive the serialization data
  77918. */
  77919. serialize(serializationObject: any): void;
  77920. /** @hidden */
  77921. _syncGeometryWithMorphTargetManager(): void;
  77922. /** @hidden */
  77923. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77924. /**
  77925. * Returns a new Mesh object parsed from the source provided.
  77926. * @param parsedMesh is the source
  77927. * @param scene defines the hosting scene
  77928. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77929. * @returns a new Mesh
  77930. */
  77931. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77932. /**
  77933. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77934. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77935. * @param name defines the name of the mesh to create
  77936. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77937. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77938. * @param closePath creates a seam between the first and the last points of each path of the path array
  77939. * @param offset is taken in account only if the `pathArray` is containing a single path
  77940. * @param scene defines the hosting scene
  77941. * @param updatable defines if the mesh must be flagged as updatable
  77942. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77943. * @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)
  77944. * @returns a new Mesh
  77945. */
  77946. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77947. /**
  77948. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77949. * @param name defines the name of the mesh to create
  77950. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77951. * @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
  77952. * @param scene defines the hosting scene
  77953. * @param updatable defines if the mesh must be flagged as updatable
  77954. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77955. * @returns a new Mesh
  77956. */
  77957. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77958. /**
  77959. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77960. * @param name defines the name of the mesh to create
  77961. * @param size sets the size (float) of each box side (default 1)
  77962. * @param scene defines the hosting scene
  77963. * @param updatable defines if the mesh must be flagged as updatable
  77964. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77965. * @returns a new Mesh
  77966. */
  77967. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77968. /**
  77969. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77970. * @param name defines the name of the mesh to create
  77971. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77972. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77973. * @param scene defines the hosting scene
  77974. * @param updatable defines if the mesh must be flagged as updatable
  77975. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77976. * @returns a new Mesh
  77977. */
  77978. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77979. /**
  77980. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77981. * @param name defines the name of the mesh to create
  77982. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77983. * @param diameterTop set the top cap diameter (floats, default 1)
  77984. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77985. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77986. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77987. * @param scene defines the hosting scene
  77988. * @param updatable defines if the mesh must be flagged as updatable
  77989. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77990. * @returns a new Mesh
  77991. */
  77992. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77993. /**
  77994. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77995. * @param name defines the name of the mesh to create
  77996. * @param diameter sets the diameter size (float) of the torus (default 1)
  77997. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77998. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77999. * @param scene defines the hosting scene
  78000. * @param updatable defines if the mesh must be flagged as updatable
  78001. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78002. * @returns a new Mesh
  78003. */
  78004. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78005. /**
  78006. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  78007. * @param name defines the name of the mesh to create
  78008. * @param radius sets the global radius size (float) of the torus knot (default 2)
  78009. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  78010. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  78011. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  78012. * @param p the number of windings on X axis (positive integers, default 2)
  78013. * @param q the number of windings on Y axis (positive integers, default 3)
  78014. * @param scene defines the hosting scene
  78015. * @param updatable defines if the mesh must be flagged as updatable
  78016. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78017. * @returns a new Mesh
  78018. */
  78019. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78020. /**
  78021. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  78022. * @param name defines the name of the mesh to create
  78023. * @param points is an array successive Vector3
  78024. * @param scene defines the hosting scene
  78025. * @param updatable defines if the mesh must be flagged as updatable
  78026. * @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).
  78027. * @returns a new Mesh
  78028. */
  78029. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  78030. /**
  78031. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  78032. * @param name defines the name of the mesh to create
  78033. * @param points is an array successive Vector3
  78034. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  78035. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78036. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  78037. * @param scene defines the hosting scene
  78038. * @param updatable defines if the mesh must be flagged as updatable
  78039. * @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)
  78040. * @returns a new Mesh
  78041. */
  78042. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  78043. /**
  78044. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  78045. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  78046. * 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.
  78047. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78048. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78049. * Remember you can only change the shape positions, not their number when updating a polygon.
  78050. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78051. * @param name defines the name of the mesh to create
  78052. * @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
  78053. * @param scene defines the hosting scene
  78054. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78055. * @param updatable defines if the mesh must be flagged as updatable
  78056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78057. * @param earcutInjection can be used to inject your own earcut reference
  78058. * @returns a new Mesh
  78059. */
  78060. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78061. /**
  78062. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78063. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78064. * @param name defines the name of the mesh to create
  78065. * @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
  78066. * @param depth defines the height of extrusion
  78067. * @param scene defines the hosting scene
  78068. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78069. * @param updatable defines if the mesh must be flagged as updatable
  78070. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78071. * @param earcutInjection can be used to inject your own earcut reference
  78072. * @returns a new Mesh
  78073. */
  78074. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78075. /**
  78076. * Creates an extruded shape mesh.
  78077. * 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
  78078. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78079. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78080. * @param name defines the name of the mesh to create
  78081. * @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
  78082. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78083. * @param scale is the value to scale the shape
  78084. * @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
  78085. * @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
  78086. * @param scene defines the hosting scene
  78087. * @param updatable defines if the mesh must be flagged as updatable
  78088. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78089. * @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)
  78090. * @returns a new Mesh
  78091. */
  78092. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78093. /**
  78094. * Creates an custom extruded shape mesh.
  78095. * The custom extrusion is a parametric shape.
  78096. * It has no predefined shape. Its final shape will depend on the input parameters.
  78097. * Please consider using the same method from the MeshBuilder class instead
  78098. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78099. * @param name defines the name of the mesh to create
  78100. * @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
  78101. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78102. * @param scaleFunction is a custom Javascript function called on each path point
  78103. * @param rotationFunction is a custom Javascript function called on each path point
  78104. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78105. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78106. * @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
  78107. * @param scene defines the hosting scene
  78108. * @param updatable defines if the mesh must be flagged as updatable
  78109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78110. * @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)
  78111. * @returns a new Mesh
  78112. */
  78113. 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;
  78114. /**
  78115. * Creates lathe mesh.
  78116. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78117. * Please consider using the same method from the MeshBuilder class instead
  78118. * @param name defines the name of the mesh to create
  78119. * @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
  78120. * @param radius is the radius value of the lathe
  78121. * @param tessellation is the side number of the lathe.
  78122. * @param scene defines the hosting scene
  78123. * @param updatable defines if the mesh must be flagged as updatable
  78124. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78125. * @returns a new Mesh
  78126. */
  78127. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78128. /**
  78129. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78130. * @param name defines the name of the mesh to create
  78131. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78132. * @param scene defines the hosting scene
  78133. * @param updatable defines if the mesh must be flagged as updatable
  78134. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78135. * @returns a new Mesh
  78136. */
  78137. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78138. /**
  78139. * Creates a ground mesh.
  78140. * Please consider using the same method from the MeshBuilder class instead
  78141. * @param name defines the name of the mesh to create
  78142. * @param width set the width of the ground
  78143. * @param height set the height of the ground
  78144. * @param subdivisions sets the number of subdivisions per side
  78145. * @param scene defines the hosting scene
  78146. * @param updatable defines if the mesh must be flagged as updatable
  78147. * @returns a new Mesh
  78148. */
  78149. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78150. /**
  78151. * Creates a tiled ground mesh.
  78152. * Please consider using the same method from the MeshBuilder class instead
  78153. * @param name defines the name of the mesh to create
  78154. * @param xmin set the ground minimum X coordinate
  78155. * @param zmin set the ground minimum Y coordinate
  78156. * @param xmax set the ground maximum X coordinate
  78157. * @param zmax set the ground maximum Z coordinate
  78158. * @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
  78159. * @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
  78160. * @param scene defines the hosting scene
  78161. * @param updatable defines if the mesh must be flagged as updatable
  78162. * @returns a new Mesh
  78163. */
  78164. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78165. w: number;
  78166. h: number;
  78167. }, precision: {
  78168. w: number;
  78169. h: number;
  78170. }, scene: Scene, updatable?: boolean): Mesh;
  78171. /**
  78172. * Creates a ground mesh from a height map.
  78173. * Please consider using the same method from the MeshBuilder class instead
  78174. * @see http://doc.babylonjs.com/babylon101/height_map
  78175. * @param name defines the name of the mesh to create
  78176. * @param url sets the URL of the height map image resource
  78177. * @param width set the ground width size
  78178. * @param height set the ground height size
  78179. * @param subdivisions sets the number of subdivision per side
  78180. * @param minHeight is the minimum altitude on the ground
  78181. * @param maxHeight is the maximum altitude on the ground
  78182. * @param scene defines the hosting scene
  78183. * @param updatable defines if the mesh must be flagged as updatable
  78184. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78185. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78186. * @returns a new Mesh
  78187. */
  78188. 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;
  78189. /**
  78190. * Creates a tube mesh.
  78191. * The tube is a parametric shape.
  78192. * It has no predefined shape. Its final shape will depend on the input parameters.
  78193. * Please consider using the same method from the MeshBuilder class instead
  78194. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78195. * @param name defines the name of the mesh to create
  78196. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78197. * @param radius sets the tube radius size
  78198. * @param tessellation is the number of sides on the tubular surface
  78199. * @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
  78200. * @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
  78201. * @param scene defines the hosting scene
  78202. * @param updatable defines if the mesh must be flagged as updatable
  78203. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78204. * @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)
  78205. * @returns a new Mesh
  78206. */
  78207. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78208. (i: number, distance: number): number;
  78209. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78210. /**
  78211. * Creates a polyhedron mesh.
  78212. * Please consider using the same method from the MeshBuilder class instead.
  78213. * * 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
  78214. * * The parameter `size` (positive float, default 1) sets the polygon size
  78215. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78216. * * 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`
  78217. * * 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
  78218. * * 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)`)
  78219. * * 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
  78220. * * 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
  78221. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78222. * * If you create a double-sided mesh, you can choose what parts of 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
  78223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78224. * @param name defines the name of the mesh to create
  78225. * @param options defines the options used to create the mesh
  78226. * @param scene defines the hosting scene
  78227. * @returns a new Mesh
  78228. */
  78229. static CreatePolyhedron(name: string, options: {
  78230. type?: number;
  78231. size?: number;
  78232. sizeX?: number;
  78233. sizeY?: number;
  78234. sizeZ?: number;
  78235. custom?: any;
  78236. faceUV?: Vector4[];
  78237. faceColors?: Color4[];
  78238. updatable?: boolean;
  78239. sideOrientation?: number;
  78240. }, scene: Scene): Mesh;
  78241. /**
  78242. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78243. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78244. * * 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`)
  78245. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78246. * * 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
  78247. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78248. * * If you create a double-sided mesh, you can choose what parts of 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
  78249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78250. * @param name defines the name of the mesh
  78251. * @param options defines the options used to create the mesh
  78252. * @param scene defines the hosting scene
  78253. * @returns a new Mesh
  78254. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78255. */
  78256. static CreateIcoSphere(name: string, options: {
  78257. radius?: number;
  78258. flat?: boolean;
  78259. subdivisions?: number;
  78260. sideOrientation?: number;
  78261. updatable?: boolean;
  78262. }, scene: Scene): Mesh;
  78263. /**
  78264. * Creates a decal mesh.
  78265. * Please consider using the same method from the MeshBuilder class instead.
  78266. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78267. * @param name defines the name of the mesh
  78268. * @param sourceMesh defines the mesh receiving the decal
  78269. * @param position sets the position of the decal in world coordinates
  78270. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78271. * @param size sets the decal scaling
  78272. * @param angle sets the angle to rotate the decal
  78273. * @returns a new Mesh
  78274. */
  78275. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78276. /**
  78277. * Prepare internal position array for software CPU skinning
  78278. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78279. */
  78280. setPositionsForCPUSkinning(): Float32Array;
  78281. /**
  78282. * Prepare internal normal array for software CPU skinning
  78283. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78284. */
  78285. setNormalsForCPUSkinning(): Float32Array;
  78286. /**
  78287. * Updates the vertex buffer by applying transformation from the bones
  78288. * @param skeleton defines the skeleton to apply to current mesh
  78289. * @returns the current mesh
  78290. */
  78291. applySkeleton(skeleton: Skeleton): Mesh;
  78292. /**
  78293. * 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
  78294. * @param meshes defines the list of meshes to scan
  78295. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78296. */
  78297. static MinMax(meshes: AbstractMesh[]): {
  78298. min: Vector3;
  78299. max: Vector3;
  78300. };
  78301. /**
  78302. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78303. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78304. * @returns a vector3
  78305. */
  78306. static Center(meshesOrMinMaxVector: {
  78307. min: Vector3;
  78308. max: Vector3;
  78309. } | AbstractMesh[]): Vector3;
  78310. /**
  78311. * Merge the array of meshes into a single mesh for performance reasons.
  78312. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78313. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78314. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78315. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78316. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78317. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78318. * @returns a new mesh
  78319. */
  78320. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78321. /** @hidden */
  78322. addInstance(instance: InstancedMesh): void;
  78323. /** @hidden */
  78324. removeInstance(instance: InstancedMesh): void;
  78325. }
  78326. }
  78327. declare module BABYLON {
  78328. /**
  78329. * Base class for the main features of a material in Babylon.js
  78330. */
  78331. export class Material implements IAnimatable {
  78332. /**
  78333. * Returns the triangle fill mode
  78334. */
  78335. static readonly TriangleFillMode: number;
  78336. /**
  78337. * Returns the wireframe mode
  78338. */
  78339. static readonly WireFrameFillMode: number;
  78340. /**
  78341. * Returns the point fill mode
  78342. */
  78343. static readonly PointFillMode: number;
  78344. /**
  78345. * Returns the point list draw mode
  78346. */
  78347. static readonly PointListDrawMode: number;
  78348. /**
  78349. * Returns the line list draw mode
  78350. */
  78351. static readonly LineListDrawMode: number;
  78352. /**
  78353. * Returns the line loop draw mode
  78354. */
  78355. static readonly LineLoopDrawMode: number;
  78356. /**
  78357. * Returns the line strip draw mode
  78358. */
  78359. static readonly LineStripDrawMode: number;
  78360. /**
  78361. * Returns the triangle strip draw mode
  78362. */
  78363. static readonly TriangleStripDrawMode: number;
  78364. /**
  78365. * Returns the triangle fan draw mode
  78366. */
  78367. static readonly TriangleFanDrawMode: number;
  78368. /**
  78369. * Stores the clock-wise side orientation
  78370. */
  78371. static readonly ClockWiseSideOrientation: number;
  78372. /**
  78373. * Stores the counter clock-wise side orientation
  78374. */
  78375. static readonly CounterClockWiseSideOrientation: number;
  78376. /**
  78377. * The dirty texture flag value
  78378. */
  78379. static readonly TextureDirtyFlag: number;
  78380. /**
  78381. * The dirty light flag value
  78382. */
  78383. static readonly LightDirtyFlag: number;
  78384. /**
  78385. * The dirty fresnel flag value
  78386. */
  78387. static readonly FresnelDirtyFlag: number;
  78388. /**
  78389. * The dirty attribute flag value
  78390. */
  78391. static readonly AttributesDirtyFlag: number;
  78392. /**
  78393. * The dirty misc flag value
  78394. */
  78395. static readonly MiscDirtyFlag: number;
  78396. /**
  78397. * The all dirty flag value
  78398. */
  78399. static readonly AllDirtyFlag: number;
  78400. /**
  78401. * The ID of the material
  78402. */
  78403. id: string;
  78404. /**
  78405. * Gets or sets the unique id of the material
  78406. */
  78407. uniqueId: number;
  78408. /**
  78409. * The name of the material
  78410. */
  78411. name: string;
  78412. /**
  78413. * Gets or sets user defined metadata
  78414. */
  78415. metadata: any;
  78416. /**
  78417. * For internal use only. Please do not use.
  78418. */
  78419. reservedDataStore: any;
  78420. /**
  78421. * Specifies if the ready state should be checked on each call
  78422. */
  78423. checkReadyOnEveryCall: boolean;
  78424. /**
  78425. * Specifies if the ready state should be checked once
  78426. */
  78427. checkReadyOnlyOnce: boolean;
  78428. /**
  78429. * The state of the material
  78430. */
  78431. state: string;
  78432. /**
  78433. * The alpha value of the material
  78434. */
  78435. protected _alpha: number;
  78436. /**
  78437. * Sets the alpha value of the material
  78438. */
  78439. /**
  78440. * Gets the alpha value of the material
  78441. */
  78442. alpha: number;
  78443. /**
  78444. * Specifies if back face culling is enabled
  78445. */
  78446. protected _backFaceCulling: boolean;
  78447. /**
  78448. * Sets the back-face culling state
  78449. */
  78450. /**
  78451. * Gets the back-face culling state
  78452. */
  78453. backFaceCulling: boolean;
  78454. /**
  78455. * Stores the value for side orientation
  78456. */
  78457. sideOrientation: number;
  78458. /**
  78459. * Callback triggered when the material is compiled
  78460. */
  78461. onCompiled: (effect: Effect) => void;
  78462. /**
  78463. * Callback triggered when an error occurs
  78464. */
  78465. onError: (effect: Effect, errors: string) => void;
  78466. /**
  78467. * Callback triggered to get the render target textures
  78468. */
  78469. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  78470. /**
  78471. * Gets a boolean indicating that current material needs to register RTT
  78472. */
  78473. readonly hasRenderTargetTextures: boolean;
  78474. /**
  78475. * Specifies if the material should be serialized
  78476. */
  78477. doNotSerialize: boolean;
  78478. /**
  78479. * @hidden
  78480. */
  78481. _storeEffectOnSubMeshes: boolean;
  78482. /**
  78483. * Stores the animations for the material
  78484. */
  78485. animations: Array<Animation>;
  78486. /**
  78487. * An event triggered when the material is disposed
  78488. */
  78489. onDisposeObservable: Observable<Material>;
  78490. /**
  78491. * An observer which watches for dispose events
  78492. */
  78493. private _onDisposeObserver;
  78494. private _onUnBindObservable;
  78495. /**
  78496. * Called during a dispose event
  78497. */
  78498. onDispose: () => void;
  78499. private _onBindObservable;
  78500. /**
  78501. * An event triggered when the material is bound
  78502. */
  78503. readonly onBindObservable: Observable<AbstractMesh>;
  78504. /**
  78505. * An observer which watches for bind events
  78506. */
  78507. private _onBindObserver;
  78508. /**
  78509. * Called during a bind event
  78510. */
  78511. onBind: (Mesh: AbstractMesh) => void;
  78512. /**
  78513. * An event triggered when the material is unbound
  78514. */
  78515. readonly onUnBindObservable: Observable<Material>;
  78516. /**
  78517. * Stores the value of the alpha mode
  78518. */
  78519. private _alphaMode;
  78520. /**
  78521. * Sets the value of the alpha mode.
  78522. *
  78523. * | Value | Type | Description |
  78524. * | --- | --- | --- |
  78525. * | 0 | ALPHA_DISABLE | |
  78526. * | 1 | ALPHA_ADD | |
  78527. * | 2 | ALPHA_COMBINE | |
  78528. * | 3 | ALPHA_SUBTRACT | |
  78529. * | 4 | ALPHA_MULTIPLY | |
  78530. * | 5 | ALPHA_MAXIMIZED | |
  78531. * | 6 | ALPHA_ONEONE | |
  78532. * | 7 | ALPHA_PREMULTIPLIED | |
  78533. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  78534. * | 9 | ALPHA_INTERPOLATE | |
  78535. * | 10 | ALPHA_SCREENMODE | |
  78536. *
  78537. */
  78538. /**
  78539. * Gets the value of the alpha mode
  78540. */
  78541. alphaMode: number;
  78542. /**
  78543. * Stores the state of the need depth pre-pass value
  78544. */
  78545. private _needDepthPrePass;
  78546. /**
  78547. * Sets the need depth pre-pass value
  78548. */
  78549. /**
  78550. * Gets the depth pre-pass value
  78551. */
  78552. needDepthPrePass: boolean;
  78553. /**
  78554. * Specifies if depth writing should be disabled
  78555. */
  78556. disableDepthWrite: boolean;
  78557. /**
  78558. * Specifies if depth writing should be forced
  78559. */
  78560. forceDepthWrite: boolean;
  78561. /**
  78562. * Specifies if there should be a separate pass for culling
  78563. */
  78564. separateCullingPass: boolean;
  78565. /**
  78566. * Stores the state specifing if fog should be enabled
  78567. */
  78568. private _fogEnabled;
  78569. /**
  78570. * Sets the state for enabling fog
  78571. */
  78572. /**
  78573. * Gets the value of the fog enabled state
  78574. */
  78575. fogEnabled: boolean;
  78576. /**
  78577. * Stores the size of points
  78578. */
  78579. pointSize: number;
  78580. /**
  78581. * Stores the z offset value
  78582. */
  78583. zOffset: number;
  78584. /**
  78585. * Gets a value specifying if wireframe mode is enabled
  78586. */
  78587. /**
  78588. * Sets the state of wireframe mode
  78589. */
  78590. wireframe: boolean;
  78591. /**
  78592. * Gets the value specifying if point clouds are enabled
  78593. */
  78594. /**
  78595. * Sets the state of point cloud mode
  78596. */
  78597. pointsCloud: boolean;
  78598. /**
  78599. * Gets the material fill mode
  78600. */
  78601. /**
  78602. * Sets the material fill mode
  78603. */
  78604. fillMode: number;
  78605. /**
  78606. * @hidden
  78607. * Stores the effects for the material
  78608. */
  78609. _effect: Nullable<Effect>;
  78610. /**
  78611. * @hidden
  78612. * Specifies if the material was previously ready
  78613. */
  78614. _wasPreviouslyReady: boolean;
  78615. /**
  78616. * Specifies if uniform buffers should be used
  78617. */
  78618. private _useUBO;
  78619. /**
  78620. * Stores a reference to the scene
  78621. */
  78622. private _scene;
  78623. /**
  78624. * Stores the fill mode state
  78625. */
  78626. private _fillMode;
  78627. /**
  78628. * Specifies if the depth write state should be cached
  78629. */
  78630. private _cachedDepthWriteState;
  78631. /**
  78632. * Stores the uniform buffer
  78633. */
  78634. protected _uniformBuffer: UniformBuffer;
  78635. /** @hidden */
  78636. _indexInSceneMaterialArray: number;
  78637. /** @hidden */
  78638. meshMap: Nullable<{
  78639. [id: string]: AbstractMesh | undefined;
  78640. }>;
  78641. /**
  78642. * Creates a material instance
  78643. * @param name defines the name of the material
  78644. * @param scene defines the scene to reference
  78645. * @param doNotAdd specifies if the material should be added to the scene
  78646. */
  78647. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  78648. /**
  78649. * Returns a string representation of the current material
  78650. * @param fullDetails defines a boolean indicating which levels of logging is desired
  78651. * @returns a string with material information
  78652. */
  78653. toString(fullDetails?: boolean): string;
  78654. /**
  78655. * Gets the class name of the material
  78656. * @returns a string with the class name of the material
  78657. */
  78658. getClassName(): string;
  78659. /**
  78660. * Specifies if updates for the material been locked
  78661. */
  78662. readonly isFrozen: boolean;
  78663. /**
  78664. * Locks updates for the material
  78665. */
  78666. freeze(): void;
  78667. /**
  78668. * Unlocks updates for the material
  78669. */
  78670. unfreeze(): void;
  78671. /**
  78672. * Specifies if the material is ready to be used
  78673. * @param mesh defines the mesh to check
  78674. * @param useInstances specifies if instances should be used
  78675. * @returns a boolean indicating if the material is ready to be used
  78676. */
  78677. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  78678. /**
  78679. * Specifies that the submesh is ready to be used
  78680. * @param mesh defines the mesh to check
  78681. * @param subMesh defines which submesh to check
  78682. * @param useInstances specifies that instances should be used
  78683. * @returns a boolean indicating that the submesh is ready or not
  78684. */
  78685. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  78686. /**
  78687. * Returns the material effect
  78688. * @returns the effect associated with the material
  78689. */
  78690. getEffect(): Nullable<Effect>;
  78691. /**
  78692. * Returns the current scene
  78693. * @returns a Scene
  78694. */
  78695. getScene(): Scene;
  78696. /**
  78697. * Specifies if the material will require alpha blending
  78698. * @returns a boolean specifying if alpha blending is needed
  78699. */
  78700. needAlphaBlending(): boolean;
  78701. /**
  78702. * Specifies if the mesh will require alpha blending
  78703. * @param mesh defines the mesh to check
  78704. * @returns a boolean specifying if alpha blending is needed for the mesh
  78705. */
  78706. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  78707. /**
  78708. * Specifies if this material should be rendered in alpha test mode
  78709. * @returns a boolean specifying if an alpha test is needed.
  78710. */
  78711. needAlphaTesting(): boolean;
  78712. /**
  78713. * Gets the texture used for the alpha test
  78714. * @returns the texture to use for alpha testing
  78715. */
  78716. getAlphaTestTexture(): Nullable<BaseTexture>;
  78717. /**
  78718. * Marks the material to indicate that it needs to be re-calculated
  78719. */
  78720. markDirty(): void;
  78721. /** @hidden */
  78722. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  78723. /**
  78724. * Binds the material to the mesh
  78725. * @param world defines the world transformation matrix
  78726. * @param mesh defines the mesh to bind the material to
  78727. */
  78728. bind(world: Matrix, mesh?: Mesh): void;
  78729. /**
  78730. * Binds the submesh to the material
  78731. * @param world defines the world transformation matrix
  78732. * @param mesh defines the mesh containing the submesh
  78733. * @param subMesh defines the submesh to bind the material to
  78734. */
  78735. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  78736. /**
  78737. * Binds the world matrix to the material
  78738. * @param world defines the world transformation matrix
  78739. */
  78740. bindOnlyWorldMatrix(world: Matrix): void;
  78741. /**
  78742. * Binds the scene's uniform buffer to the effect.
  78743. * @param effect defines the effect to bind to the scene uniform buffer
  78744. * @param sceneUbo defines the uniform buffer storing scene data
  78745. */
  78746. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  78747. /**
  78748. * Binds the view matrix to the effect
  78749. * @param effect defines the effect to bind the view matrix to
  78750. */
  78751. bindView(effect: Effect): void;
  78752. /**
  78753. * Binds the view projection matrix to the effect
  78754. * @param effect defines the effect to bind the view projection matrix to
  78755. */
  78756. bindViewProjection(effect: Effect): void;
  78757. /**
  78758. * Specifies if material alpha testing should be turned on for the mesh
  78759. * @param mesh defines the mesh to check
  78760. */
  78761. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  78762. /**
  78763. * Processes to execute after binding the material to a mesh
  78764. * @param mesh defines the rendered mesh
  78765. */
  78766. protected _afterBind(mesh?: Mesh): void;
  78767. /**
  78768. * Unbinds the material from the mesh
  78769. */
  78770. unbind(): void;
  78771. /**
  78772. * Gets the active textures from the material
  78773. * @returns an array of textures
  78774. */
  78775. getActiveTextures(): BaseTexture[];
  78776. /**
  78777. * Specifies if the material uses a texture
  78778. * @param texture defines the texture to check against the material
  78779. * @returns a boolean specifying if the material uses the texture
  78780. */
  78781. hasTexture(texture: BaseTexture): boolean;
  78782. /**
  78783. * Makes a duplicate of the material, and gives it a new name
  78784. * @param name defines the new name for the duplicated material
  78785. * @returns the cloned material
  78786. */
  78787. clone(name: string): Nullable<Material>;
  78788. /**
  78789. * Gets the meshes bound to the material
  78790. * @returns an array of meshes bound to the material
  78791. */
  78792. getBindedMeshes(): AbstractMesh[];
  78793. /**
  78794. * Force shader compilation
  78795. * @param mesh defines the mesh associated with this material
  78796. * @param onCompiled defines a function to execute once the material is compiled
  78797. * @param options defines the options to configure the compilation
  78798. */
  78799. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  78800. clipPlane: boolean;
  78801. }>): void;
  78802. /**
  78803. * Force shader compilation
  78804. * @param mesh defines the mesh that will use this material
  78805. * @param options defines additional options for compiling the shaders
  78806. * @returns a promise that resolves when the compilation completes
  78807. */
  78808. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  78809. clipPlane: boolean;
  78810. }>): Promise<void>;
  78811. private static readonly _ImageProcessingDirtyCallBack;
  78812. private static readonly _TextureDirtyCallBack;
  78813. private static readonly _FresnelDirtyCallBack;
  78814. private static readonly _MiscDirtyCallBack;
  78815. private static readonly _LightsDirtyCallBack;
  78816. private static readonly _AttributeDirtyCallBack;
  78817. private static _FresnelAndMiscDirtyCallBack;
  78818. private static _TextureAndMiscDirtyCallBack;
  78819. private static readonly _DirtyCallbackArray;
  78820. private static readonly _RunDirtyCallBacks;
  78821. /**
  78822. * Marks a define in the material to indicate that it needs to be re-computed
  78823. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  78824. */
  78825. markAsDirty(flag: number): void;
  78826. /**
  78827. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  78828. * @param func defines a function which checks material defines against the submeshes
  78829. */
  78830. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  78831. /**
  78832. * Indicates that image processing needs to be re-calculated for all submeshes
  78833. */
  78834. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  78835. /**
  78836. * Indicates that textures need to be re-calculated for all submeshes
  78837. */
  78838. protected _markAllSubMeshesAsTexturesDirty(): void;
  78839. /**
  78840. * Indicates that fresnel needs to be re-calculated for all submeshes
  78841. */
  78842. protected _markAllSubMeshesAsFresnelDirty(): void;
  78843. /**
  78844. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  78845. */
  78846. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  78847. /**
  78848. * Indicates that lights need to be re-calculated for all submeshes
  78849. */
  78850. protected _markAllSubMeshesAsLightsDirty(): void;
  78851. /**
  78852. * Indicates that attributes need to be re-calculated for all submeshes
  78853. */
  78854. protected _markAllSubMeshesAsAttributesDirty(): void;
  78855. /**
  78856. * Indicates that misc needs to be re-calculated for all submeshes
  78857. */
  78858. protected _markAllSubMeshesAsMiscDirty(): void;
  78859. /**
  78860. * Indicates that textures and misc need to be re-calculated for all submeshes
  78861. */
  78862. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  78863. /**
  78864. * Disposes the material
  78865. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78866. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  78867. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  78868. */
  78869. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  78870. /** @hidden */
  78871. private releaseVertexArrayObject;
  78872. /**
  78873. * Serializes this material
  78874. * @returns the serialized material object
  78875. */
  78876. serialize(): any;
  78877. /**
  78878. * Creates a material from parsed material data
  78879. * @param parsedMaterial defines parsed material data
  78880. * @param scene defines the hosting scene
  78881. * @param rootUrl defines the root URL to use to load textures
  78882. * @returns a new material
  78883. */
  78884. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  78885. }
  78886. }
  78887. declare module BABYLON {
  78888. /**
  78889. * Base class for submeshes
  78890. */
  78891. export class BaseSubMesh {
  78892. /** @hidden */
  78893. _materialDefines: Nullable<MaterialDefines>;
  78894. /** @hidden */
  78895. _materialEffect: Nullable<Effect>;
  78896. /**
  78897. * Gets associated effect
  78898. */
  78899. readonly effect: Nullable<Effect>;
  78900. /**
  78901. * Sets associated effect (effect used to render this submesh)
  78902. * @param effect defines the effect to associate with
  78903. * @param defines defines the set of defines used to compile this effect
  78904. */
  78905. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  78906. }
  78907. /**
  78908. * Defines a subdivision inside a mesh
  78909. */
  78910. export class SubMesh extends BaseSubMesh implements ICullable {
  78911. /** the material index to use */
  78912. materialIndex: number;
  78913. /** vertex index start */
  78914. verticesStart: number;
  78915. /** vertices count */
  78916. verticesCount: number;
  78917. /** index start */
  78918. indexStart: number;
  78919. /** indices count */
  78920. indexCount: number;
  78921. /** @hidden */
  78922. _linesIndexCount: number;
  78923. private _mesh;
  78924. private _renderingMesh;
  78925. private _boundingInfo;
  78926. private _linesIndexBuffer;
  78927. /** @hidden */
  78928. _lastColliderWorldVertices: Nullable<Vector3[]>;
  78929. /** @hidden */
  78930. _trianglePlanes: Plane[];
  78931. /** @hidden */
  78932. _lastColliderTransformMatrix: Matrix;
  78933. /** @hidden */
  78934. _renderId: number;
  78935. /** @hidden */
  78936. _alphaIndex: number;
  78937. /** @hidden */
  78938. _distanceToCamera: number;
  78939. /** @hidden */
  78940. _id: number;
  78941. private _currentMaterial;
  78942. /**
  78943. * Add a new submesh to a mesh
  78944. * @param materialIndex defines the material index to use
  78945. * @param verticesStart defines vertex index start
  78946. * @param verticesCount defines vertices count
  78947. * @param indexStart defines index start
  78948. * @param indexCount defines indices count
  78949. * @param mesh defines the parent mesh
  78950. * @param renderingMesh defines an optional rendering mesh
  78951. * @param createBoundingBox defines if bounding box should be created for this submesh
  78952. * @returns the new submesh
  78953. */
  78954. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  78955. /**
  78956. * Creates a new submesh
  78957. * @param materialIndex defines the material index to use
  78958. * @param verticesStart defines vertex index start
  78959. * @param verticesCount defines vertices count
  78960. * @param indexStart defines index start
  78961. * @param indexCount defines indices count
  78962. * @param mesh defines the parent mesh
  78963. * @param renderingMesh defines an optional rendering mesh
  78964. * @param createBoundingBox defines if bounding box should be created for this submesh
  78965. */
  78966. constructor(
  78967. /** the material index to use */
  78968. materialIndex: number,
  78969. /** vertex index start */
  78970. verticesStart: number,
  78971. /** vertices count */
  78972. verticesCount: number,
  78973. /** index start */
  78974. indexStart: number,
  78975. /** indices count */
  78976. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  78977. /**
  78978. * Returns true if this submesh covers the entire parent mesh
  78979. * @ignorenaming
  78980. */
  78981. readonly IsGlobal: boolean;
  78982. /**
  78983. * Returns the submesh BoudingInfo object
  78984. * @returns current bounding info (or mesh's one if the submesh is global)
  78985. */
  78986. getBoundingInfo(): BoundingInfo;
  78987. /**
  78988. * Sets the submesh BoundingInfo
  78989. * @param boundingInfo defines the new bounding info to use
  78990. * @returns the SubMesh
  78991. */
  78992. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  78993. /**
  78994. * Returns the mesh of the current submesh
  78995. * @return the parent mesh
  78996. */
  78997. getMesh(): AbstractMesh;
  78998. /**
  78999. * Returns the rendering mesh of the submesh
  79000. * @returns the rendering mesh (could be different from parent mesh)
  79001. */
  79002. getRenderingMesh(): Mesh;
  79003. /**
  79004. * Returns the submesh material
  79005. * @returns null or the current material
  79006. */
  79007. getMaterial(): Nullable<Material>;
  79008. /**
  79009. * Sets a new updated BoundingInfo object to the submesh
  79010. * @returns the SubMesh
  79011. */
  79012. refreshBoundingInfo(): SubMesh;
  79013. /** @hidden */
  79014. _checkCollision(collider: Collider): boolean;
  79015. /**
  79016. * Updates the submesh BoundingInfo
  79017. * @param world defines the world matrix to use to update the bounding info
  79018. * @returns the submesh
  79019. */
  79020. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  79021. /**
  79022. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  79023. * @param frustumPlanes defines the frustum planes
  79024. * @returns true if the submesh is intersecting with the frustum
  79025. */
  79026. isInFrustum(frustumPlanes: Plane[]): boolean;
  79027. /**
  79028. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  79029. * @param frustumPlanes defines the frustum planes
  79030. * @returns true if the submesh is inside the frustum
  79031. */
  79032. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79033. /**
  79034. * Renders the submesh
  79035. * @param enableAlphaMode defines if alpha needs to be used
  79036. * @returns the submesh
  79037. */
  79038. render(enableAlphaMode: boolean): SubMesh;
  79039. /**
  79040. * @hidden
  79041. */
  79042. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  79043. /**
  79044. * Checks if the submesh intersects with a ray
  79045. * @param ray defines the ray to test
  79046. * @returns true is the passed ray intersects the submesh bounding box
  79047. */
  79048. canIntersects(ray: Ray): boolean;
  79049. /**
  79050. * Intersects current submesh with a ray
  79051. * @param ray defines the ray to test
  79052. * @param positions defines mesh's positions array
  79053. * @param indices defines mesh's indices array
  79054. * @param fastCheck defines if only bounding info should be used
  79055. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  79056. * @returns intersection info or null if no intersection
  79057. */
  79058. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  79059. /** @hidden */
  79060. private _intersectLines;
  79061. /** @hidden */
  79062. private _intersectTriangles;
  79063. /** @hidden */
  79064. _rebuild(): void;
  79065. /**
  79066. * Creates a new submesh from the passed mesh
  79067. * @param newMesh defines the new hosting mesh
  79068. * @param newRenderingMesh defines an optional rendering mesh
  79069. * @returns the new submesh
  79070. */
  79071. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79072. /**
  79073. * Release associated resources
  79074. */
  79075. dispose(): void;
  79076. /**
  79077. * Gets the class name
  79078. * @returns the string "SubMesh".
  79079. */
  79080. getClassName(): string;
  79081. /**
  79082. * Creates a new submesh from indices data
  79083. * @param materialIndex the index of the main mesh material
  79084. * @param startIndex the index where to start the copy in the mesh indices array
  79085. * @param indexCount the number of indices to copy then from the startIndex
  79086. * @param mesh the main mesh to create the submesh from
  79087. * @param renderingMesh the optional rendering mesh
  79088. * @returns a new submesh
  79089. */
  79090. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79091. }
  79092. }
  79093. declare module BABYLON {
  79094. /**
  79095. * Class used to store geometry data (vertex buffers + index buffer)
  79096. */
  79097. export class Geometry implements IGetSetVerticesData {
  79098. /**
  79099. * Gets or sets the ID of the geometry
  79100. */
  79101. id: string;
  79102. /**
  79103. * Gets or sets the unique ID of the geometry
  79104. */
  79105. uniqueId: number;
  79106. /**
  79107. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79108. */
  79109. delayLoadState: number;
  79110. /**
  79111. * Gets the file containing the data to load when running in delay load state
  79112. */
  79113. delayLoadingFile: Nullable<string>;
  79114. /**
  79115. * Callback called when the geometry is updated
  79116. */
  79117. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79118. private _scene;
  79119. private _engine;
  79120. private _meshes;
  79121. private _totalVertices;
  79122. /** @hidden */
  79123. _indices: IndicesArray;
  79124. /** @hidden */
  79125. _vertexBuffers: {
  79126. [key: string]: VertexBuffer;
  79127. };
  79128. private _isDisposed;
  79129. private _extend;
  79130. private _boundingBias;
  79131. /** @hidden */
  79132. _delayInfo: Array<string>;
  79133. private _indexBuffer;
  79134. private _indexBufferIsUpdatable;
  79135. /** @hidden */
  79136. _boundingInfo: Nullable<BoundingInfo>;
  79137. /** @hidden */
  79138. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79139. /** @hidden */
  79140. _softwareSkinningFrameId: number;
  79141. private _vertexArrayObjects;
  79142. private _updatable;
  79143. /** @hidden */
  79144. _positions: Nullable<Vector3[]>;
  79145. /**
  79146. * 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
  79147. */
  79148. /**
  79149. * 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
  79150. */
  79151. boundingBias: Vector2;
  79152. /**
  79153. * Static function used to attach a new empty geometry to a mesh
  79154. * @param mesh defines the mesh to attach the geometry to
  79155. * @returns the new Geometry
  79156. */
  79157. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79158. /**
  79159. * Creates a new geometry
  79160. * @param id defines the unique ID
  79161. * @param scene defines the hosting scene
  79162. * @param vertexData defines the VertexData used to get geometry data
  79163. * @param updatable defines if geometry must be updatable (false by default)
  79164. * @param mesh defines the mesh that will be associated with the geometry
  79165. */
  79166. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79167. /**
  79168. * Gets the current extend of the geometry
  79169. */
  79170. readonly extend: {
  79171. minimum: Vector3;
  79172. maximum: Vector3;
  79173. };
  79174. /**
  79175. * Gets the hosting scene
  79176. * @returns the hosting Scene
  79177. */
  79178. getScene(): Scene;
  79179. /**
  79180. * Gets the hosting engine
  79181. * @returns the hosting Engine
  79182. */
  79183. getEngine(): Engine;
  79184. /**
  79185. * Defines if the geometry is ready to use
  79186. * @returns true if the geometry is ready to be used
  79187. */
  79188. isReady(): boolean;
  79189. /**
  79190. * Gets a value indicating that the geometry should not be serialized
  79191. */
  79192. readonly doNotSerialize: boolean;
  79193. /** @hidden */
  79194. _rebuild(): void;
  79195. /**
  79196. * Affects all geometry data in one call
  79197. * @param vertexData defines the geometry data
  79198. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79199. */
  79200. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79201. /**
  79202. * Set specific vertex data
  79203. * @param kind defines the data kind (Position, normal, etc...)
  79204. * @param data defines the vertex data to use
  79205. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79206. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79207. */
  79208. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79209. /**
  79210. * Removes a specific vertex data
  79211. * @param kind defines the data kind (Position, normal, etc...)
  79212. */
  79213. removeVerticesData(kind: string): void;
  79214. /**
  79215. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79216. * @param buffer defines the vertex buffer to use
  79217. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79218. */
  79219. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79220. /**
  79221. * Update a specific vertex buffer
  79222. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79223. * It will do nothing if the buffer is not updatable
  79224. * @param kind defines the data kind (Position, normal, etc...)
  79225. * @param data defines the data to use
  79226. * @param offset defines the offset in the target buffer where to store the data
  79227. * @param useBytes set to true if the offset is in bytes
  79228. */
  79229. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79230. /**
  79231. * Update a specific vertex buffer
  79232. * This function will create a new buffer if the current one is not updatable
  79233. * @param kind defines the data kind (Position, normal, etc...)
  79234. * @param data defines the data to use
  79235. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79236. */
  79237. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79238. private _updateBoundingInfo;
  79239. /** @hidden */
  79240. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79241. /**
  79242. * Gets total number of vertices
  79243. * @returns the total number of vertices
  79244. */
  79245. getTotalVertices(): number;
  79246. /**
  79247. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79248. * @param kind defines the data kind (Position, normal, etc...)
  79249. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79250. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79251. * @returns a float array containing vertex data
  79252. */
  79253. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79254. /**
  79255. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79256. * @param kind defines the data kind (Position, normal, etc...)
  79257. * @returns true if the vertex buffer with the specified kind is updatable
  79258. */
  79259. isVertexBufferUpdatable(kind: string): boolean;
  79260. /**
  79261. * Gets a specific vertex buffer
  79262. * @param kind defines the data kind (Position, normal, etc...)
  79263. * @returns a VertexBuffer
  79264. */
  79265. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79266. /**
  79267. * Returns all vertex buffers
  79268. * @return an object holding all vertex buffers indexed by kind
  79269. */
  79270. getVertexBuffers(): Nullable<{
  79271. [key: string]: VertexBuffer;
  79272. }>;
  79273. /**
  79274. * Gets a boolean indicating if specific vertex buffer is present
  79275. * @param kind defines the data kind (Position, normal, etc...)
  79276. * @returns true if data is present
  79277. */
  79278. isVerticesDataPresent(kind: string): boolean;
  79279. /**
  79280. * Gets a list of all attached data kinds (Position, normal, etc...)
  79281. * @returns a list of string containing all kinds
  79282. */
  79283. getVerticesDataKinds(): string[];
  79284. /**
  79285. * Update index buffer
  79286. * @param indices defines the indices to store in the index buffer
  79287. * @param offset defines the offset in the target buffer where to store the data
  79288. */
  79289. updateIndices(indices: IndicesArray, offset?: number): void;
  79290. /**
  79291. * Creates a new index buffer
  79292. * @param indices defines the indices to store in the index buffer
  79293. * @param totalVertices defines the total number of vertices (could be null)
  79294. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79295. */
  79296. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79297. /**
  79298. * Return the total number of indices
  79299. * @returns the total number of indices
  79300. */
  79301. getTotalIndices(): number;
  79302. /**
  79303. * Gets the index buffer array
  79304. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79305. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79306. * @returns the index buffer array
  79307. */
  79308. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79309. /**
  79310. * Gets the index buffer
  79311. * @return the index buffer
  79312. */
  79313. getIndexBuffer(): Nullable<WebGLBuffer>;
  79314. /** @hidden */
  79315. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79316. /**
  79317. * Release the associated resources for a specific mesh
  79318. * @param mesh defines the source mesh
  79319. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79320. */
  79321. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79322. /**
  79323. * Apply current geometry to a given mesh
  79324. * @param mesh defines the mesh to apply geometry to
  79325. */
  79326. applyToMesh(mesh: Mesh): void;
  79327. private _updateExtend;
  79328. private _applyToMesh;
  79329. private notifyUpdate;
  79330. /**
  79331. * Load the geometry if it was flagged as delay loaded
  79332. * @param scene defines the hosting scene
  79333. * @param onLoaded defines a callback called when the geometry is loaded
  79334. */
  79335. load(scene: Scene, onLoaded?: () => void): void;
  79336. private _queueLoad;
  79337. /**
  79338. * Invert the geometry to move from a right handed system to a left handed one.
  79339. */
  79340. toLeftHanded(): void;
  79341. /** @hidden */
  79342. _resetPointsArrayCache(): void;
  79343. /** @hidden */
  79344. _generatePointsArray(): boolean;
  79345. /**
  79346. * Gets a value indicating if the geometry is disposed
  79347. * @returns true if the geometry was disposed
  79348. */
  79349. isDisposed(): boolean;
  79350. private _disposeVertexArrayObjects;
  79351. /**
  79352. * Free all associated resources
  79353. */
  79354. dispose(): void;
  79355. /**
  79356. * Clone the current geometry into a new geometry
  79357. * @param id defines the unique ID of the new geometry
  79358. * @returns a new geometry object
  79359. */
  79360. copy(id: string): Geometry;
  79361. /**
  79362. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79363. * @return a JSON representation of the current geometry data (without the vertices data)
  79364. */
  79365. serialize(): any;
  79366. private toNumberArray;
  79367. /**
  79368. * Serialize all vertices data into a JSON oject
  79369. * @returns a JSON representation of the current geometry data
  79370. */
  79371. serializeVerticeData(): any;
  79372. /**
  79373. * Extracts a clone of a mesh geometry
  79374. * @param mesh defines the source mesh
  79375. * @param id defines the unique ID of the new geometry object
  79376. * @returns the new geometry object
  79377. */
  79378. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79379. /**
  79380. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  79381. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  79382. * Be aware Math.random() could cause collisions, but:
  79383. * "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"
  79384. * @returns a string containing a new GUID
  79385. */
  79386. static RandomId(): string;
  79387. /** @hidden */
  79388. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  79389. private static _CleanMatricesWeights;
  79390. /**
  79391. * Create a new geometry from persisted data (Using .babylon file format)
  79392. * @param parsedVertexData defines the persisted data
  79393. * @param scene defines the hosting scene
  79394. * @param rootUrl defines the root url to use to load assets (like delayed data)
  79395. * @returns the new geometry object
  79396. */
  79397. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  79398. }
  79399. }
  79400. declare module BABYLON {
  79401. /**
  79402. * Define an interface for all classes that will get and set the data on vertices
  79403. */
  79404. export interface IGetSetVerticesData {
  79405. /**
  79406. * Gets a boolean indicating if specific vertex data is present
  79407. * @param kind defines the vertex data kind to use
  79408. * @returns true is data kind is present
  79409. */
  79410. isVerticesDataPresent(kind: string): boolean;
  79411. /**
  79412. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79413. * @param kind defines the data kind (Position, normal, etc...)
  79414. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79415. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79416. * @returns a float array containing vertex data
  79417. */
  79418. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79419. /**
  79420. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79421. * @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.
  79422. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79423. * @returns the indices array or an empty array if the mesh has no geometry
  79424. */
  79425. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79426. /**
  79427. * Set specific vertex data
  79428. * @param kind defines the data kind (Position, normal, etc...)
  79429. * @param data defines the vertex data to use
  79430. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79431. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79432. */
  79433. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  79434. /**
  79435. * Update a specific associated vertex buffer
  79436. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79437. * - VertexBuffer.PositionKind
  79438. * - VertexBuffer.UVKind
  79439. * - VertexBuffer.UV2Kind
  79440. * - VertexBuffer.UV3Kind
  79441. * - VertexBuffer.UV4Kind
  79442. * - VertexBuffer.UV5Kind
  79443. * - VertexBuffer.UV6Kind
  79444. * - VertexBuffer.ColorKind
  79445. * - VertexBuffer.MatricesIndicesKind
  79446. * - VertexBuffer.MatricesIndicesExtraKind
  79447. * - VertexBuffer.MatricesWeightsKind
  79448. * - VertexBuffer.MatricesWeightsExtraKind
  79449. * @param data defines the data source
  79450. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79451. * @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)
  79452. */
  79453. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  79454. /**
  79455. * Creates a new index buffer
  79456. * @param indices defines the indices to store in the index buffer
  79457. * @param totalVertices defines the total number of vertices (could be null)
  79458. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79459. */
  79460. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  79461. }
  79462. /**
  79463. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  79464. */
  79465. export class VertexData {
  79466. /**
  79467. * Mesh side orientation : usually the external or front surface
  79468. */
  79469. static readonly FRONTSIDE: number;
  79470. /**
  79471. * Mesh side orientation : usually the internal or back surface
  79472. */
  79473. static readonly BACKSIDE: number;
  79474. /**
  79475. * Mesh side orientation : both internal and external or front and back surfaces
  79476. */
  79477. static readonly DOUBLESIDE: number;
  79478. /**
  79479. * Mesh side orientation : by default, `FRONTSIDE`
  79480. */
  79481. static readonly DEFAULTSIDE: number;
  79482. /**
  79483. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  79484. */
  79485. positions: Nullable<FloatArray>;
  79486. /**
  79487. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  79488. */
  79489. normals: Nullable<FloatArray>;
  79490. /**
  79491. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  79492. */
  79493. tangents: Nullable<FloatArray>;
  79494. /**
  79495. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79496. */
  79497. uvs: Nullable<FloatArray>;
  79498. /**
  79499. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79500. */
  79501. uvs2: Nullable<FloatArray>;
  79502. /**
  79503. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79504. */
  79505. uvs3: Nullable<FloatArray>;
  79506. /**
  79507. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79508. */
  79509. uvs4: Nullable<FloatArray>;
  79510. /**
  79511. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79512. */
  79513. uvs5: Nullable<FloatArray>;
  79514. /**
  79515. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79516. */
  79517. uvs6: Nullable<FloatArray>;
  79518. /**
  79519. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  79520. */
  79521. colors: Nullable<FloatArray>;
  79522. /**
  79523. * 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).
  79524. */
  79525. matricesIndices: Nullable<FloatArray>;
  79526. /**
  79527. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  79528. */
  79529. matricesWeights: Nullable<FloatArray>;
  79530. /**
  79531. * An array extending the number of possible indices
  79532. */
  79533. matricesIndicesExtra: Nullable<FloatArray>;
  79534. /**
  79535. * An array extending the number of possible weights when the number of indices is extended
  79536. */
  79537. matricesWeightsExtra: Nullable<FloatArray>;
  79538. /**
  79539. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  79540. */
  79541. indices: Nullable<IndicesArray>;
  79542. /**
  79543. * Uses the passed data array to set the set the values for the specified kind of data
  79544. * @param data a linear array of floating numbers
  79545. * @param kind the type of data that is being set, eg positions, colors etc
  79546. */
  79547. set(data: FloatArray, kind: string): void;
  79548. /**
  79549. * Associates the vertexData to the passed Mesh.
  79550. * Sets it as updatable or not (default `false`)
  79551. * @param mesh the mesh the vertexData is applied to
  79552. * @param updatable when used and having the value true allows new data to update the vertexData
  79553. * @returns the VertexData
  79554. */
  79555. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  79556. /**
  79557. * Associates the vertexData to the passed Geometry.
  79558. * Sets it as updatable or not (default `false`)
  79559. * @param geometry the geometry the vertexData is applied to
  79560. * @param updatable when used and having the value true allows new data to update the vertexData
  79561. * @returns VertexData
  79562. */
  79563. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  79564. /**
  79565. * Updates the associated mesh
  79566. * @param mesh the mesh to be updated
  79567. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79568. * @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
  79569. * @returns VertexData
  79570. */
  79571. updateMesh(mesh: Mesh): VertexData;
  79572. /**
  79573. * Updates the associated geometry
  79574. * @param geometry the geometry to be updated
  79575. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79576. * @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
  79577. * @returns VertexData.
  79578. */
  79579. updateGeometry(geometry: Geometry): VertexData;
  79580. private _applyTo;
  79581. private _update;
  79582. /**
  79583. * Transforms each position and each normal of the vertexData according to the passed Matrix
  79584. * @param matrix the transforming matrix
  79585. * @returns the VertexData
  79586. */
  79587. transform(matrix: Matrix): VertexData;
  79588. /**
  79589. * Merges the passed VertexData into the current one
  79590. * @param other the VertexData to be merged into the current one
  79591. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  79592. * @returns the modified VertexData
  79593. */
  79594. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  79595. private _mergeElement;
  79596. private _validate;
  79597. /**
  79598. * Serializes the VertexData
  79599. * @returns a serialized object
  79600. */
  79601. serialize(): any;
  79602. /**
  79603. * Extracts the vertexData from a mesh
  79604. * @param mesh the mesh from which to extract the VertexData
  79605. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  79606. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79607. * @returns the object VertexData associated to the passed mesh
  79608. */
  79609. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79610. /**
  79611. * Extracts the vertexData from the geometry
  79612. * @param geometry the geometry from which to extract the VertexData
  79613. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  79614. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79615. * @returns the object VertexData associated to the passed mesh
  79616. */
  79617. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79618. private static _ExtractFrom;
  79619. /**
  79620. * Creates the VertexData for a Ribbon
  79621. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  79622. * * pathArray array of paths, each of which an array of successive Vector3
  79623. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  79624. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  79625. * * 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
  79626. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79627. * * 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)
  79628. * * 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)
  79629. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  79630. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  79631. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  79632. * @returns the VertexData of the ribbon
  79633. */
  79634. static CreateRibbon(options: {
  79635. pathArray: Vector3[][];
  79636. closeArray?: boolean;
  79637. closePath?: boolean;
  79638. offset?: number;
  79639. sideOrientation?: number;
  79640. frontUVs?: Vector4;
  79641. backUVs?: Vector4;
  79642. invertUV?: boolean;
  79643. uvs?: Vector2[];
  79644. colors?: Color4[];
  79645. }): VertexData;
  79646. /**
  79647. * Creates the VertexData for a box
  79648. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79649. * * size sets the width, height and depth of the box to the value of size, optional default 1
  79650. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  79651. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  79652. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  79653. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  79654. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  79655. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79656. * * 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)
  79657. * * 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)
  79658. * @returns the VertexData of the box
  79659. */
  79660. static CreateBox(options: {
  79661. size?: number;
  79662. width?: number;
  79663. height?: number;
  79664. depth?: number;
  79665. faceUV?: Vector4[];
  79666. faceColors?: Color4[];
  79667. sideOrientation?: number;
  79668. frontUVs?: Vector4;
  79669. backUVs?: Vector4;
  79670. }): VertexData;
  79671. /**
  79672. * Creates the VertexData for an ellipsoid, defaults to a sphere
  79673. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79674. * * segments sets the number of horizontal strips optional, default 32
  79675. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  79676. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  79677. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  79678. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  79679. * * 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
  79680. * * 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
  79681. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79682. * * 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)
  79683. * * 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)
  79684. * @returns the VertexData of the ellipsoid
  79685. */
  79686. static CreateSphere(options: {
  79687. segments?: number;
  79688. diameter?: number;
  79689. diameterX?: number;
  79690. diameterY?: number;
  79691. diameterZ?: number;
  79692. arc?: number;
  79693. slice?: number;
  79694. sideOrientation?: number;
  79695. frontUVs?: Vector4;
  79696. backUVs?: Vector4;
  79697. }): VertexData;
  79698. /**
  79699. * Creates the VertexData for a cylinder, cone or prism
  79700. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79701. * * height sets the height (y direction) of the cylinder, optional, default 2
  79702. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  79703. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  79704. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  79705. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79706. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  79707. * * 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
  79708. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79709. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79710. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  79711. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  79712. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79713. * * 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)
  79714. * * 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)
  79715. * @returns the VertexData of the cylinder, cone or prism
  79716. */
  79717. static CreateCylinder(options: {
  79718. height?: number;
  79719. diameterTop?: number;
  79720. diameterBottom?: number;
  79721. diameter?: number;
  79722. tessellation?: number;
  79723. subdivisions?: number;
  79724. arc?: number;
  79725. faceColors?: Color4[];
  79726. faceUV?: Vector4[];
  79727. hasRings?: boolean;
  79728. enclose?: boolean;
  79729. sideOrientation?: number;
  79730. frontUVs?: Vector4;
  79731. backUVs?: Vector4;
  79732. }): VertexData;
  79733. /**
  79734. * Creates the VertexData for a torus
  79735. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79736. * * diameter the diameter of the torus, optional default 1
  79737. * * thickness the diameter of the tube forming the torus, optional default 0.5
  79738. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79739. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79740. * * 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)
  79741. * * 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)
  79742. * @returns the VertexData of the torus
  79743. */
  79744. static CreateTorus(options: {
  79745. diameter?: number;
  79746. thickness?: number;
  79747. tessellation?: number;
  79748. sideOrientation?: number;
  79749. frontUVs?: Vector4;
  79750. backUVs?: Vector4;
  79751. }): VertexData;
  79752. /**
  79753. * Creates the VertexData of the LineSystem
  79754. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  79755. * - lines an array of lines, each line being an array of successive Vector3
  79756. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  79757. * @returns the VertexData of the LineSystem
  79758. */
  79759. static CreateLineSystem(options: {
  79760. lines: Vector3[][];
  79761. colors?: Nullable<Color4[][]>;
  79762. }): VertexData;
  79763. /**
  79764. * Create the VertexData for a DashedLines
  79765. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  79766. * - points an array successive Vector3
  79767. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  79768. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  79769. * - dashNb the intended total number of dashes, optional, default 200
  79770. * @returns the VertexData for the DashedLines
  79771. */
  79772. static CreateDashedLines(options: {
  79773. points: Vector3[];
  79774. dashSize?: number;
  79775. gapSize?: number;
  79776. dashNb?: number;
  79777. }): VertexData;
  79778. /**
  79779. * Creates the VertexData for a Ground
  79780. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79781. * - width the width (x direction) of the ground, optional, default 1
  79782. * - height the height (z direction) of the ground, optional, default 1
  79783. * - subdivisions the number of subdivisions per side, optional, default 1
  79784. * @returns the VertexData of the Ground
  79785. */
  79786. static CreateGround(options: {
  79787. width?: number;
  79788. height?: number;
  79789. subdivisions?: number;
  79790. subdivisionsX?: number;
  79791. subdivisionsY?: number;
  79792. }): VertexData;
  79793. /**
  79794. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  79795. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79796. * * xmin the ground minimum X coordinate, optional, default -1
  79797. * * zmin the ground minimum Z coordinate, optional, default -1
  79798. * * xmax the ground maximum X coordinate, optional, default 1
  79799. * * zmax the ground maximum Z coordinate, optional, default 1
  79800. * * 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}
  79801. * * 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}
  79802. * @returns the VertexData of the TiledGround
  79803. */
  79804. static CreateTiledGround(options: {
  79805. xmin: number;
  79806. zmin: number;
  79807. xmax: number;
  79808. zmax: number;
  79809. subdivisions?: {
  79810. w: number;
  79811. h: number;
  79812. };
  79813. precision?: {
  79814. w: number;
  79815. h: number;
  79816. };
  79817. }): VertexData;
  79818. /**
  79819. * Creates the VertexData of the Ground designed from a heightmap
  79820. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  79821. * * width the width (x direction) of the ground
  79822. * * height the height (z direction) of the ground
  79823. * * subdivisions the number of subdivisions per side
  79824. * * minHeight the minimum altitude on the ground, optional, default 0
  79825. * * maxHeight the maximum altitude on the ground, optional default 1
  79826. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  79827. * * buffer the array holding the image color data
  79828. * * bufferWidth the width of image
  79829. * * bufferHeight the height of image
  79830. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  79831. * @returns the VertexData of the Ground designed from a heightmap
  79832. */
  79833. static CreateGroundFromHeightMap(options: {
  79834. width: number;
  79835. height: number;
  79836. subdivisions: number;
  79837. minHeight: number;
  79838. maxHeight: number;
  79839. colorFilter: Color3;
  79840. buffer: Uint8Array;
  79841. bufferWidth: number;
  79842. bufferHeight: number;
  79843. alphaFilter: number;
  79844. }): VertexData;
  79845. /**
  79846. * Creates the VertexData for a Plane
  79847. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  79848. * * size sets the width and height of the plane to the value of size, optional default 1
  79849. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  79850. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  79851. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79852. * * 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)
  79853. * * 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)
  79854. * @returns the VertexData of the box
  79855. */
  79856. static CreatePlane(options: {
  79857. size?: number;
  79858. width?: number;
  79859. height?: number;
  79860. sideOrientation?: number;
  79861. frontUVs?: Vector4;
  79862. backUVs?: Vector4;
  79863. }): VertexData;
  79864. /**
  79865. * Creates the VertexData of the Disc or regular Polygon
  79866. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  79867. * * radius the radius of the disc, optional default 0.5
  79868. * * tessellation the number of polygon sides, optional, default 64
  79869. * * 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
  79870. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79871. * * 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)
  79872. * * 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)
  79873. * @returns the VertexData of the box
  79874. */
  79875. static CreateDisc(options: {
  79876. radius?: number;
  79877. tessellation?: number;
  79878. arc?: number;
  79879. sideOrientation?: number;
  79880. frontUVs?: Vector4;
  79881. backUVs?: Vector4;
  79882. }): VertexData;
  79883. /**
  79884. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  79885. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  79886. * @param polygon a mesh built from polygonTriangulation.build()
  79887. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79888. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79889. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79890. * @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)
  79891. * @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)
  79892. * @returns the VertexData of the Polygon
  79893. */
  79894. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  79895. /**
  79896. * Creates the VertexData of the IcoSphere
  79897. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  79898. * * radius the radius of the IcoSphere, optional default 1
  79899. * * radiusX allows stretching in the x direction, optional, default radius
  79900. * * radiusY allows stretching in the y direction, optional, default radius
  79901. * * radiusZ allows stretching in the z direction, optional, default radius
  79902. * * flat when true creates a flat shaded mesh, optional, default true
  79903. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79905. * * 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)
  79906. * * 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)
  79907. * @returns the VertexData of the IcoSphere
  79908. */
  79909. static CreateIcoSphere(options: {
  79910. radius?: number;
  79911. radiusX?: number;
  79912. radiusY?: number;
  79913. radiusZ?: number;
  79914. flat?: boolean;
  79915. subdivisions?: number;
  79916. sideOrientation?: number;
  79917. frontUVs?: Vector4;
  79918. backUVs?: Vector4;
  79919. }): VertexData;
  79920. /**
  79921. * Creates the VertexData for a Polyhedron
  79922. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  79923. * * type provided types are:
  79924. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  79925. * * 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)
  79926. * * size the size of the IcoSphere, optional default 1
  79927. * * sizeX allows stretching in the x direction, optional, default size
  79928. * * sizeY allows stretching in the y direction, optional, default size
  79929. * * sizeZ allows stretching in the z direction, optional, default size
  79930. * * 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
  79931. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79932. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79933. * * flat when true creates a flat shaded mesh, optional, default true
  79934. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79935. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79936. * * 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)
  79937. * * 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)
  79938. * @returns the VertexData of the Polyhedron
  79939. */
  79940. static CreatePolyhedron(options: {
  79941. type?: number;
  79942. size?: number;
  79943. sizeX?: number;
  79944. sizeY?: number;
  79945. sizeZ?: number;
  79946. custom?: any;
  79947. faceUV?: Vector4[];
  79948. faceColors?: Color4[];
  79949. flat?: boolean;
  79950. sideOrientation?: number;
  79951. frontUVs?: Vector4;
  79952. backUVs?: Vector4;
  79953. }): VertexData;
  79954. /**
  79955. * Creates the VertexData for a TorusKnot
  79956. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  79957. * * radius the radius of the torus knot, optional, default 2
  79958. * * tube the thickness of the tube, optional, default 0.5
  79959. * * radialSegments the number of sides on each tube segments, optional, default 32
  79960. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  79961. * * p the number of windings around the z axis, optional, default 2
  79962. * * q the number of windings around the x axis, optional, default 3
  79963. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79964. * * 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)
  79965. * * 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)
  79966. * @returns the VertexData of the Torus Knot
  79967. */
  79968. static CreateTorusKnot(options: {
  79969. radius?: number;
  79970. tube?: number;
  79971. radialSegments?: number;
  79972. tubularSegments?: number;
  79973. p?: number;
  79974. q?: number;
  79975. sideOrientation?: number;
  79976. frontUVs?: Vector4;
  79977. backUVs?: Vector4;
  79978. }): VertexData;
  79979. /**
  79980. * Compute normals for given positions and indices
  79981. * @param positions an array of vertex positions, [...., x, y, z, ......]
  79982. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  79983. * @param normals an array of vertex normals, [...., x, y, z, ......]
  79984. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  79985. * * facetNormals : optional array of facet normals (vector3)
  79986. * * facetPositions : optional array of facet positions (vector3)
  79987. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  79988. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  79989. * * bInfo : optional bounding info, required for facetPartitioning computation
  79990. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  79991. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  79992. * * useRightHandedSystem: optional boolean to for right handed system computation
  79993. * * depthSort : optional boolean to enable the facet depth sort computation
  79994. * * distanceTo : optional Vector3 to compute the facet depth from this location
  79995. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  79996. */
  79997. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  79998. facetNormals?: any;
  79999. facetPositions?: any;
  80000. facetPartitioning?: any;
  80001. ratio?: number;
  80002. bInfo?: any;
  80003. bbSize?: Vector3;
  80004. subDiv?: any;
  80005. useRightHandedSystem?: boolean;
  80006. depthSort?: boolean;
  80007. distanceTo?: Vector3;
  80008. depthSortedFacets?: any;
  80009. }): void;
  80010. /** @hidden */
  80011. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  80012. /**
  80013. * Applies VertexData created from the imported parameters to the geometry
  80014. * @param parsedVertexData the parsed data from an imported file
  80015. * @param geometry the geometry to apply the VertexData to
  80016. */
  80017. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  80018. }
  80019. }
  80020. declare module BABYLON {
  80021. /**
  80022. * Class containing static functions to help procedurally build meshes
  80023. */
  80024. export class DiscBuilder {
  80025. /**
  80026. * Creates a plane polygonal mesh. By default, this is a disc
  80027. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80028. * * 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
  80029. * * 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
  80030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80031. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80033. * @param name defines the name of the mesh
  80034. * @param options defines the options used to create the mesh
  80035. * @param scene defines the hosting scene
  80036. * @returns the plane polygonal mesh
  80037. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80038. */
  80039. static CreateDisc(name: string, options: {
  80040. radius?: number;
  80041. tessellation?: number;
  80042. arc?: number;
  80043. updatable?: boolean;
  80044. sideOrientation?: number;
  80045. frontUVs?: Vector4;
  80046. backUVs?: Vector4;
  80047. }, scene?: Nullable<Scene>): Mesh;
  80048. }
  80049. }
  80050. declare module BABYLON {
  80051. /**
  80052. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  80053. *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.
  80054. * The SPS is also a particle system. It provides some methods to manage the particles.
  80055. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  80056. *
  80057. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  80058. */
  80059. export class SolidParticleSystem implements IDisposable {
  80060. /**
  80061. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80062. * Example : var p = SPS.particles[i];
  80063. */
  80064. particles: SolidParticle[];
  80065. /**
  80066. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80067. */
  80068. nbParticles: number;
  80069. /**
  80070. * If the particles must ever face the camera (default false). Useful for planar particles.
  80071. */
  80072. billboard: boolean;
  80073. /**
  80074. * Recompute normals when adding a shape
  80075. */
  80076. recomputeNormals: boolean;
  80077. /**
  80078. * This a counter ofr your own usage. It's not set by any SPS functions.
  80079. */
  80080. counter: number;
  80081. /**
  80082. * The SPS name. This name is also given to the underlying mesh.
  80083. */
  80084. name: string;
  80085. /**
  80086. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80087. */
  80088. mesh: Mesh;
  80089. /**
  80090. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80091. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80092. */
  80093. vars: any;
  80094. /**
  80095. * This array is populated when the SPS is set as 'pickable'.
  80096. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80097. * Each element of this array is an object `{idx: int, faceId: int}`.
  80098. * `idx` is the picked particle index in the `SPS.particles` array
  80099. * `faceId` is the picked face index counted within this particle.
  80100. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80101. */
  80102. pickedParticles: {
  80103. idx: number;
  80104. faceId: number;
  80105. }[];
  80106. /**
  80107. * This array is populated when `enableDepthSort` is set to true.
  80108. * Each element of this array is an instance of the class DepthSortedParticle.
  80109. */
  80110. depthSortedParticles: DepthSortedParticle[];
  80111. /**
  80112. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80113. * @hidden
  80114. */
  80115. _bSphereOnly: boolean;
  80116. /**
  80117. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80118. * @hidden
  80119. */
  80120. _bSphereRadiusFactor: number;
  80121. private _scene;
  80122. private _positions;
  80123. private _indices;
  80124. private _normals;
  80125. private _colors;
  80126. private _uvs;
  80127. private _indices32;
  80128. private _positions32;
  80129. private _normals32;
  80130. private _fixedNormal32;
  80131. private _colors32;
  80132. private _uvs32;
  80133. private _index;
  80134. private _updatable;
  80135. private _pickable;
  80136. private _isVisibilityBoxLocked;
  80137. private _alwaysVisible;
  80138. private _depthSort;
  80139. private _shapeCounter;
  80140. private _copy;
  80141. private _color;
  80142. private _computeParticleColor;
  80143. private _computeParticleTexture;
  80144. private _computeParticleRotation;
  80145. private _computeParticleVertex;
  80146. private _computeBoundingBox;
  80147. private _depthSortParticles;
  80148. private _camera;
  80149. private _mustUnrotateFixedNormals;
  80150. private _particlesIntersect;
  80151. private _needs32Bits;
  80152. /**
  80153. * Creates a SPS (Solid Particle System) object.
  80154. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80155. * @param scene (Scene) is the scene in which the SPS is added.
  80156. * @param options defines the options of the sps e.g.
  80157. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80158. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80159. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80160. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80161. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80162. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80163. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80164. */
  80165. constructor(name: string, scene: Scene, options?: {
  80166. updatable?: boolean;
  80167. isPickable?: boolean;
  80168. enableDepthSort?: boolean;
  80169. particleIntersection?: boolean;
  80170. boundingSphereOnly?: boolean;
  80171. bSphereRadiusFactor?: number;
  80172. });
  80173. /**
  80174. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80175. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80176. * @returns the created mesh
  80177. */
  80178. buildMesh(): Mesh;
  80179. /**
  80180. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80181. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80182. * Thus the particles generated from `digest()` have their property `position` set yet.
  80183. * @param mesh ( Mesh ) is the mesh to be digested
  80184. * @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
  80185. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80186. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80187. * @returns the current SPS
  80188. */
  80189. digest(mesh: Mesh, options?: {
  80190. facetNb?: number;
  80191. number?: number;
  80192. delta?: number;
  80193. }): SolidParticleSystem;
  80194. private _unrotateFixedNormals;
  80195. private _resetCopy;
  80196. private _meshBuilder;
  80197. private _posToShape;
  80198. private _uvsToShapeUV;
  80199. private _addParticle;
  80200. /**
  80201. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80202. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80203. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80204. * @param nb (positive integer) the number of particles to be created from this model
  80205. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80206. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80207. * @returns the number of shapes in the system
  80208. */
  80209. addShape(mesh: Mesh, nb: number, options?: {
  80210. positionFunction?: any;
  80211. vertexFunction?: any;
  80212. }): number;
  80213. private _rebuildParticle;
  80214. /**
  80215. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80216. * @returns the SPS.
  80217. */
  80218. rebuildMesh(): SolidParticleSystem;
  80219. /**
  80220. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80221. * This method calls `updateParticle()` for each particle of the SPS.
  80222. * For an animated SPS, it is usually called within the render loop.
  80223. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80224. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80225. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80226. * @returns the SPS.
  80227. */
  80228. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80229. /**
  80230. * Disposes the SPS.
  80231. */
  80232. dispose(): void;
  80233. /**
  80234. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80235. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80236. * @returns the SPS.
  80237. */
  80238. refreshVisibleSize(): SolidParticleSystem;
  80239. /**
  80240. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80241. * @param size the size (float) of the visibility box
  80242. * note : this doesn't lock the SPS mesh bounding box.
  80243. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80244. */
  80245. setVisibilityBox(size: number): void;
  80246. /**
  80247. * Gets whether the SPS as always visible or not
  80248. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80249. */
  80250. /**
  80251. * Sets the SPS as always visible or not
  80252. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80253. */
  80254. isAlwaysVisible: boolean;
  80255. /**
  80256. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80257. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80258. */
  80259. /**
  80260. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80261. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80262. */
  80263. isVisibilityBoxLocked: boolean;
  80264. /**
  80265. * Tells to `setParticles()` to compute the particle rotations or not.
  80266. * Default value : true. The SPS is faster when it's set to false.
  80267. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80268. */
  80269. /**
  80270. * Gets if `setParticles()` computes the particle rotations or not.
  80271. * Default value : true. The SPS is faster when it's set to false.
  80272. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80273. */
  80274. computeParticleRotation: boolean;
  80275. /**
  80276. * Tells to `setParticles()` to compute the particle colors or not.
  80277. * Default value : true. The SPS is faster when it's set to false.
  80278. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80279. */
  80280. /**
  80281. * Gets if `setParticles()` computes the particle colors or not.
  80282. * Default value : true. The SPS is faster when it's set to false.
  80283. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80284. */
  80285. computeParticleColor: boolean;
  80286. /**
  80287. * Gets if `setParticles()` computes the particle textures or not.
  80288. * Default value : true. The SPS is faster when it's set to false.
  80289. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80290. */
  80291. computeParticleTexture: boolean;
  80292. /**
  80293. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  80294. * Default value : false. The SPS is faster when it's set to false.
  80295. * Note : the particle custom vertex positions aren't stored values.
  80296. */
  80297. /**
  80298. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80299. * Default value : false. The SPS is faster when it's set to false.
  80300. * Note : the particle custom vertex positions aren't stored values.
  80301. */
  80302. computeParticleVertex: boolean;
  80303. /**
  80304. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80305. */
  80306. /**
  80307. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80308. */
  80309. computeBoundingBox: boolean;
  80310. /**
  80311. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  80312. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80313. * Default : `true`
  80314. */
  80315. /**
  80316. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80317. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80318. * Default : `true`
  80319. */
  80320. depthSortParticles: boolean;
  80321. /**
  80322. * This function does nothing. It may be overwritten to set all the particle first values.
  80323. * The SPS doesn't call this function, you may have to call it by your own.
  80324. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80325. */
  80326. initParticles(): void;
  80327. /**
  80328. * This function does nothing. It may be overwritten to recycle a particle.
  80329. * The SPS doesn't call this function, you may have to call it by your own.
  80330. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80331. * @param particle The particle to recycle
  80332. * @returns the recycled particle
  80333. */
  80334. recycleParticle(particle: SolidParticle): SolidParticle;
  80335. /**
  80336. * Updates a particle : this function should be overwritten by the user.
  80337. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80338. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80339. * @example : just set a particle position or velocity and recycle conditions
  80340. * @param particle The particle to update
  80341. * @returns the updated particle
  80342. */
  80343. updateParticle(particle: SolidParticle): SolidParticle;
  80344. /**
  80345. * Updates a vertex of a particle : it can be overwritten by the user.
  80346. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80347. * @param particle the current particle
  80348. * @param vertex the current index of the current particle
  80349. * @param pt the index of the current vertex in the particle shape
  80350. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80351. * @example : just set a vertex particle position
  80352. * @returns the updated vertex
  80353. */
  80354. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80355. /**
  80356. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80357. * This does nothing and may be overwritten by the user.
  80358. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80359. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80360. * @param update the boolean update value actually passed to setParticles()
  80361. */
  80362. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80363. /**
  80364. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80365. * This will be passed three parameters.
  80366. * This does nothing and may be overwritten by the user.
  80367. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80368. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80369. * @param update the boolean update value actually passed to setParticles()
  80370. */
  80371. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80372. }
  80373. }
  80374. declare module BABYLON {
  80375. /**
  80376. * Represents one particle of a solid particle system.
  80377. */
  80378. export class SolidParticle {
  80379. /**
  80380. * particle global index
  80381. */
  80382. idx: number;
  80383. /**
  80384. * The color of the particle
  80385. */
  80386. color: Nullable<Color4>;
  80387. /**
  80388. * The world space position of the particle.
  80389. */
  80390. position: Vector3;
  80391. /**
  80392. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  80393. */
  80394. rotation: Vector3;
  80395. /**
  80396. * The world space rotation quaternion of the particle.
  80397. */
  80398. rotationQuaternion: Nullable<Quaternion>;
  80399. /**
  80400. * The scaling of the particle.
  80401. */
  80402. scaling: Vector3;
  80403. /**
  80404. * The uvs of the particle.
  80405. */
  80406. uvs: Vector4;
  80407. /**
  80408. * The current speed of the particle.
  80409. */
  80410. velocity: Vector3;
  80411. /**
  80412. * The pivot point in the particle local space.
  80413. */
  80414. pivot: Vector3;
  80415. /**
  80416. * Must the particle be translated from its pivot point in its local space ?
  80417. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  80418. * Default : false
  80419. */
  80420. translateFromPivot: boolean;
  80421. /**
  80422. * Is the particle active or not ?
  80423. */
  80424. alive: boolean;
  80425. /**
  80426. * Is the particle visible or not ?
  80427. */
  80428. isVisible: boolean;
  80429. /**
  80430. * Index of this particle in the global "positions" array (Internal use)
  80431. * @hidden
  80432. */
  80433. _pos: number;
  80434. /**
  80435. * @hidden Index of this particle in the global "indices" array (Internal use)
  80436. */
  80437. _ind: number;
  80438. /**
  80439. * @hidden ModelShape of this particle (Internal use)
  80440. */
  80441. _model: ModelShape;
  80442. /**
  80443. * ModelShape id of this particle
  80444. */
  80445. shapeId: number;
  80446. /**
  80447. * Index of the particle in its shape id (Internal use)
  80448. */
  80449. idxInShape: number;
  80450. /**
  80451. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  80452. */
  80453. _modelBoundingInfo: BoundingInfo;
  80454. /**
  80455. * @hidden Particle BoundingInfo object (Internal use)
  80456. */
  80457. _boundingInfo: BoundingInfo;
  80458. /**
  80459. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  80460. */
  80461. _sps: SolidParticleSystem;
  80462. /**
  80463. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  80464. */
  80465. _stillInvisible: boolean;
  80466. /**
  80467. * @hidden Last computed particle rotation matrix
  80468. */
  80469. _rotationMatrix: number[];
  80470. /**
  80471. * Parent particle Id, if any.
  80472. * Default null.
  80473. */
  80474. parentId: Nullable<number>;
  80475. /**
  80476. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  80477. * The possible values are :
  80478. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80479. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80480. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80481. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80482. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80483. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80484. * */
  80485. cullingStrategy: number;
  80486. /**
  80487. * @hidden Internal global position in the SPS.
  80488. */
  80489. _globalPosition: Vector3;
  80490. /**
  80491. * Creates a Solid Particle object.
  80492. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80493. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80494. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80495. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80496. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80497. * @param shapeId (integer) is the model shape identifier in the SPS.
  80498. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80499. * @param sps defines the sps it is associated to
  80500. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  80501. */
  80502. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  80503. /**
  80504. * Legacy support, changed scale to scaling
  80505. */
  80506. /**
  80507. * Legacy support, changed scale to scaling
  80508. */
  80509. scale: Vector3;
  80510. /**
  80511. * Legacy support, changed quaternion to rotationQuaternion
  80512. */
  80513. /**
  80514. * Legacy support, changed quaternion to rotationQuaternion
  80515. */
  80516. quaternion: Nullable<Quaternion>;
  80517. /**
  80518. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  80519. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  80520. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  80521. * @returns true if it intersects
  80522. */
  80523. intersectsMesh(target: Mesh | SolidParticle): boolean;
  80524. /**
  80525. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  80526. * A particle is in the frustum if its bounding box intersects the frustum
  80527. * @param frustumPlanes defines the frustum to test
  80528. * @returns true if the particle is in the frustum planes
  80529. */
  80530. isInFrustum(frustumPlanes: Plane[]): boolean;
  80531. /**
  80532. * get the rotation matrix of the particle
  80533. * @hidden
  80534. */
  80535. getRotationMatrix(m: Matrix): void;
  80536. }
  80537. /**
  80538. * Represents the shape of the model used by one particle of a solid particle system.
  80539. * SPS internal tool, don't use it manually.
  80540. */
  80541. export class ModelShape {
  80542. /**
  80543. * The shape id
  80544. * @hidden
  80545. */
  80546. shapeID: number;
  80547. /**
  80548. * flat array of model positions (internal use)
  80549. * @hidden
  80550. */
  80551. _shape: Vector3[];
  80552. /**
  80553. * flat array of model UVs (internal use)
  80554. * @hidden
  80555. */
  80556. _shapeUV: number[];
  80557. /**
  80558. * length of the shape in the model indices array (internal use)
  80559. * @hidden
  80560. */
  80561. _indicesLength: number;
  80562. /**
  80563. * Custom position function (internal use)
  80564. * @hidden
  80565. */
  80566. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  80567. /**
  80568. * Custom vertex function (internal use)
  80569. * @hidden
  80570. */
  80571. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  80572. /**
  80573. * 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.
  80574. * SPS internal tool, don't use it manually.
  80575. * @hidden
  80576. */
  80577. 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>);
  80578. }
  80579. /**
  80580. * Represents a Depth Sorted Particle in the solid particle system.
  80581. */
  80582. export class DepthSortedParticle {
  80583. /**
  80584. * Index of the particle in the "indices" array
  80585. */
  80586. ind: number;
  80587. /**
  80588. * Length of the particle shape in the "indices" array
  80589. */
  80590. indicesLength: number;
  80591. /**
  80592. * Squared distance from the particle to the camera
  80593. */
  80594. sqDistance: number;
  80595. }
  80596. }
  80597. declare module BABYLON {
  80598. /**
  80599. * Class used to store all common mesh properties
  80600. */
  80601. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  80602. /** No occlusion */
  80603. static OCCLUSION_TYPE_NONE: number;
  80604. /** Occlusion set to optimisitic */
  80605. static OCCLUSION_TYPE_OPTIMISTIC: number;
  80606. /** Occlusion set to strict */
  80607. static OCCLUSION_TYPE_STRICT: number;
  80608. /** Use an accurante occlusion algorithm */
  80609. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  80610. /** Use a conservative occlusion algorithm */
  80611. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  80612. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80613. * Test order :
  80614. * Is the bounding sphere outside the frustum ?
  80615. * If not, are the bounding box vertices outside the frustum ?
  80616. * It not, then the cullable object is in the frustum.
  80617. */
  80618. static readonly CULLINGSTRATEGY_STANDARD: number;
  80619. /** Culling strategy : Bounding Sphere Only.
  80620. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80621. * It's also less accurate than the standard because some not visible objects can still be selected.
  80622. * Test : is the bounding sphere outside the frustum ?
  80623. * If not, then the cullable object is in the frustum.
  80624. */
  80625. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80626. /** Culling strategy : Optimistic Inclusion.
  80627. * This in an inclusion test first, then the standard exclusion test.
  80628. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80629. * 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.
  80630. * Anyway, it's as accurate as the standard strategy.
  80631. * Test :
  80632. * Is the cullable object bounding sphere center in the frustum ?
  80633. * If not, apply the default culling strategy.
  80634. */
  80635. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80636. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80637. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80638. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80639. * 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.
  80640. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80641. * Test :
  80642. * Is the cullable object bounding sphere center in the frustum ?
  80643. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80644. */
  80645. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80646. /**
  80647. * No billboard
  80648. */
  80649. static readonly BILLBOARDMODE_NONE: number;
  80650. /** Billboard on X axis */
  80651. static readonly BILLBOARDMODE_X: number;
  80652. /** Billboard on Y axis */
  80653. static readonly BILLBOARDMODE_Y: number;
  80654. /** Billboard on Z axis */
  80655. static readonly BILLBOARDMODE_Z: number;
  80656. /** Billboard on all axes */
  80657. static readonly BILLBOARDMODE_ALL: number;
  80658. private _facetData;
  80659. /**
  80660. * The culling strategy to use to check whether the mesh must be rendered or not.
  80661. * This value can be changed at any time and will be used on the next render mesh selection.
  80662. * The possible values are :
  80663. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80664. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80665. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80666. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80667. * Please read each static variable documentation to get details about the culling process.
  80668. * */
  80669. cullingStrategy: number;
  80670. /**
  80671. * Gets the number of facets in the mesh
  80672. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80673. */
  80674. readonly facetNb: number;
  80675. /**
  80676. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80677. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80678. */
  80679. partitioningSubdivisions: number;
  80680. /**
  80681. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80682. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80684. */
  80685. partitioningBBoxRatio: number;
  80686. /**
  80687. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80688. * Works only for updatable meshes.
  80689. * Doesn't work with multi-materials
  80690. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80691. */
  80692. mustDepthSortFacets: boolean;
  80693. /**
  80694. * The location (Vector3) where the facet depth sort must be computed from.
  80695. * By default, the active camera position.
  80696. * Used only when facet depth sort is enabled
  80697. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80698. */
  80699. facetDepthSortFrom: Vector3;
  80700. /**
  80701. * gets a boolean indicating if facetData is enabled
  80702. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80703. */
  80704. readonly isFacetDataEnabled: boolean;
  80705. /** @hidden */
  80706. _updateNonUniformScalingState(value: boolean): boolean;
  80707. /**
  80708. * An event triggered when this mesh collides with another one
  80709. */
  80710. onCollideObservable: Observable<AbstractMesh>;
  80711. private _onCollideObserver;
  80712. /** Set a function to call when this mesh collides with another one */
  80713. onCollide: () => void;
  80714. /**
  80715. * An event triggered when the collision's position changes
  80716. */
  80717. onCollisionPositionChangeObservable: Observable<Vector3>;
  80718. private _onCollisionPositionChangeObserver;
  80719. /** Set a function to call when the collision's position changes */
  80720. onCollisionPositionChange: () => void;
  80721. /**
  80722. * An event triggered when material is changed
  80723. */
  80724. onMaterialChangedObservable: Observable<AbstractMesh>;
  80725. /**
  80726. * Gets or sets the orientation for POV movement & rotation
  80727. */
  80728. definedFacingForward: boolean;
  80729. /** @hidden */
  80730. _occlusionQuery: Nullable<WebGLQuery>;
  80731. private _visibility;
  80732. /**
  80733. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80734. */
  80735. /**
  80736. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80737. */
  80738. visibility: number;
  80739. /** Gets or sets the alpha index used to sort transparent meshes
  80740. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  80741. */
  80742. alphaIndex: number;
  80743. /**
  80744. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  80745. */
  80746. isVisible: boolean;
  80747. /**
  80748. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80749. */
  80750. isPickable: boolean;
  80751. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  80752. showSubMeshesBoundingBox: boolean;
  80753. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  80754. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  80755. */
  80756. isBlocker: boolean;
  80757. /**
  80758. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  80759. */
  80760. enablePointerMoveEvents: boolean;
  80761. /**
  80762. * Specifies the rendering group id for this mesh (0 by default)
  80763. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80764. */
  80765. renderingGroupId: number;
  80766. private _material;
  80767. /** Gets or sets current material */
  80768. material: Nullable<Material>;
  80769. private _receiveShadows;
  80770. /**
  80771. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  80772. * @see http://doc.babylonjs.com/babylon101/shadows
  80773. */
  80774. receiveShadows: boolean;
  80775. /** Defines color to use when rendering outline */
  80776. outlineColor: Color3;
  80777. /** Define width to use when rendering outline */
  80778. outlineWidth: number;
  80779. /** Defines color to use when rendering overlay */
  80780. overlayColor: Color3;
  80781. /** Defines alpha to use when rendering overlay */
  80782. overlayAlpha: number;
  80783. private _hasVertexAlpha;
  80784. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  80785. hasVertexAlpha: boolean;
  80786. private _useVertexColors;
  80787. /** 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) */
  80788. useVertexColors: boolean;
  80789. private _computeBonesUsingShaders;
  80790. /**
  80791. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  80792. */
  80793. computeBonesUsingShaders: boolean;
  80794. private _numBoneInfluencers;
  80795. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  80796. numBoneInfluencers: number;
  80797. private _applyFog;
  80798. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  80799. applyFog: boolean;
  80800. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  80801. useOctreeForRenderingSelection: boolean;
  80802. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  80803. useOctreeForPicking: boolean;
  80804. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  80805. useOctreeForCollisions: boolean;
  80806. private _layerMask;
  80807. /**
  80808. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  80809. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  80810. */
  80811. layerMask: number;
  80812. /**
  80813. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  80814. */
  80815. alwaysSelectAsActiveMesh: boolean;
  80816. /**
  80817. * Gets or sets the current action manager
  80818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80819. */
  80820. actionManager: Nullable<AbstractActionManager>;
  80821. private _checkCollisions;
  80822. private _collisionMask;
  80823. private _collisionGroup;
  80824. /**
  80825. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  80826. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80827. */
  80828. ellipsoid: Vector3;
  80829. /**
  80830. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  80831. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80832. */
  80833. ellipsoidOffset: Vector3;
  80834. private _collider;
  80835. private _oldPositionForCollisions;
  80836. private _diffPositionForCollisions;
  80837. /**
  80838. * Gets or sets a collision mask used to mask collisions (default is -1).
  80839. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80840. */
  80841. collisionMask: number;
  80842. /**
  80843. * Gets or sets the current collision group mask (-1 by default).
  80844. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80845. */
  80846. collisionGroup: number;
  80847. /**
  80848. * Defines edge width used when edgesRenderer is enabled
  80849. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80850. */
  80851. edgesWidth: number;
  80852. /**
  80853. * Defines edge color used when edgesRenderer is enabled
  80854. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80855. */
  80856. edgesColor: Color4;
  80857. /** @hidden */
  80858. _edgesRenderer: Nullable<IEdgesRenderer>;
  80859. /** @hidden */
  80860. _masterMesh: Nullable<AbstractMesh>;
  80861. /** @hidden */
  80862. _boundingInfo: Nullable<BoundingInfo>;
  80863. /** @hidden */
  80864. _renderId: number;
  80865. /**
  80866. * Gets or sets the list of subMeshes
  80867. * @see http://doc.babylonjs.com/how_to/multi_materials
  80868. */
  80869. subMeshes: SubMesh[];
  80870. /** @hidden */
  80871. _intersectionsInProgress: AbstractMesh[];
  80872. /** @hidden */
  80873. _unIndexed: boolean;
  80874. /** @hidden */
  80875. _lightSources: Light[];
  80876. /** @hidden */
  80877. readonly _positions: Nullable<Vector3[]>;
  80878. /** @hidden */
  80879. _waitingActions: any;
  80880. /** @hidden */
  80881. _waitingFreezeWorldMatrix: Nullable<boolean>;
  80882. private _skeleton;
  80883. /** @hidden */
  80884. _bonesTransformMatrices: Nullable<Float32Array>;
  80885. /**
  80886. * Gets or sets a skeleton to apply skining transformations
  80887. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80888. */
  80889. skeleton: Nullable<Skeleton>;
  80890. /**
  80891. * An event triggered when the mesh is rebuilt.
  80892. */
  80893. onRebuildObservable: Observable<AbstractMesh>;
  80894. /**
  80895. * Creates a new AbstractMesh
  80896. * @param name defines the name of the mesh
  80897. * @param scene defines the hosting scene
  80898. */
  80899. constructor(name: string, scene?: Nullable<Scene>);
  80900. /**
  80901. * Returns the string "AbstractMesh"
  80902. * @returns "AbstractMesh"
  80903. */
  80904. getClassName(): string;
  80905. /**
  80906. * Gets a string representation of the current mesh
  80907. * @param fullDetails defines a boolean indicating if full details must be included
  80908. * @returns a string representation of the current mesh
  80909. */
  80910. toString(fullDetails?: boolean): string;
  80911. /** @hidden */
  80912. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  80913. /** @hidden */
  80914. _rebuild(): void;
  80915. /** @hidden */
  80916. _resyncLightSources(): void;
  80917. /** @hidden */
  80918. _resyncLighSource(light: Light): void;
  80919. /** @hidden */
  80920. _unBindEffect(): void;
  80921. /** @hidden */
  80922. _removeLightSource(light: Light): void;
  80923. private _markSubMeshesAsDirty;
  80924. /** @hidden */
  80925. _markSubMeshesAsLightDirty(): void;
  80926. /** @hidden */
  80927. _markSubMeshesAsAttributesDirty(): void;
  80928. /** @hidden */
  80929. _markSubMeshesAsMiscDirty(): void;
  80930. /**
  80931. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  80932. */
  80933. scaling: Vector3;
  80934. /**
  80935. * Returns true if the mesh is blocked. Implemented by child classes
  80936. */
  80937. readonly isBlocked: boolean;
  80938. /**
  80939. * Returns the mesh itself by default. Implemented by child classes
  80940. * @param camera defines the camera to use to pick the right LOD level
  80941. * @returns the currentAbstractMesh
  80942. */
  80943. getLOD(camera: Camera): Nullable<AbstractMesh>;
  80944. /**
  80945. * Returns 0 by default. Implemented by child classes
  80946. * @returns an integer
  80947. */
  80948. getTotalVertices(): number;
  80949. /**
  80950. * Returns a positive integer : the total number of indices in this mesh geometry.
  80951. * @returns the numner of indices or zero if the mesh has no geometry.
  80952. */
  80953. getTotalIndices(): number;
  80954. /**
  80955. * Returns null by default. Implemented by child classes
  80956. * @returns null
  80957. */
  80958. getIndices(): Nullable<IndicesArray>;
  80959. /**
  80960. * Returns the array of the requested vertex data kind. Implemented by child classes
  80961. * @param kind defines the vertex data kind to use
  80962. * @returns null
  80963. */
  80964. getVerticesData(kind: string): Nullable<FloatArray>;
  80965. /**
  80966. * Sets the vertex data of the mesh geometry for the requested `kind`.
  80967. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  80968. * Note that a new underlying VertexBuffer object is created each call.
  80969. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  80970. * @param kind defines vertex data kind:
  80971. * * VertexBuffer.PositionKind
  80972. * * VertexBuffer.UVKind
  80973. * * VertexBuffer.UV2Kind
  80974. * * VertexBuffer.UV3Kind
  80975. * * VertexBuffer.UV4Kind
  80976. * * VertexBuffer.UV5Kind
  80977. * * VertexBuffer.UV6Kind
  80978. * * VertexBuffer.ColorKind
  80979. * * VertexBuffer.MatricesIndicesKind
  80980. * * VertexBuffer.MatricesIndicesExtraKind
  80981. * * VertexBuffer.MatricesWeightsKind
  80982. * * VertexBuffer.MatricesWeightsExtraKind
  80983. * @param data defines the data source
  80984. * @param updatable defines if the data must be flagged as updatable (or static)
  80985. * @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
  80986. * @returns the current mesh
  80987. */
  80988. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  80989. /**
  80990. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  80991. * If the mesh has no geometry, it is simply returned as it is.
  80992. * @param kind defines vertex data kind:
  80993. * * VertexBuffer.PositionKind
  80994. * * VertexBuffer.UVKind
  80995. * * VertexBuffer.UV2Kind
  80996. * * VertexBuffer.UV3Kind
  80997. * * VertexBuffer.UV4Kind
  80998. * * VertexBuffer.UV5Kind
  80999. * * VertexBuffer.UV6Kind
  81000. * * VertexBuffer.ColorKind
  81001. * * VertexBuffer.MatricesIndicesKind
  81002. * * VertexBuffer.MatricesIndicesExtraKind
  81003. * * VertexBuffer.MatricesWeightsKind
  81004. * * VertexBuffer.MatricesWeightsExtraKind
  81005. * @param data defines the data source
  81006. * @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
  81007. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81008. * @returns the current mesh
  81009. */
  81010. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  81011. /**
  81012. * Sets the mesh indices,
  81013. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81014. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81015. * @param totalVertices Defines the total number of vertices
  81016. * @returns the current mesh
  81017. */
  81018. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  81019. /**
  81020. * Gets a boolean indicating if specific vertex data is present
  81021. * @param kind defines the vertex data kind to use
  81022. * @returns true is data kind is present
  81023. */
  81024. isVerticesDataPresent(kind: string): boolean;
  81025. /**
  81026. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81027. * @returns a BoundingInfo
  81028. */
  81029. getBoundingInfo(): BoundingInfo;
  81030. /**
  81031. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81032. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81033. * @returns the current mesh
  81034. */
  81035. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  81036. /**
  81037. * Overwrite the current bounding info
  81038. * @param boundingInfo defines the new bounding info
  81039. * @returns the current mesh
  81040. */
  81041. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  81042. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81043. readonly useBones: boolean;
  81044. /** @hidden */
  81045. _preActivate(): void;
  81046. /** @hidden */
  81047. _preActivateForIntermediateRendering(renderId: number): void;
  81048. /** @hidden */
  81049. _activate(renderId: number): void;
  81050. /**
  81051. * Gets the current world matrix
  81052. * @returns a Matrix
  81053. */
  81054. getWorldMatrix(): Matrix;
  81055. /** @hidden */
  81056. _getWorldMatrixDeterminant(): number;
  81057. /**
  81058. * Perform relative position change from the point of view of behind the front of the mesh.
  81059. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81060. * Supports definition of mesh facing forward or backward
  81061. * @param amountRight defines the distance on the right axis
  81062. * @param amountUp defines the distance on the up axis
  81063. * @param amountForward defines the distance on the forward axis
  81064. * @returns the current mesh
  81065. */
  81066. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81067. /**
  81068. * Calculate relative position change from the point of view of behind the front of the mesh.
  81069. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81070. * Supports definition of mesh facing forward or backward
  81071. * @param amountRight defines the distance on the right axis
  81072. * @param amountUp defines the distance on the up axis
  81073. * @param amountForward defines the distance on the forward axis
  81074. * @returns the new displacement vector
  81075. */
  81076. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81077. /**
  81078. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81079. * Supports definition of mesh facing forward or backward
  81080. * @param flipBack defines the flip
  81081. * @param twirlClockwise defines the twirl
  81082. * @param tiltRight defines the tilt
  81083. * @returns the current mesh
  81084. */
  81085. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81086. /**
  81087. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81088. * Supports definition of mesh facing forward or backward.
  81089. * @param flipBack defines the flip
  81090. * @param twirlClockwise defines the twirl
  81091. * @param tiltRight defines the tilt
  81092. * @returns the new rotation vector
  81093. */
  81094. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81095. /**
  81096. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81097. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81098. * @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
  81099. * @returns the new bounding vectors
  81100. */
  81101. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81102. min: Vector3;
  81103. max: Vector3;
  81104. };
  81105. /**
  81106. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81107. * This means the mesh underlying bounding box and sphere are recomputed.
  81108. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81109. * @returns the current mesh
  81110. */
  81111. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81112. /** @hidden */
  81113. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81114. /** @hidden */
  81115. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81116. /** @hidden */
  81117. _updateBoundingInfo(): AbstractMesh;
  81118. /** @hidden */
  81119. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81120. /** @hidden */
  81121. protected _afterComputeWorldMatrix(): void;
  81122. /**
  81123. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81124. * A mesh is in the frustum if its bounding box intersects the frustum
  81125. * @param frustumPlanes defines the frustum to test
  81126. * @returns true if the mesh is in the frustum planes
  81127. */
  81128. isInFrustum(frustumPlanes: Plane[]): boolean;
  81129. /**
  81130. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81131. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81132. * @param frustumPlanes defines the frustum to test
  81133. * @returns true if the mesh is completely in the frustum planes
  81134. */
  81135. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81136. /**
  81137. * True if the mesh intersects another mesh or a SolidParticle object
  81138. * @param mesh defines a target mesh or SolidParticle to test
  81139. * @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)
  81140. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81141. * @returns true if there is an intersection
  81142. */
  81143. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81144. /**
  81145. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81146. * @param point defines the point to test
  81147. * @returns true if there is an intersection
  81148. */
  81149. intersectsPoint(point: Vector3): boolean;
  81150. /**
  81151. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81153. */
  81154. checkCollisions: boolean;
  81155. /**
  81156. * Gets Collider object used to compute collisions (not physics)
  81157. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81158. */
  81159. readonly collider: Collider;
  81160. /**
  81161. * Move the mesh using collision engine
  81162. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81163. * @param displacement defines the requested displacement vector
  81164. * @returns the current mesh
  81165. */
  81166. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81167. private _onCollisionPositionChange;
  81168. /** @hidden */
  81169. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81170. /** @hidden */
  81171. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81172. /** @hidden */
  81173. _checkCollision(collider: Collider): AbstractMesh;
  81174. /** @hidden */
  81175. _generatePointsArray(): boolean;
  81176. /**
  81177. * Checks if the passed Ray intersects with the mesh
  81178. * @param ray defines the ray to use
  81179. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81180. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81181. * @returns the picking info
  81182. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81183. */
  81184. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  81185. /**
  81186. * Clones the current mesh
  81187. * @param name defines the mesh name
  81188. * @param newParent defines the new mesh parent
  81189. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81190. * @returns the new mesh
  81191. */
  81192. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81193. /**
  81194. * Disposes all the submeshes of the current meshnp
  81195. * @returns the current mesh
  81196. */
  81197. releaseSubMeshes(): AbstractMesh;
  81198. /**
  81199. * Releases resources associated with this abstract mesh.
  81200. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81201. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81202. */
  81203. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81204. /**
  81205. * Adds the passed mesh as a child to the current mesh
  81206. * @param mesh defines the child mesh
  81207. * @returns the current mesh
  81208. */
  81209. addChild(mesh: AbstractMesh): AbstractMesh;
  81210. /**
  81211. * Removes the passed mesh from the current mesh children list
  81212. * @param mesh defines the child mesh
  81213. * @returns the current mesh
  81214. */
  81215. removeChild(mesh: AbstractMesh): AbstractMesh;
  81216. /** @hidden */
  81217. private _initFacetData;
  81218. /**
  81219. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81220. * This method can be called within the render loop.
  81221. * 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
  81222. * @returns the current mesh
  81223. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81224. */
  81225. updateFacetData(): AbstractMesh;
  81226. /**
  81227. * Returns the facetLocalNormals array.
  81228. * The normals are expressed in the mesh local spac
  81229. * @returns an array of Vector3
  81230. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81231. */
  81232. getFacetLocalNormals(): Vector3[];
  81233. /**
  81234. * Returns the facetLocalPositions array.
  81235. * The facet positions are expressed in the mesh local space
  81236. * @returns an array of Vector3
  81237. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81238. */
  81239. getFacetLocalPositions(): Vector3[];
  81240. /**
  81241. * Returns the facetLocalPartioning array
  81242. * @returns an array of array of numbers
  81243. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81244. */
  81245. getFacetLocalPartitioning(): number[][];
  81246. /**
  81247. * Returns the i-th facet position in the world system.
  81248. * This method allocates a new Vector3 per call
  81249. * @param i defines the facet index
  81250. * @returns a new Vector3
  81251. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81252. */
  81253. getFacetPosition(i: number): Vector3;
  81254. /**
  81255. * Sets the reference Vector3 with the i-th facet position in the world system
  81256. * @param i defines the facet index
  81257. * @param ref defines the target vector
  81258. * @returns the current mesh
  81259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81260. */
  81261. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81262. /**
  81263. * Returns the i-th facet normal in the world system.
  81264. * This method allocates a new Vector3 per call
  81265. * @param i defines the facet index
  81266. * @returns a new Vector3
  81267. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81268. */
  81269. getFacetNormal(i: number): Vector3;
  81270. /**
  81271. * Sets the reference Vector3 with the i-th facet normal in the world system
  81272. * @param i defines the facet index
  81273. * @param ref defines the target vector
  81274. * @returns the current mesh
  81275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81276. */
  81277. getFacetNormalToRef(i: number, ref: Vector3): this;
  81278. /**
  81279. * 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)
  81280. * @param x defines x coordinate
  81281. * @param y defines y coordinate
  81282. * @param z defines z coordinate
  81283. * @returns the array of facet indexes
  81284. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81285. */
  81286. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81287. /**
  81288. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81289. * @param projected sets as the (x,y,z) world projection on the facet
  81290. * @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
  81291. * @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
  81292. * @param x defines x coordinate
  81293. * @param y defines y coordinate
  81294. * @param z defines z coordinate
  81295. * @returns the face index if found (or null instead)
  81296. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81297. */
  81298. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81299. /**
  81300. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81301. * @param projected sets as the (x,y,z) local projection on the facet
  81302. * @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
  81303. * @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
  81304. * @param x defines x coordinate
  81305. * @param y defines y coordinate
  81306. * @param z defines z coordinate
  81307. * @returns the face index if found (or null instead)
  81308. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81309. */
  81310. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81311. /**
  81312. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81313. * @returns the parameters
  81314. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81315. */
  81316. getFacetDataParameters(): any;
  81317. /**
  81318. * Disables the feature FacetData and frees the related memory
  81319. * @returns the current mesh
  81320. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81321. */
  81322. disableFacetData(): AbstractMesh;
  81323. /**
  81324. * Updates the AbstractMesh indices array
  81325. * @param indices defines the data source
  81326. * @returns the current mesh
  81327. */
  81328. updateIndices(indices: IndicesArray): AbstractMesh;
  81329. /**
  81330. * Creates new normals data for the mesh
  81331. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81332. * @returns the current mesh
  81333. */
  81334. createNormals(updatable: boolean): AbstractMesh;
  81335. /**
  81336. * Align the mesh with a normal
  81337. * @param normal defines the normal to use
  81338. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81339. * @returns the current mesh
  81340. */
  81341. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81342. /** @hidden */
  81343. _checkOcclusionQuery(): boolean;
  81344. }
  81345. }
  81346. declare module BABYLON {
  81347. /**
  81348. * Interface used to define ActionEvent
  81349. */
  81350. export interface IActionEvent {
  81351. /** The mesh or sprite that triggered the action */
  81352. source: any;
  81353. /** The X mouse cursor position at the time of the event */
  81354. pointerX: number;
  81355. /** The Y mouse cursor position at the time of the event */
  81356. pointerY: number;
  81357. /** The mesh that is currently pointed at (can be null) */
  81358. meshUnderPointer: Nullable<AbstractMesh>;
  81359. /** the original (browser) event that triggered the ActionEvent */
  81360. sourceEvent?: any;
  81361. /** additional data for the event */
  81362. additionalData?: any;
  81363. }
  81364. /**
  81365. * ActionEvent is the event being sent when an action is triggered.
  81366. */
  81367. export class ActionEvent implements IActionEvent {
  81368. /** The mesh or sprite that triggered the action */
  81369. source: any;
  81370. /** The X mouse cursor position at the time of the event */
  81371. pointerX: number;
  81372. /** The Y mouse cursor position at the time of the event */
  81373. pointerY: number;
  81374. /** The mesh that is currently pointed at (can be null) */
  81375. meshUnderPointer: Nullable<AbstractMesh>;
  81376. /** the original (browser) event that triggered the ActionEvent */
  81377. sourceEvent?: any;
  81378. /** additional data for the event */
  81379. additionalData?: any;
  81380. /**
  81381. * Creates a new ActionEvent
  81382. * @param source The mesh or sprite that triggered the action
  81383. * @param pointerX The X mouse cursor position at the time of the event
  81384. * @param pointerY The Y mouse cursor position at the time of the event
  81385. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  81386. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  81387. * @param additionalData additional data for the event
  81388. */
  81389. constructor(
  81390. /** The mesh or sprite that triggered the action */
  81391. source: any,
  81392. /** The X mouse cursor position at the time of the event */
  81393. pointerX: number,
  81394. /** The Y mouse cursor position at the time of the event */
  81395. pointerY: number,
  81396. /** The mesh that is currently pointed at (can be null) */
  81397. meshUnderPointer: Nullable<AbstractMesh>,
  81398. /** the original (browser) event that triggered the ActionEvent */
  81399. sourceEvent?: any,
  81400. /** additional data for the event */
  81401. additionalData?: any);
  81402. /**
  81403. * Helper function to auto-create an ActionEvent from a source mesh.
  81404. * @param source The source mesh that triggered the event
  81405. * @param evt The original (browser) event
  81406. * @param additionalData additional data for the event
  81407. * @returns the new ActionEvent
  81408. */
  81409. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  81410. /**
  81411. * Helper function to auto-create an ActionEvent from a source sprite
  81412. * @param source The source sprite that triggered the event
  81413. * @param scene Scene associated with the sprite
  81414. * @param evt The original (browser) event
  81415. * @param additionalData additional data for the event
  81416. * @returns the new ActionEvent
  81417. */
  81418. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  81419. /**
  81420. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  81421. * @param scene the scene where the event occurred
  81422. * @param evt The original (browser) event
  81423. * @returns the new ActionEvent
  81424. */
  81425. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  81426. /**
  81427. * Helper function to auto-create an ActionEvent from a primitive
  81428. * @param prim defines the target primitive
  81429. * @param pointerPos defines the pointer position
  81430. * @param evt The original (browser) event
  81431. * @param additionalData additional data for the event
  81432. * @returns the new ActionEvent
  81433. */
  81434. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  81435. }
  81436. }
  81437. declare module BABYLON {
  81438. /**
  81439. * Abstract class used to decouple action Manager from scene and meshes.
  81440. * Do not instantiate.
  81441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81442. */
  81443. export abstract class AbstractActionManager implements IDisposable {
  81444. /** Gets the list of active triggers */
  81445. static Triggers: {
  81446. [key: string]: number;
  81447. };
  81448. /** Gets the cursor to use when hovering items */
  81449. hoverCursor: string;
  81450. /** Gets the list of actions */
  81451. actions: IAction[];
  81452. /**
  81453. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  81454. */
  81455. isRecursive: boolean;
  81456. /**
  81457. * Releases all associated resources
  81458. */
  81459. abstract dispose(): void;
  81460. /**
  81461. * Does this action manager has pointer triggers
  81462. */
  81463. abstract readonly hasPointerTriggers: boolean;
  81464. /**
  81465. * Does this action manager has pick triggers
  81466. */
  81467. abstract readonly hasPickTriggers: boolean;
  81468. /**
  81469. * Process a specific trigger
  81470. * @param trigger defines the trigger to process
  81471. * @param evt defines the event details to be processed
  81472. */
  81473. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  81474. /**
  81475. * Does this action manager handles actions of any of the given triggers
  81476. * @param triggers defines the triggers to be tested
  81477. * @return a boolean indicating whether one (or more) of the triggers is handled
  81478. */
  81479. abstract hasSpecificTriggers(triggers: number[]): boolean;
  81480. /**
  81481. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81482. * speed.
  81483. * @param triggerA defines the trigger to be tested
  81484. * @param triggerB defines the trigger to be tested
  81485. * @return a boolean indicating whether one (or more) of the triggers is handled
  81486. */
  81487. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81488. /**
  81489. * Does this action manager handles actions of a given trigger
  81490. * @param trigger defines the trigger to be tested
  81491. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81492. * @return whether the trigger is handled
  81493. */
  81494. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81495. /**
  81496. * Serialize this manager to a JSON object
  81497. * @param name defines the property name to store this manager
  81498. * @returns a JSON representation of this manager
  81499. */
  81500. abstract serialize(name: string): any;
  81501. /**
  81502. * Does exist one action manager with at least one trigger
  81503. **/
  81504. static readonly HasTriggers: boolean;
  81505. /**
  81506. * Does exist one action manager with at least one pick trigger
  81507. **/
  81508. static readonly HasPickTriggers: boolean;
  81509. /**
  81510. * Does exist one action manager that handles actions of a given trigger
  81511. * @param trigger defines the trigger to be tested
  81512. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  81513. **/
  81514. static HasSpecificTrigger(trigger: number): boolean;
  81515. }
  81516. }
  81517. declare module BABYLON {
  81518. /**
  81519. * Defines how a node can be built from a string name.
  81520. */
  81521. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  81522. /**
  81523. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  81524. */
  81525. export class Node implements IBehaviorAware<Node> {
  81526. /** @hidden */
  81527. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  81528. private static _NodeConstructors;
  81529. /**
  81530. * Add a new node constructor
  81531. * @param type defines the type name of the node to construct
  81532. * @param constructorFunc defines the constructor function
  81533. */
  81534. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  81535. /**
  81536. * Returns a node constructor based on type name
  81537. * @param type defines the type name
  81538. * @param name defines the new node name
  81539. * @param scene defines the hosting scene
  81540. * @param options defines optional options to transmit to constructors
  81541. * @returns the new constructor or null
  81542. */
  81543. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  81544. /**
  81545. * Gets or sets the name of the node
  81546. */
  81547. name: string;
  81548. /**
  81549. * Gets or sets the id of the node
  81550. */
  81551. id: string;
  81552. /**
  81553. * Gets or sets the unique id of the node
  81554. */
  81555. uniqueId: number;
  81556. /**
  81557. * Gets or sets a string used to store user defined state for the node
  81558. */
  81559. state: string;
  81560. /**
  81561. * Gets or sets an object used to store user defined information for the node
  81562. */
  81563. metadata: any;
  81564. /**
  81565. * For internal use only. Please do not use.
  81566. */
  81567. reservedDataStore: any;
  81568. /**
  81569. * Gets or sets a boolean used to define if the node must be serialized
  81570. */
  81571. doNotSerialize: boolean;
  81572. /** @hidden */
  81573. _isDisposed: boolean;
  81574. /**
  81575. * Gets a list of Animations associated with the node
  81576. */
  81577. animations: Animation[];
  81578. protected _ranges: {
  81579. [name: string]: Nullable<AnimationRange>;
  81580. };
  81581. /**
  81582. * Callback raised when the node is ready to be used
  81583. */
  81584. onReady: (node: Node) => void;
  81585. private _isEnabled;
  81586. private _isParentEnabled;
  81587. private _isReady;
  81588. /** @hidden */
  81589. _currentRenderId: number;
  81590. private _parentRenderId;
  81591. protected _childRenderId: number;
  81592. /** @hidden */
  81593. _waitingParentId: Nullable<string>;
  81594. /** @hidden */
  81595. _scene: Scene;
  81596. /** @hidden */
  81597. _cache: any;
  81598. private _parentNode;
  81599. private _children;
  81600. /** @hidden */
  81601. _worldMatrix: Matrix;
  81602. /** @hidden */
  81603. _worldMatrixDeterminant: number;
  81604. /** @hidden */
  81605. private _sceneRootNodesIndex;
  81606. /**
  81607. * Gets a boolean indicating if the node has been disposed
  81608. * @returns true if the node was disposed
  81609. */
  81610. isDisposed(): boolean;
  81611. /**
  81612. * Gets or sets the parent of the node
  81613. */
  81614. parent: Nullable<Node>;
  81615. private addToSceneRootNodes;
  81616. private removeFromSceneRootNodes;
  81617. private _animationPropertiesOverride;
  81618. /**
  81619. * Gets or sets the animation properties override
  81620. */
  81621. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81622. /**
  81623. * Gets a string idenfifying the name of the class
  81624. * @returns "Node" string
  81625. */
  81626. getClassName(): string;
  81627. /** @hidden */
  81628. readonly _isNode: boolean;
  81629. /**
  81630. * An event triggered when the mesh is disposed
  81631. */
  81632. onDisposeObservable: Observable<Node>;
  81633. private _onDisposeObserver;
  81634. /**
  81635. * Sets a callback that will be raised when the node will be disposed
  81636. */
  81637. onDispose: () => void;
  81638. /**
  81639. * Creates a new Node
  81640. * @param name the name and id to be given to this node
  81641. * @param scene the scene this node will be added to
  81642. * @param addToRootNodes the node will be added to scene.rootNodes
  81643. */
  81644. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  81645. /**
  81646. * Gets the scene of the node
  81647. * @returns a scene
  81648. */
  81649. getScene(): Scene;
  81650. /**
  81651. * Gets the engine of the node
  81652. * @returns a Engine
  81653. */
  81654. getEngine(): Engine;
  81655. private _behaviors;
  81656. /**
  81657. * Attach a behavior to the node
  81658. * @see http://doc.babylonjs.com/features/behaviour
  81659. * @param behavior defines the behavior to attach
  81660. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  81661. * @returns the current Node
  81662. */
  81663. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  81664. /**
  81665. * Remove an attached behavior
  81666. * @see http://doc.babylonjs.com/features/behaviour
  81667. * @param behavior defines the behavior to attach
  81668. * @returns the current Node
  81669. */
  81670. removeBehavior(behavior: Behavior<Node>): Node;
  81671. /**
  81672. * Gets the list of attached behaviors
  81673. * @see http://doc.babylonjs.com/features/behaviour
  81674. */
  81675. readonly behaviors: Behavior<Node>[];
  81676. /**
  81677. * Gets an attached behavior by name
  81678. * @param name defines the name of the behavior to look for
  81679. * @see http://doc.babylonjs.com/features/behaviour
  81680. * @returns null if behavior was not found else the requested behavior
  81681. */
  81682. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  81683. /**
  81684. * Returns the latest update of the World matrix
  81685. * @returns a Matrix
  81686. */
  81687. getWorldMatrix(): Matrix;
  81688. /** @hidden */
  81689. _getWorldMatrixDeterminant(): number;
  81690. /**
  81691. * Returns directly the latest state of the mesh World matrix.
  81692. * A Matrix is returned.
  81693. */
  81694. readonly worldMatrixFromCache: Matrix;
  81695. /** @hidden */
  81696. _initCache(): void;
  81697. /** @hidden */
  81698. updateCache(force?: boolean): void;
  81699. /** @hidden */
  81700. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81701. /** @hidden */
  81702. _updateCache(ignoreParentClass?: boolean): void;
  81703. /** @hidden */
  81704. _isSynchronized(): boolean;
  81705. /** @hidden */
  81706. _markSyncedWithParent(): void;
  81707. /** @hidden */
  81708. isSynchronizedWithParent(): boolean;
  81709. /** @hidden */
  81710. isSynchronized(): boolean;
  81711. /**
  81712. * Is this node ready to be used/rendered
  81713. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81714. * @return true if the node is ready
  81715. */
  81716. isReady(completeCheck?: boolean): boolean;
  81717. /**
  81718. * Is this node enabled?
  81719. * 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
  81720. * @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
  81721. * @return whether this node (and its parent) is enabled
  81722. */
  81723. isEnabled(checkAncestors?: boolean): boolean;
  81724. /** @hidden */
  81725. protected _syncParentEnabledState(): void;
  81726. /**
  81727. * Set the enabled state of this node
  81728. * @param value defines the new enabled state
  81729. */
  81730. setEnabled(value: boolean): void;
  81731. /**
  81732. * Is this node a descendant of the given node?
  81733. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  81734. * @param ancestor defines the parent node to inspect
  81735. * @returns a boolean indicating if this node is a descendant of the given node
  81736. */
  81737. isDescendantOf(ancestor: Node): boolean;
  81738. /** @hidden */
  81739. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  81740. /**
  81741. * Will return all nodes that have this node as ascendant
  81742. * @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
  81743. * @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
  81744. * @return all children nodes of all types
  81745. */
  81746. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  81747. /**
  81748. * Get all child-meshes of this node
  81749. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  81750. * @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
  81751. * @returns an array of AbstractMesh
  81752. */
  81753. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  81754. /**
  81755. * Get all direct children of this node
  81756. * @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
  81757. * @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)
  81758. * @returns an array of Node
  81759. */
  81760. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  81761. /** @hidden */
  81762. _setReady(state: boolean): void;
  81763. /**
  81764. * Get an animation by name
  81765. * @param name defines the name of the animation to look for
  81766. * @returns null if not found else the requested animation
  81767. */
  81768. getAnimationByName(name: string): Nullable<Animation>;
  81769. /**
  81770. * Creates an animation range for this node
  81771. * @param name defines the name of the range
  81772. * @param from defines the starting key
  81773. * @param to defines the end key
  81774. */
  81775. createAnimationRange(name: string, from: number, to: number): void;
  81776. /**
  81777. * Delete a specific animation range
  81778. * @param name defines the name of the range to delete
  81779. * @param deleteFrames defines if animation frames from the range must be deleted as well
  81780. */
  81781. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81782. /**
  81783. * Get an animation range by name
  81784. * @param name defines the name of the animation range to look for
  81785. * @returns null if not found else the requested animation range
  81786. */
  81787. getAnimationRange(name: string): Nullable<AnimationRange>;
  81788. /**
  81789. * Gets the list of all animation ranges defined on this node
  81790. * @returns an array
  81791. */
  81792. getAnimationRanges(): Nullable<AnimationRange>[];
  81793. /**
  81794. * Will start the animation sequence
  81795. * @param name defines the range frames for animation sequence
  81796. * @param loop defines if the animation should loop (false by default)
  81797. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  81798. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  81799. * @returns the object created for this animation. If range does not exist, it will return null
  81800. */
  81801. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81802. /**
  81803. * Serialize animation ranges into a JSON compatible object
  81804. * @returns serialization object
  81805. */
  81806. serializeAnimationRanges(): any;
  81807. /**
  81808. * Computes the world matrix of the node
  81809. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81810. * @returns the world matrix
  81811. */
  81812. computeWorldMatrix(force?: boolean): Matrix;
  81813. /**
  81814. * Releases resources associated with this node.
  81815. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81816. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81817. */
  81818. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81819. /**
  81820. * Parse animation range data from a serialization object and store them into a given node
  81821. * @param node defines where to store the animation ranges
  81822. * @param parsedNode defines the serialization object to read data from
  81823. * @param scene defines the hosting scene
  81824. */
  81825. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  81826. }
  81827. }
  81828. declare module BABYLON {
  81829. /**
  81830. * Class used to store any kind of animation
  81831. */
  81832. export class Animation {
  81833. /**Name of the animation */
  81834. name: string;
  81835. /**Property to animate */
  81836. targetProperty: string;
  81837. /**The frames per second of the animation */
  81838. framePerSecond: number;
  81839. /**The data type of the animation */
  81840. dataType: number;
  81841. /**The loop mode of the animation */
  81842. loopMode?: number | undefined;
  81843. /**Specifies if blending should be enabled */
  81844. enableBlending?: boolean | undefined;
  81845. /**
  81846. * Use matrix interpolation instead of using direct key value when animating matrices
  81847. */
  81848. static AllowMatricesInterpolation: boolean;
  81849. /**
  81850. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  81851. */
  81852. static AllowMatrixDecomposeForInterpolation: boolean;
  81853. /**
  81854. * Stores the key frames of the animation
  81855. */
  81856. private _keys;
  81857. /**
  81858. * Stores the easing function of the animation
  81859. */
  81860. private _easingFunction;
  81861. /**
  81862. * @hidden Internal use only
  81863. */
  81864. _runtimeAnimations: RuntimeAnimation[];
  81865. /**
  81866. * The set of event that will be linked to this animation
  81867. */
  81868. private _events;
  81869. /**
  81870. * Stores an array of target property paths
  81871. */
  81872. targetPropertyPath: string[];
  81873. /**
  81874. * Stores the blending speed of the animation
  81875. */
  81876. blendingSpeed: number;
  81877. /**
  81878. * Stores the animation ranges for the animation
  81879. */
  81880. private _ranges;
  81881. /**
  81882. * @hidden Internal use
  81883. */
  81884. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  81885. /**
  81886. * Sets up an animation
  81887. * @param property The property to animate
  81888. * @param animationType The animation type to apply
  81889. * @param framePerSecond The frames per second of the animation
  81890. * @param easingFunction The easing function used in the animation
  81891. * @returns The created animation
  81892. */
  81893. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  81894. /**
  81895. * Create and start an animation on a node
  81896. * @param name defines the name of the global animation that will be run on all nodes
  81897. * @param node defines the root node where the animation will take place
  81898. * @param targetProperty defines property to animate
  81899. * @param framePerSecond defines the number of frame per second yo use
  81900. * @param totalFrame defines the number of frames in total
  81901. * @param from defines the initial value
  81902. * @param to defines the final value
  81903. * @param loopMode defines which loop mode you want to use (off by default)
  81904. * @param easingFunction defines the easing function to use (linear by default)
  81905. * @param onAnimationEnd defines the callback to call when animation end
  81906. * @returns the animatable created for this animation
  81907. */
  81908. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81909. /**
  81910. * Create and start an animation on a node and its descendants
  81911. * @param name defines the name of the global animation that will be run on all nodes
  81912. * @param node defines the root node where the animation will take place
  81913. * @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
  81914. * @param targetProperty defines property to animate
  81915. * @param framePerSecond defines the number of frame per second to use
  81916. * @param totalFrame defines the number of frames in total
  81917. * @param from defines the initial value
  81918. * @param to defines the final value
  81919. * @param loopMode defines which loop mode you want to use (off by default)
  81920. * @param easingFunction defines the easing function to use (linear by default)
  81921. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81922. * @returns the list of animatables created for all nodes
  81923. * @example https://www.babylonjs-playground.com/#MH0VLI
  81924. */
  81925. 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[]>;
  81926. /**
  81927. * Creates a new animation, merges it with the existing animations and starts it
  81928. * @param name Name of the animation
  81929. * @param node Node which contains the scene that begins the animations
  81930. * @param targetProperty Specifies which property to animate
  81931. * @param framePerSecond The frames per second of the animation
  81932. * @param totalFrame The total number of frames
  81933. * @param from The frame at the beginning of the animation
  81934. * @param to The frame at the end of the animation
  81935. * @param loopMode Specifies the loop mode of the animation
  81936. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  81937. * @param onAnimationEnd Callback to run once the animation is complete
  81938. * @returns Nullable animation
  81939. */
  81940. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81941. /**
  81942. * Transition property of an host to the target Value
  81943. * @param property The property to transition
  81944. * @param targetValue The target Value of the property
  81945. * @param host The object where the property to animate belongs
  81946. * @param scene Scene used to run the animation
  81947. * @param frameRate Framerate (in frame/s) to use
  81948. * @param transition The transition type we want to use
  81949. * @param duration The duration of the animation, in milliseconds
  81950. * @param onAnimationEnd Callback trigger at the end of the animation
  81951. * @returns Nullable animation
  81952. */
  81953. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  81954. /**
  81955. * Return the array of runtime animations currently using this animation
  81956. */
  81957. readonly runtimeAnimations: RuntimeAnimation[];
  81958. /**
  81959. * Specifies if any of the runtime animations are currently running
  81960. */
  81961. readonly hasRunningRuntimeAnimations: boolean;
  81962. /**
  81963. * Initializes the animation
  81964. * @param name Name of the animation
  81965. * @param targetProperty Property to animate
  81966. * @param framePerSecond The frames per second of the animation
  81967. * @param dataType The data type of the animation
  81968. * @param loopMode The loop mode of the animation
  81969. * @param enableBlending Specifies if blending should be enabled
  81970. */
  81971. constructor(
  81972. /**Name of the animation */
  81973. name: string,
  81974. /**Property to animate */
  81975. targetProperty: string,
  81976. /**The frames per second of the animation */
  81977. framePerSecond: number,
  81978. /**The data type of the animation */
  81979. dataType: number,
  81980. /**The loop mode of the animation */
  81981. loopMode?: number | undefined,
  81982. /**Specifies if blending should be enabled */
  81983. enableBlending?: boolean | undefined);
  81984. /**
  81985. * Converts the animation to a string
  81986. * @param fullDetails support for multiple levels of logging within scene loading
  81987. * @returns String form of the animation
  81988. */
  81989. toString(fullDetails?: boolean): string;
  81990. /**
  81991. * Add an event to this animation
  81992. * @param event Event to add
  81993. */
  81994. addEvent(event: AnimationEvent): void;
  81995. /**
  81996. * Remove all events found at the given frame
  81997. * @param frame The frame to remove events from
  81998. */
  81999. removeEvents(frame: number): void;
  82000. /**
  82001. * Retrieves all the events from the animation
  82002. * @returns Events from the animation
  82003. */
  82004. getEvents(): AnimationEvent[];
  82005. /**
  82006. * Creates an animation range
  82007. * @param name Name of the animation range
  82008. * @param from Starting frame of the animation range
  82009. * @param to Ending frame of the animation
  82010. */
  82011. createRange(name: string, from: number, to: number): void;
  82012. /**
  82013. * Deletes an animation range by name
  82014. * @param name Name of the animation range to delete
  82015. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  82016. */
  82017. deleteRange(name: string, deleteFrames?: boolean): void;
  82018. /**
  82019. * Gets the animation range by name, or null if not defined
  82020. * @param name Name of the animation range
  82021. * @returns Nullable animation range
  82022. */
  82023. getRange(name: string): Nullable<AnimationRange>;
  82024. /**
  82025. * Gets the key frames from the animation
  82026. * @returns The key frames of the animation
  82027. */
  82028. getKeys(): Array<IAnimationKey>;
  82029. /**
  82030. * Gets the highest frame rate of the animation
  82031. * @returns Highest frame rate of the animation
  82032. */
  82033. getHighestFrame(): number;
  82034. /**
  82035. * Gets the easing function of the animation
  82036. * @returns Easing function of the animation
  82037. */
  82038. getEasingFunction(): IEasingFunction;
  82039. /**
  82040. * Sets the easing function of the animation
  82041. * @param easingFunction A custom mathematical formula for animation
  82042. */
  82043. setEasingFunction(easingFunction: EasingFunction): void;
  82044. /**
  82045. * Interpolates a scalar linearly
  82046. * @param startValue Start value of the animation curve
  82047. * @param endValue End value of the animation curve
  82048. * @param gradient Scalar amount to interpolate
  82049. * @returns Interpolated scalar value
  82050. */
  82051. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  82052. /**
  82053. * Interpolates a scalar cubically
  82054. * @param startValue Start value of the animation curve
  82055. * @param outTangent End tangent of the animation
  82056. * @param endValue End value of the animation curve
  82057. * @param inTangent Start tangent of the animation curve
  82058. * @param gradient Scalar amount to interpolate
  82059. * @returns Interpolated scalar value
  82060. */
  82061. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82062. /**
  82063. * Interpolates a quaternion using a spherical linear interpolation
  82064. * @param startValue Start value of the animation curve
  82065. * @param endValue End value of the animation curve
  82066. * @param gradient Scalar amount to interpolate
  82067. * @returns Interpolated quaternion value
  82068. */
  82069. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82070. /**
  82071. * Interpolates a quaternion cubically
  82072. * @param startValue Start value of the animation curve
  82073. * @param outTangent End tangent of the animation curve
  82074. * @param endValue End value of the animation curve
  82075. * @param inTangent Start tangent of the animation curve
  82076. * @param gradient Scalar amount to interpolate
  82077. * @returns Interpolated quaternion value
  82078. */
  82079. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82080. /**
  82081. * Interpolates a Vector3 linearl
  82082. * @param startValue Start value of the animation curve
  82083. * @param endValue End value of the animation curve
  82084. * @param gradient Scalar amount to interpolate
  82085. * @returns Interpolated scalar value
  82086. */
  82087. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82088. /**
  82089. * Interpolates a Vector3 cubically
  82090. * @param startValue Start value of the animation curve
  82091. * @param outTangent End tangent of the animation
  82092. * @param endValue End value of the animation curve
  82093. * @param inTangent Start tangent of the animation curve
  82094. * @param gradient Scalar amount to interpolate
  82095. * @returns InterpolatedVector3 value
  82096. */
  82097. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82098. /**
  82099. * Interpolates a Vector2 linearly
  82100. * @param startValue Start value of the animation curve
  82101. * @param endValue End value of the animation curve
  82102. * @param gradient Scalar amount to interpolate
  82103. * @returns Interpolated Vector2 value
  82104. */
  82105. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82106. /**
  82107. * Interpolates a Vector2 cubically
  82108. * @param startValue Start value of the animation curve
  82109. * @param outTangent End tangent of the animation
  82110. * @param endValue End value of the animation curve
  82111. * @param inTangent Start tangent of the animation curve
  82112. * @param gradient Scalar amount to interpolate
  82113. * @returns Interpolated Vector2 value
  82114. */
  82115. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82116. /**
  82117. * Interpolates a size linearly
  82118. * @param startValue Start value of the animation curve
  82119. * @param endValue End value of the animation curve
  82120. * @param gradient Scalar amount to interpolate
  82121. * @returns Interpolated Size value
  82122. */
  82123. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82124. /**
  82125. * Interpolates a Color3 linearly
  82126. * @param startValue Start value of the animation curve
  82127. * @param endValue End value of the animation curve
  82128. * @param gradient Scalar amount to interpolate
  82129. * @returns Interpolated Color3 value
  82130. */
  82131. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82132. /**
  82133. * @hidden Internal use only
  82134. */
  82135. _getKeyValue(value: any): any;
  82136. /**
  82137. * @hidden Internal use only
  82138. */
  82139. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82140. /**
  82141. * Defines the function to use to interpolate matrices
  82142. * @param startValue defines the start matrix
  82143. * @param endValue defines the end matrix
  82144. * @param gradient defines the gradient between both matrices
  82145. * @param result defines an optional target matrix where to store the interpolation
  82146. * @returns the interpolated matrix
  82147. */
  82148. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82149. /**
  82150. * Makes a copy of the animation
  82151. * @returns Cloned animation
  82152. */
  82153. clone(): Animation;
  82154. /**
  82155. * Sets the key frames of the animation
  82156. * @param values The animation key frames to set
  82157. */
  82158. setKeys(values: Array<IAnimationKey>): void;
  82159. /**
  82160. * Serializes the animation to an object
  82161. * @returns Serialized object
  82162. */
  82163. serialize(): any;
  82164. /**
  82165. * Float animation type
  82166. */
  82167. private static _ANIMATIONTYPE_FLOAT;
  82168. /**
  82169. * Vector3 animation type
  82170. */
  82171. private static _ANIMATIONTYPE_VECTOR3;
  82172. /**
  82173. * Quaternion animation type
  82174. */
  82175. private static _ANIMATIONTYPE_QUATERNION;
  82176. /**
  82177. * Matrix animation type
  82178. */
  82179. private static _ANIMATIONTYPE_MATRIX;
  82180. /**
  82181. * Color3 animation type
  82182. */
  82183. private static _ANIMATIONTYPE_COLOR3;
  82184. /**
  82185. * Vector2 animation type
  82186. */
  82187. private static _ANIMATIONTYPE_VECTOR2;
  82188. /**
  82189. * Size animation type
  82190. */
  82191. private static _ANIMATIONTYPE_SIZE;
  82192. /**
  82193. * Relative Loop Mode
  82194. */
  82195. private static _ANIMATIONLOOPMODE_RELATIVE;
  82196. /**
  82197. * Cycle Loop Mode
  82198. */
  82199. private static _ANIMATIONLOOPMODE_CYCLE;
  82200. /**
  82201. * Constant Loop Mode
  82202. */
  82203. private static _ANIMATIONLOOPMODE_CONSTANT;
  82204. /**
  82205. * Get the float animation type
  82206. */
  82207. static readonly ANIMATIONTYPE_FLOAT: number;
  82208. /**
  82209. * Get the Vector3 animation type
  82210. */
  82211. static readonly ANIMATIONTYPE_VECTOR3: number;
  82212. /**
  82213. * Get the Vector2 animation type
  82214. */
  82215. static readonly ANIMATIONTYPE_VECTOR2: number;
  82216. /**
  82217. * Get the Size animation type
  82218. */
  82219. static readonly ANIMATIONTYPE_SIZE: number;
  82220. /**
  82221. * Get the Quaternion animation type
  82222. */
  82223. static readonly ANIMATIONTYPE_QUATERNION: number;
  82224. /**
  82225. * Get the Matrix animation type
  82226. */
  82227. static readonly ANIMATIONTYPE_MATRIX: number;
  82228. /**
  82229. * Get the Color3 animation type
  82230. */
  82231. static readonly ANIMATIONTYPE_COLOR3: number;
  82232. /**
  82233. * Get the Relative Loop Mode
  82234. */
  82235. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82236. /**
  82237. * Get the Cycle Loop Mode
  82238. */
  82239. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82240. /**
  82241. * Get the Constant Loop Mode
  82242. */
  82243. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82244. /** @hidden */
  82245. static _UniversalLerp(left: any, right: any, amount: number): any;
  82246. /**
  82247. * Parses an animation object and creates an animation
  82248. * @param parsedAnimation Parsed animation object
  82249. * @returns Animation object
  82250. */
  82251. static Parse(parsedAnimation: any): Animation;
  82252. /**
  82253. * Appends the serialized animations from the source animations
  82254. * @param source Source containing the animations
  82255. * @param destination Target to store the animations
  82256. */
  82257. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82258. }
  82259. }
  82260. declare module BABYLON {
  82261. /**
  82262. * Base class of all the textures in babylon.
  82263. * It groups all the common properties the materials, post process, lights... might need
  82264. * in order to make a correct use of the texture.
  82265. */
  82266. export class BaseTexture implements IAnimatable {
  82267. /**
  82268. * Default anisotropic filtering level for the application.
  82269. * It is set to 4 as a good tradeoff between perf and quality.
  82270. */
  82271. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82272. /**
  82273. * Gets or sets the unique id of the texture
  82274. */
  82275. uniqueId: number;
  82276. /**
  82277. * Define the name of the texture.
  82278. */
  82279. name: string;
  82280. /**
  82281. * Gets or sets an object used to store user defined information.
  82282. */
  82283. metadata: any;
  82284. /**
  82285. * For internal use only. Please do not use.
  82286. */
  82287. reservedDataStore: any;
  82288. private _hasAlpha;
  82289. /**
  82290. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82291. */
  82292. hasAlpha: boolean;
  82293. /**
  82294. * Defines if the alpha value should be determined via the rgb values.
  82295. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82296. */
  82297. getAlphaFromRGB: boolean;
  82298. /**
  82299. * Intensity or strength of the texture.
  82300. * It is commonly used by materials to fine tune the intensity of the texture
  82301. */
  82302. level: number;
  82303. /**
  82304. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82305. * This is part of the texture as textures usually maps to one uv set.
  82306. */
  82307. coordinatesIndex: number;
  82308. private _coordinatesMode;
  82309. /**
  82310. * How a texture is mapped.
  82311. *
  82312. * | Value | Type | Description |
  82313. * | ----- | ----------------------------------- | ----------- |
  82314. * | 0 | EXPLICIT_MODE | |
  82315. * | 1 | SPHERICAL_MODE | |
  82316. * | 2 | PLANAR_MODE | |
  82317. * | 3 | CUBIC_MODE | |
  82318. * | 4 | PROJECTION_MODE | |
  82319. * | 5 | SKYBOX_MODE | |
  82320. * | 6 | INVCUBIC_MODE | |
  82321. * | 7 | EQUIRECTANGULAR_MODE | |
  82322. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82323. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82324. */
  82325. coordinatesMode: number;
  82326. /**
  82327. * | Value | Type | Description |
  82328. * | ----- | ------------------ | ----------- |
  82329. * | 0 | CLAMP_ADDRESSMODE | |
  82330. * | 1 | WRAP_ADDRESSMODE | |
  82331. * | 2 | MIRROR_ADDRESSMODE | |
  82332. */
  82333. wrapU: number;
  82334. /**
  82335. * | Value | Type | Description |
  82336. * | ----- | ------------------ | ----------- |
  82337. * | 0 | CLAMP_ADDRESSMODE | |
  82338. * | 1 | WRAP_ADDRESSMODE | |
  82339. * | 2 | MIRROR_ADDRESSMODE | |
  82340. */
  82341. wrapV: number;
  82342. /**
  82343. * | Value | Type | Description |
  82344. * | ----- | ------------------ | ----------- |
  82345. * | 0 | CLAMP_ADDRESSMODE | |
  82346. * | 1 | WRAP_ADDRESSMODE | |
  82347. * | 2 | MIRROR_ADDRESSMODE | |
  82348. */
  82349. wrapR: number;
  82350. /**
  82351. * With compliant hardware and browser (supporting anisotropic filtering)
  82352. * this defines the level of anisotropic filtering in the texture.
  82353. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82354. */
  82355. anisotropicFilteringLevel: number;
  82356. /**
  82357. * Define if the texture is a cube texture or if false a 2d texture.
  82358. */
  82359. isCube: boolean;
  82360. /**
  82361. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82362. */
  82363. is3D: boolean;
  82364. /**
  82365. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  82366. * HDR texture are usually stored in linear space.
  82367. * This only impacts the PBR and Background materials
  82368. */
  82369. gammaSpace: boolean;
  82370. /**
  82371. * Gets whether or not the texture contains RGBD data.
  82372. */
  82373. readonly isRGBD: boolean;
  82374. /**
  82375. * Is Z inverted in the texture (useful in a cube texture).
  82376. */
  82377. invertZ: boolean;
  82378. /**
  82379. * Are mip maps generated for this texture or not.
  82380. */
  82381. readonly noMipmap: boolean;
  82382. /**
  82383. * @hidden
  82384. */
  82385. lodLevelInAlpha: boolean;
  82386. /**
  82387. * With prefiltered texture, defined the offset used during the prefiltering steps.
  82388. */
  82389. lodGenerationOffset: number;
  82390. /**
  82391. * With prefiltered texture, defined the scale used during the prefiltering steps.
  82392. */
  82393. lodGenerationScale: number;
  82394. /**
  82395. * Define if the texture is a render target.
  82396. */
  82397. isRenderTarget: boolean;
  82398. /**
  82399. * Define the unique id of the texture in the scene.
  82400. */
  82401. readonly uid: string;
  82402. /**
  82403. * Return a string representation of the texture.
  82404. * @returns the texture as a string
  82405. */
  82406. toString(): string;
  82407. /**
  82408. * Get the class name of the texture.
  82409. * @returns "BaseTexture"
  82410. */
  82411. getClassName(): string;
  82412. /**
  82413. * Define the list of animation attached to the texture.
  82414. */
  82415. animations: Animation[];
  82416. /**
  82417. * An event triggered when the texture is disposed.
  82418. */
  82419. onDisposeObservable: Observable<BaseTexture>;
  82420. private _onDisposeObserver;
  82421. /**
  82422. * Callback triggered when the texture has been disposed.
  82423. * Kept for back compatibility, you can use the onDisposeObservable instead.
  82424. */
  82425. onDispose: () => void;
  82426. /**
  82427. * Define the current state of the loading sequence when in delayed load mode.
  82428. */
  82429. delayLoadState: number;
  82430. private _scene;
  82431. /** @hidden */
  82432. _texture: Nullable<InternalTexture>;
  82433. private _uid;
  82434. /**
  82435. * Define if the texture is preventinga material to render or not.
  82436. * If not and the texture is not ready, the engine will use a default black texture instead.
  82437. */
  82438. readonly isBlocking: boolean;
  82439. /**
  82440. * Instantiates a new BaseTexture.
  82441. * Base class of all the textures in babylon.
  82442. * It groups all the common properties the materials, post process, lights... might need
  82443. * in order to make a correct use of the texture.
  82444. * @param scene Define the scene the texture blongs to
  82445. */
  82446. constructor(scene: Nullable<Scene>);
  82447. /**
  82448. * Get the scene the texture belongs to.
  82449. * @returns the scene or null if undefined
  82450. */
  82451. getScene(): Nullable<Scene>;
  82452. /**
  82453. * Get the texture transform matrix used to offset tile the texture for istance.
  82454. * @returns the transformation matrix
  82455. */
  82456. getTextureMatrix(): Matrix;
  82457. /**
  82458. * Get the texture reflection matrix used to rotate/transform the reflection.
  82459. * @returns the reflection matrix
  82460. */
  82461. getReflectionTextureMatrix(): Matrix;
  82462. /**
  82463. * Get the underlying lower level texture from Babylon.
  82464. * @returns the insternal texture
  82465. */
  82466. getInternalTexture(): Nullable<InternalTexture>;
  82467. /**
  82468. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  82469. * @returns true if ready or not blocking
  82470. */
  82471. isReadyOrNotBlocking(): boolean;
  82472. /**
  82473. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  82474. * @returns true if fully ready
  82475. */
  82476. isReady(): boolean;
  82477. private _cachedSize;
  82478. /**
  82479. * Get the size of the texture.
  82480. * @returns the texture size.
  82481. */
  82482. getSize(): ISize;
  82483. /**
  82484. * Get the base size of the texture.
  82485. * It can be different from the size if the texture has been resized for POT for instance
  82486. * @returns the base size
  82487. */
  82488. getBaseSize(): ISize;
  82489. /**
  82490. * Update the sampling mode of the texture.
  82491. * Default is Trilinear mode.
  82492. *
  82493. * | Value | Type | Description |
  82494. * | ----- | ------------------ | ----------- |
  82495. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  82496. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  82497. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  82498. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  82499. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  82500. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  82501. * | 7 | NEAREST_LINEAR | |
  82502. * | 8 | NEAREST_NEAREST | |
  82503. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  82504. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  82505. * | 11 | LINEAR_LINEAR | |
  82506. * | 12 | LINEAR_NEAREST | |
  82507. *
  82508. * > _mag_: magnification filter (close to the viewer)
  82509. * > _min_: minification filter (far from the viewer)
  82510. * > _mip_: filter used between mip map levels
  82511. *@param samplingMode Define the new sampling mode of the texture
  82512. */
  82513. updateSamplingMode(samplingMode: number): void;
  82514. /**
  82515. * Scales the texture if is `canRescale()`
  82516. * @param ratio the resize factor we want to use to rescale
  82517. */
  82518. scale(ratio: number): void;
  82519. /**
  82520. * Get if the texture can rescale.
  82521. */
  82522. readonly canRescale: boolean;
  82523. /** @hidden */
  82524. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  82525. /** @hidden */
  82526. _rebuild(): void;
  82527. /**
  82528. * Triggers the load sequence in delayed load mode.
  82529. */
  82530. delayLoad(): void;
  82531. /**
  82532. * Clones the texture.
  82533. * @returns the cloned texture
  82534. */
  82535. clone(): Nullable<BaseTexture>;
  82536. /**
  82537. * Get the texture underlying type (INT, FLOAT...)
  82538. */
  82539. readonly textureType: number;
  82540. /**
  82541. * Get the texture underlying format (RGB, RGBA...)
  82542. */
  82543. readonly textureFormat: number;
  82544. /**
  82545. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  82546. * This will returns an RGBA array buffer containing either in values (0-255) or
  82547. * float values (0-1) depending of the underlying buffer type.
  82548. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  82549. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  82550. * @param buffer defines a user defined buffer to fill with data (can be null)
  82551. * @returns The Array buffer containing the pixels data.
  82552. */
  82553. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  82554. /**
  82555. * Release and destroy the underlying lower level texture aka internalTexture.
  82556. */
  82557. releaseInternalTexture(): void;
  82558. /**
  82559. * Get the polynomial representation of the texture data.
  82560. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  82561. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  82562. */
  82563. sphericalPolynomial: Nullable<SphericalPolynomial>;
  82564. /** @hidden */
  82565. readonly _lodTextureHigh: Nullable<BaseTexture>;
  82566. /** @hidden */
  82567. readonly _lodTextureMid: Nullable<BaseTexture>;
  82568. /** @hidden */
  82569. readonly _lodTextureLow: Nullable<BaseTexture>;
  82570. /**
  82571. * Dispose the texture and release its associated resources.
  82572. */
  82573. dispose(): void;
  82574. /**
  82575. * Serialize the texture into a JSON representation that can be parsed later on.
  82576. * @returns the JSON representation of the texture
  82577. */
  82578. serialize(): any;
  82579. /**
  82580. * Helper function to be called back once a list of texture contains only ready textures.
  82581. * @param textures Define the list of textures to wait for
  82582. * @param callback Define the callback triggered once the entire list will be ready
  82583. */
  82584. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  82585. }
  82586. }
  82587. declare module BABYLON {
  82588. /**
  82589. * Uniform buffer objects.
  82590. *
  82591. * Handles blocks of uniform on the GPU.
  82592. *
  82593. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82594. *
  82595. * For more information, please refer to :
  82596. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82597. */
  82598. export class UniformBuffer {
  82599. private _engine;
  82600. private _buffer;
  82601. private _data;
  82602. private _bufferData;
  82603. private _dynamic?;
  82604. private _uniformLocations;
  82605. private _uniformSizes;
  82606. private _uniformLocationPointer;
  82607. private _needSync;
  82608. private _noUBO;
  82609. private _currentEffect;
  82610. private static _MAX_UNIFORM_SIZE;
  82611. private static _tempBuffer;
  82612. /**
  82613. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82614. * This is dynamic to allow compat with webgl 1 and 2.
  82615. * You will need to pass the name of the uniform as well as the value.
  82616. */
  82617. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82618. /**
  82619. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82620. * This is dynamic to allow compat with webgl 1 and 2.
  82621. * You will need to pass the name of the uniform as well as the value.
  82622. */
  82623. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82624. /**
  82625. * Lambda to Update a single float in a uniform buffer.
  82626. * This is dynamic to allow compat with webgl 1 and 2.
  82627. * You will need to pass the name of the uniform as well as the value.
  82628. */
  82629. updateFloat: (name: string, x: number) => void;
  82630. /**
  82631. * Lambda to Update a vec2 of float in a uniform buffer.
  82632. * This is dynamic to allow compat with webgl 1 and 2.
  82633. * You will need to pass the name of the uniform as well as the value.
  82634. */
  82635. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82636. /**
  82637. * Lambda to Update a vec3 of float in a uniform buffer.
  82638. * This is dynamic to allow compat with webgl 1 and 2.
  82639. * You will need to pass the name of the uniform as well as the value.
  82640. */
  82641. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82642. /**
  82643. * Lambda to Update a vec4 of float in a uniform buffer.
  82644. * This is dynamic to allow compat with webgl 1 and 2.
  82645. * You will need to pass the name of the uniform as well as the value.
  82646. */
  82647. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82648. /**
  82649. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82650. * This is dynamic to allow compat with webgl 1 and 2.
  82651. * You will need to pass the name of the uniform as well as the value.
  82652. */
  82653. updateMatrix: (name: string, mat: Matrix) => void;
  82654. /**
  82655. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82656. * This is dynamic to allow compat with webgl 1 and 2.
  82657. * You will need to pass the name of the uniform as well as the value.
  82658. */
  82659. updateVector3: (name: string, vector: Vector3) => void;
  82660. /**
  82661. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82662. * This is dynamic to allow compat with webgl 1 and 2.
  82663. * You will need to pass the name of the uniform as well as the value.
  82664. */
  82665. updateVector4: (name: string, vector: Vector4) => void;
  82666. /**
  82667. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82668. * This is dynamic to allow compat with webgl 1 and 2.
  82669. * You will need to pass the name of the uniform as well as the value.
  82670. */
  82671. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82672. /**
  82673. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82674. * This is dynamic to allow compat with webgl 1 and 2.
  82675. * You will need to pass the name of the uniform as well as the value.
  82676. */
  82677. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82678. /**
  82679. * Instantiates a new Uniform buffer objects.
  82680. *
  82681. * Handles blocks of uniform on the GPU.
  82682. *
  82683. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82684. *
  82685. * For more information, please refer to :
  82686. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82687. * @param engine Define the engine the buffer is associated with
  82688. * @param data Define the data contained in the buffer
  82689. * @param dynamic Define if the buffer is updatable
  82690. */
  82691. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82692. /**
  82693. * Indicates if the buffer is using the WebGL2 UBO implementation,
  82694. * or just falling back on setUniformXXX calls.
  82695. */
  82696. readonly useUbo: boolean;
  82697. /**
  82698. * Indicates if the WebGL underlying uniform buffer is in sync
  82699. * with the javascript cache data.
  82700. */
  82701. readonly isSync: boolean;
  82702. /**
  82703. * Indicates if the WebGL underlying uniform buffer is dynamic.
  82704. * Also, a dynamic UniformBuffer will disable cache verification and always
  82705. * update the underlying WebGL uniform buffer to the GPU.
  82706. * @returns if Dynamic, otherwise false
  82707. */
  82708. isDynamic(): boolean;
  82709. /**
  82710. * The data cache on JS side.
  82711. * @returns the underlying data as a float array
  82712. */
  82713. getData(): Float32Array;
  82714. /**
  82715. * The underlying WebGL Uniform buffer.
  82716. * @returns the webgl buffer
  82717. */
  82718. getBuffer(): Nullable<WebGLBuffer>;
  82719. /**
  82720. * std140 layout specifies how to align data within an UBO structure.
  82721. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  82722. * for specs.
  82723. */
  82724. private _fillAlignment;
  82725. /**
  82726. * Adds an uniform in the buffer.
  82727. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  82728. * for the layout to be correct !
  82729. * @param name Name of the uniform, as used in the uniform block in the shader.
  82730. * @param size Data size, or data directly.
  82731. */
  82732. addUniform(name: string, size: number | number[]): void;
  82733. /**
  82734. * Adds a Matrix 4x4 to the uniform buffer.
  82735. * @param name Name of the uniform, as used in the uniform block in the shader.
  82736. * @param mat A 4x4 matrix.
  82737. */
  82738. addMatrix(name: string, mat: Matrix): void;
  82739. /**
  82740. * Adds a vec2 to the uniform buffer.
  82741. * @param name Name of the uniform, as used in the uniform block in the shader.
  82742. * @param x Define the x component value of the vec2
  82743. * @param y Define the y component value of the vec2
  82744. */
  82745. addFloat2(name: string, x: number, y: number): void;
  82746. /**
  82747. * Adds a vec3 to the uniform buffer.
  82748. * @param name Name of the uniform, as used in the uniform block in the shader.
  82749. * @param x Define the x component value of the vec3
  82750. * @param y Define the y component value of the vec3
  82751. * @param z Define the z component value of the vec3
  82752. */
  82753. addFloat3(name: string, x: number, y: number, z: number): void;
  82754. /**
  82755. * Adds a vec3 to the uniform buffer.
  82756. * @param name Name of the uniform, as used in the uniform block in the shader.
  82757. * @param color Define the vec3 from a Color
  82758. */
  82759. addColor3(name: string, color: Color3): void;
  82760. /**
  82761. * Adds a vec4 to the uniform buffer.
  82762. * @param name Name of the uniform, as used in the uniform block in the shader.
  82763. * @param color Define the rgb components from a Color
  82764. * @param alpha Define the a component of the vec4
  82765. */
  82766. addColor4(name: string, color: Color3, alpha: number): void;
  82767. /**
  82768. * Adds a vec3 to the uniform buffer.
  82769. * @param name Name of the uniform, as used in the uniform block in the shader.
  82770. * @param vector Define the vec3 components from a Vector
  82771. */
  82772. addVector3(name: string, vector: Vector3): void;
  82773. /**
  82774. * Adds a Matrix 3x3 to the uniform buffer.
  82775. * @param name Name of the uniform, as used in the uniform block in the shader.
  82776. */
  82777. addMatrix3x3(name: string): void;
  82778. /**
  82779. * Adds a Matrix 2x2 to the uniform buffer.
  82780. * @param name Name of the uniform, as used in the uniform block in the shader.
  82781. */
  82782. addMatrix2x2(name: string): void;
  82783. /**
  82784. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  82785. */
  82786. create(): void;
  82787. /** @hidden */
  82788. _rebuild(): void;
  82789. /**
  82790. * Updates the WebGL Uniform Buffer on the GPU.
  82791. * If the `dynamic` flag is set to true, no cache comparison is done.
  82792. * Otherwise, the buffer will be updated only if the cache differs.
  82793. */
  82794. update(): void;
  82795. /**
  82796. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  82797. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82798. * @param data Define the flattened data
  82799. * @param size Define the size of the data.
  82800. */
  82801. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  82802. private _updateMatrix3x3ForUniform;
  82803. private _updateMatrix3x3ForEffect;
  82804. private _updateMatrix2x2ForEffect;
  82805. private _updateMatrix2x2ForUniform;
  82806. private _updateFloatForEffect;
  82807. private _updateFloatForUniform;
  82808. private _updateFloat2ForEffect;
  82809. private _updateFloat2ForUniform;
  82810. private _updateFloat3ForEffect;
  82811. private _updateFloat3ForUniform;
  82812. private _updateFloat4ForEffect;
  82813. private _updateFloat4ForUniform;
  82814. private _updateMatrixForEffect;
  82815. private _updateMatrixForUniform;
  82816. private _updateVector3ForEffect;
  82817. private _updateVector3ForUniform;
  82818. private _updateVector4ForEffect;
  82819. private _updateVector4ForUniform;
  82820. private _updateColor3ForEffect;
  82821. private _updateColor3ForUniform;
  82822. private _updateColor4ForEffect;
  82823. private _updateColor4ForUniform;
  82824. /**
  82825. * Sets a sampler uniform on the effect.
  82826. * @param name Define the name of the sampler.
  82827. * @param texture Define the texture to set in the sampler
  82828. */
  82829. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  82830. /**
  82831. * Directly updates the value of the uniform in the cache AND on the GPU.
  82832. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82833. * @param data Define the flattened data
  82834. */
  82835. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  82836. /**
  82837. * Binds this uniform buffer to an effect.
  82838. * @param effect Define the effect to bind the buffer to
  82839. * @param name Name of the uniform block in the shader.
  82840. */
  82841. bindToEffect(effect: Effect, name: string): void;
  82842. /**
  82843. * Disposes the uniform buffer.
  82844. */
  82845. dispose(): void;
  82846. }
  82847. }
  82848. declare module BABYLON {
  82849. /**
  82850. * This represents the required contract to create a new type of texture loader.
  82851. */
  82852. export interface IInternalTextureLoader {
  82853. /**
  82854. * Defines wether the loader supports cascade loading the different faces.
  82855. */
  82856. supportCascades: boolean;
  82857. /**
  82858. * This returns if the loader support the current file information.
  82859. * @param extension defines the file extension of the file being loaded
  82860. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82861. * @param fallback defines the fallback internal texture if any
  82862. * @param isBase64 defines whether the texture is encoded as a base64
  82863. * @param isBuffer defines whether the texture data are stored as a buffer
  82864. * @returns true if the loader can load the specified file
  82865. */
  82866. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  82867. /**
  82868. * Transform the url before loading if required.
  82869. * @param rootUrl the url of the texture
  82870. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82871. * @returns the transformed texture
  82872. */
  82873. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  82874. /**
  82875. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  82876. * @param rootUrl the url of the texture
  82877. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82878. * @returns the fallback texture
  82879. */
  82880. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  82881. /**
  82882. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  82883. * @param data contains the texture data
  82884. * @param texture defines the BabylonJS internal texture
  82885. * @param createPolynomials will be true if polynomials have been requested
  82886. * @param onLoad defines the callback to trigger once the texture is ready
  82887. * @param onError defines the callback to trigger in case of error
  82888. */
  82889. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  82890. /**
  82891. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  82892. * @param data contains the texture data
  82893. * @param texture defines the BabylonJS internal texture
  82894. * @param callback defines the method to call once ready to upload
  82895. */
  82896. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  82897. }
  82898. }
  82899. declare module BABYLON {
  82900. /**
  82901. * Creation options of the multi render target texture.
  82902. */
  82903. export interface IMultiRenderTargetOptions {
  82904. /**
  82905. * Define if the texture needs to create mip maps after render.
  82906. */
  82907. generateMipMaps?: boolean;
  82908. /**
  82909. * Define the types of all the draw buffers we want to create
  82910. */
  82911. types?: number[];
  82912. /**
  82913. * Define the sampling modes of all the draw buffers we want to create
  82914. */
  82915. samplingModes?: number[];
  82916. /**
  82917. * Define if a depth buffer is required
  82918. */
  82919. generateDepthBuffer?: boolean;
  82920. /**
  82921. * Define if a stencil buffer is required
  82922. */
  82923. generateStencilBuffer?: boolean;
  82924. /**
  82925. * Define if a depth texture is required instead of a depth buffer
  82926. */
  82927. generateDepthTexture?: boolean;
  82928. /**
  82929. * Define the number of desired draw buffers
  82930. */
  82931. textureCount?: number;
  82932. /**
  82933. * Define if aspect ratio should be adapted to the texture or stay the scene one
  82934. */
  82935. doNotChangeAspectRatio?: boolean;
  82936. /**
  82937. * Define the default type of the buffers we are creating
  82938. */
  82939. defaultType?: number;
  82940. }
  82941. /**
  82942. * A multi render target, like a render target provides the ability to render to a texture.
  82943. * Unlike the render target, it can render to several draw buffers in one draw.
  82944. * This is specially interesting in deferred rendering or for any effects requiring more than
  82945. * just one color from a single pass.
  82946. */
  82947. export class MultiRenderTarget extends RenderTargetTexture {
  82948. private _internalTextures;
  82949. private _textures;
  82950. private _multiRenderTargetOptions;
  82951. /**
  82952. * Get if draw buffers are currently supported by the used hardware and browser.
  82953. */
  82954. readonly isSupported: boolean;
  82955. /**
  82956. * Get the list of textures generated by the multi render target.
  82957. */
  82958. readonly textures: Texture[];
  82959. /**
  82960. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  82961. */
  82962. readonly depthTexture: Texture;
  82963. /**
  82964. * Set the wrapping mode on U of all the textures we are rendering to.
  82965. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82966. */
  82967. wrapU: number;
  82968. /**
  82969. * Set the wrapping mode on V of all the textures we are rendering to.
  82970. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82971. */
  82972. wrapV: number;
  82973. /**
  82974. * Instantiate a new multi render target texture.
  82975. * A multi render target, like a render target provides the ability to render to a texture.
  82976. * Unlike the render target, it can render to several draw buffers in one draw.
  82977. * This is specially interesting in deferred rendering or for any effects requiring more than
  82978. * just one color from a single pass.
  82979. * @param name Define the name of the texture
  82980. * @param size Define the size of the buffers to render to
  82981. * @param count Define the number of target we are rendering into
  82982. * @param scene Define the scene the texture belongs to
  82983. * @param options Define the options used to create the multi render target
  82984. */
  82985. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  82986. /** @hidden */
  82987. _rebuild(): void;
  82988. private _createInternalTextures;
  82989. private _createTextures;
  82990. /**
  82991. * Define the number of samples used if MSAA is enabled.
  82992. */
  82993. samples: number;
  82994. /**
  82995. * Resize all the textures in the multi render target.
  82996. * Be carrefull as it will recreate all the data in the new texture.
  82997. * @param size Define the new size
  82998. */
  82999. resize(size: any): void;
  83000. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83001. /**
  83002. * Dispose the render targets and their associated resources
  83003. */
  83004. dispose(): void;
  83005. /**
  83006. * Release all the underlying texture used as draw buffers.
  83007. */
  83008. releaseInternalTextures(): void;
  83009. }
  83010. }
  83011. declare module BABYLON {
  83012. /**
  83013. * Class used to work with sound analyzer using fast fourier transform (FFT)
  83014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83015. */
  83016. export class Analyser {
  83017. /**
  83018. * Gets or sets the smoothing
  83019. * @ignorenaming
  83020. */
  83021. SMOOTHING: number;
  83022. /**
  83023. * Gets or sets the FFT table size
  83024. * @ignorenaming
  83025. */
  83026. FFT_SIZE: number;
  83027. /**
  83028. * Gets or sets the bar graph amplitude
  83029. * @ignorenaming
  83030. */
  83031. BARGRAPHAMPLITUDE: number;
  83032. /**
  83033. * Gets or sets the position of the debug canvas
  83034. * @ignorenaming
  83035. */
  83036. DEBUGCANVASPOS: {
  83037. x: number;
  83038. y: number;
  83039. };
  83040. /**
  83041. * Gets or sets the debug canvas size
  83042. * @ignorenaming
  83043. */
  83044. DEBUGCANVASSIZE: {
  83045. width: number;
  83046. height: number;
  83047. };
  83048. private _byteFreqs;
  83049. private _byteTime;
  83050. private _floatFreqs;
  83051. private _webAudioAnalyser;
  83052. private _debugCanvas;
  83053. private _debugCanvasContext;
  83054. private _scene;
  83055. private _registerFunc;
  83056. private _audioEngine;
  83057. /**
  83058. * Creates a new analyser
  83059. * @param scene defines hosting scene
  83060. */
  83061. constructor(scene: Scene);
  83062. /**
  83063. * Get the number of data values you will have to play with for the visualization
  83064. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83065. * @returns a number
  83066. */
  83067. getFrequencyBinCount(): number;
  83068. /**
  83069. * Gets the current frequency data as a byte array
  83070. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83071. * @returns a Uint8Array
  83072. */
  83073. getByteFrequencyData(): Uint8Array;
  83074. /**
  83075. * Gets the current waveform as a byte array
  83076. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83077. * @returns a Uint8Array
  83078. */
  83079. getByteTimeDomainData(): Uint8Array;
  83080. /**
  83081. * Gets the current frequency data as a float array
  83082. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83083. * @returns a Float32Array
  83084. */
  83085. getFloatFrequencyData(): Float32Array;
  83086. /**
  83087. * Renders the debug canvas
  83088. */
  83089. drawDebugCanvas(): void;
  83090. /**
  83091. * Stops rendering the debug canvas and removes it
  83092. */
  83093. stopDebugCanvas(): void;
  83094. /**
  83095. * Connects two audio nodes
  83096. * @param inputAudioNode defines first node to connect
  83097. * @param outputAudioNode defines second node to connect
  83098. */
  83099. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83100. /**
  83101. * Releases all associated resources
  83102. */
  83103. dispose(): void;
  83104. }
  83105. }
  83106. declare module BABYLON {
  83107. /**
  83108. * This represents an audio engine and it is responsible
  83109. * to play, synchronize and analyse sounds throughout the application.
  83110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83111. */
  83112. export interface IAudioEngine extends IDisposable {
  83113. /**
  83114. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83115. */
  83116. readonly canUseWebAudio: boolean;
  83117. /**
  83118. * Gets the current AudioContext if available.
  83119. */
  83120. readonly audioContext: Nullable<AudioContext>;
  83121. /**
  83122. * The master gain node defines the global audio volume of your audio engine.
  83123. */
  83124. readonly masterGain: GainNode;
  83125. /**
  83126. * Gets whether or not mp3 are supported by your browser.
  83127. */
  83128. readonly isMP3supported: boolean;
  83129. /**
  83130. * Gets whether or not ogg are supported by your browser.
  83131. */
  83132. readonly isOGGsupported: boolean;
  83133. /**
  83134. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83135. * @ignoreNaming
  83136. */
  83137. WarnedWebAudioUnsupported: boolean;
  83138. /**
  83139. * Defines if the audio engine relies on a custom unlocked button.
  83140. * In this case, the embedded button will not be displayed.
  83141. */
  83142. useCustomUnlockedButton: boolean;
  83143. /**
  83144. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83145. */
  83146. readonly unlocked: boolean;
  83147. /**
  83148. * Event raised when audio has been unlocked on the browser.
  83149. */
  83150. onAudioUnlockedObservable: Observable<AudioEngine>;
  83151. /**
  83152. * Event raised when audio has been locked on the browser.
  83153. */
  83154. onAudioLockedObservable: Observable<AudioEngine>;
  83155. /**
  83156. * Flags the audio engine in Locked state.
  83157. * This happens due to new browser policies preventing audio to autoplay.
  83158. */
  83159. lock(): void;
  83160. /**
  83161. * Unlocks the audio engine once a user action has been done on the dom.
  83162. * This is helpful to resume play once browser policies have been satisfied.
  83163. */
  83164. unlock(): void;
  83165. }
  83166. /**
  83167. * This represents the default audio engine used in babylon.
  83168. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83170. */
  83171. export class AudioEngine implements IAudioEngine {
  83172. private _audioContext;
  83173. private _audioContextInitialized;
  83174. private _muteButton;
  83175. private _hostElement;
  83176. /**
  83177. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83178. */
  83179. canUseWebAudio: boolean;
  83180. /**
  83181. * The master gain node defines the global audio volume of your audio engine.
  83182. */
  83183. masterGain: GainNode;
  83184. /**
  83185. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83186. * @ignoreNaming
  83187. */
  83188. WarnedWebAudioUnsupported: boolean;
  83189. /**
  83190. * Gets whether or not mp3 are supported by your browser.
  83191. */
  83192. isMP3supported: boolean;
  83193. /**
  83194. * Gets whether or not ogg are supported by your browser.
  83195. */
  83196. isOGGsupported: boolean;
  83197. /**
  83198. * Gets whether audio has been unlocked on the device.
  83199. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83200. * a user interaction has happened.
  83201. */
  83202. unlocked: boolean;
  83203. /**
  83204. * Defines if the audio engine relies on a custom unlocked button.
  83205. * In this case, the embedded button will not be displayed.
  83206. */
  83207. useCustomUnlockedButton: boolean;
  83208. /**
  83209. * Event raised when audio has been unlocked on the browser.
  83210. */
  83211. onAudioUnlockedObservable: Observable<AudioEngine>;
  83212. /**
  83213. * Event raised when audio has been locked on the browser.
  83214. */
  83215. onAudioLockedObservable: Observable<AudioEngine>;
  83216. /**
  83217. * Gets the current AudioContext if available.
  83218. */
  83219. readonly audioContext: Nullable<AudioContext>;
  83220. private _connectedAnalyser;
  83221. /**
  83222. * Instantiates a new audio engine.
  83223. *
  83224. * There should be only one per page as some browsers restrict the number
  83225. * of audio contexts you can create.
  83226. * @param hostElement defines the host element where to display the mute icon if necessary
  83227. */
  83228. constructor(hostElement?: Nullable<HTMLElement>);
  83229. /**
  83230. * Flags the audio engine in Locked state.
  83231. * This happens due to new browser policies preventing audio to autoplay.
  83232. */
  83233. lock(): void;
  83234. /**
  83235. * Unlocks the audio engine once a user action has been done on the dom.
  83236. * This is helpful to resume play once browser policies have been satisfied.
  83237. */
  83238. unlock(): void;
  83239. private _resumeAudioContext;
  83240. private _initializeAudioContext;
  83241. private _tryToRun;
  83242. private _triggerRunningState;
  83243. private _triggerSuspendedState;
  83244. private _displayMuteButton;
  83245. private _moveButtonToTopLeft;
  83246. private _onResize;
  83247. private _hideMuteButton;
  83248. /**
  83249. * Destroy and release the resources associated with the audio ccontext.
  83250. */
  83251. dispose(): void;
  83252. /**
  83253. * Gets the global volume sets on the master gain.
  83254. * @returns the global volume if set or -1 otherwise
  83255. */
  83256. getGlobalVolume(): number;
  83257. /**
  83258. * Sets the global volume of your experience (sets on the master gain).
  83259. * @param newVolume Defines the new global volume of the application
  83260. */
  83261. setGlobalVolume(newVolume: number): void;
  83262. /**
  83263. * Connect the audio engine to an audio analyser allowing some amazing
  83264. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83266. * @param analyser The analyser to connect to the engine
  83267. */
  83268. connectToAnalyser(analyser: Analyser): void;
  83269. }
  83270. }
  83271. declare module BABYLON {
  83272. /**
  83273. * Interface used to present a loading screen while loading a scene
  83274. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83275. */
  83276. export interface ILoadingScreen {
  83277. /**
  83278. * Function called to display the loading screen
  83279. */
  83280. displayLoadingUI: () => void;
  83281. /**
  83282. * Function called to hide the loading screen
  83283. */
  83284. hideLoadingUI: () => void;
  83285. /**
  83286. * Gets or sets the color to use for the background
  83287. */
  83288. loadingUIBackgroundColor: string;
  83289. /**
  83290. * Gets or sets the text to display while loading
  83291. */
  83292. loadingUIText: string;
  83293. }
  83294. /**
  83295. * Class used for the default loading screen
  83296. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83297. */
  83298. export class DefaultLoadingScreen implements ILoadingScreen {
  83299. private _renderingCanvas;
  83300. private _loadingText;
  83301. private _loadingDivBackgroundColor;
  83302. private _loadingDiv;
  83303. private _loadingTextDiv;
  83304. /**
  83305. * Creates a new default loading screen
  83306. * @param _renderingCanvas defines the canvas used to render the scene
  83307. * @param _loadingText defines the default text to display
  83308. * @param _loadingDivBackgroundColor defines the default background color
  83309. */
  83310. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83311. /**
  83312. * Function called to display the loading screen
  83313. */
  83314. displayLoadingUI(): void;
  83315. /**
  83316. * Function called to hide the loading screen
  83317. */
  83318. hideLoadingUI(): void;
  83319. /**
  83320. * Gets or sets the text to display while loading
  83321. */
  83322. loadingUIText: string;
  83323. /**
  83324. * Gets or sets the color to use for the background
  83325. */
  83326. loadingUIBackgroundColor: string;
  83327. private _resizeLoadingUI;
  83328. }
  83329. }
  83330. declare module BABYLON {
  83331. /**
  83332. * Settings for finer control over video usage
  83333. */
  83334. export interface VideoTextureSettings {
  83335. /**
  83336. * Applies `autoplay` to video, if specified
  83337. */
  83338. autoPlay?: boolean;
  83339. /**
  83340. * Applies `loop` to video, if specified
  83341. */
  83342. loop?: boolean;
  83343. /**
  83344. * Automatically updates internal texture from video at every frame in the render loop
  83345. */
  83346. autoUpdateTexture: boolean;
  83347. /**
  83348. * Image src displayed during the video loading or until the user interacts with the video.
  83349. */
  83350. poster?: string;
  83351. }
  83352. /**
  83353. * If you want to display a video in your scene, this is the special texture for that.
  83354. * This special texture works similar to other textures, with the exception of a few parameters.
  83355. * @see https://doc.babylonjs.com/how_to/video_texture
  83356. */
  83357. export class VideoTexture extends Texture {
  83358. /**
  83359. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83360. */
  83361. readonly autoUpdateTexture: boolean;
  83362. /**
  83363. * The video instance used by the texture internally
  83364. */
  83365. readonly video: HTMLVideoElement;
  83366. private _onUserActionRequestedObservable;
  83367. /**
  83368. * Event triggerd when a dom action is required by the user to play the video.
  83369. * This happens due to recent changes in browser policies preventing video to auto start.
  83370. */
  83371. readonly onUserActionRequestedObservable: Observable<Texture>;
  83372. private _generateMipMaps;
  83373. private _engine;
  83374. private _stillImageCaptured;
  83375. private _displayingPosterTexture;
  83376. private _settings;
  83377. private _createInternalTextureOnEvent;
  83378. /**
  83379. * Creates a video texture.
  83380. * If you want to display a video in your scene, this is the special texture for that.
  83381. * This special texture works similar to other textures, with the exception of a few parameters.
  83382. * @see https://doc.babylonjs.com/how_to/video_texture
  83383. * @param name optional name, will detect from video source, if not defined
  83384. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  83385. * @param scene is obviously the current scene.
  83386. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  83387. * @param invertY is false by default but can be used to invert video on Y axis
  83388. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  83389. * @param settings allows finer control over video usage
  83390. */
  83391. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  83392. private _getName;
  83393. private _getVideo;
  83394. private _createInternalTexture;
  83395. private reset;
  83396. /**
  83397. * @hidden Internal method to initiate `update`.
  83398. */
  83399. _rebuild(): void;
  83400. /**
  83401. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  83402. */
  83403. update(): void;
  83404. /**
  83405. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  83406. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  83407. */
  83408. updateTexture(isVisible: boolean): void;
  83409. protected _updateInternalTexture: () => void;
  83410. /**
  83411. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  83412. * @param url New url.
  83413. */
  83414. updateURL(url: string): void;
  83415. /**
  83416. * Dispose the texture and release its associated resources.
  83417. */
  83418. dispose(): void;
  83419. /**
  83420. * Creates a video texture straight from a stream.
  83421. * @param scene Define the scene the texture should be created in
  83422. * @param stream Define the stream the texture should be created from
  83423. * @returns The created video texture as a promise
  83424. */
  83425. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  83426. /**
  83427. * Creates a video texture straight from your WebCam video feed.
  83428. * @param scene Define the scene the texture should be created in
  83429. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83430. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83431. * @returns The created video texture as a promise
  83432. */
  83433. static CreateFromWebCamAsync(scene: Scene, constraints: {
  83434. minWidth: number;
  83435. maxWidth: number;
  83436. minHeight: number;
  83437. maxHeight: number;
  83438. deviceId: string;
  83439. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  83440. /**
  83441. * Creates a video texture straight from your WebCam video feed.
  83442. * @param scene Define the scene the texture should be created in
  83443. * @param onReady Define a callback to triggered once the texture will be ready
  83444. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83445. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83446. */
  83447. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  83448. minWidth: number;
  83449. maxWidth: number;
  83450. minHeight: number;
  83451. maxHeight: number;
  83452. deviceId: string;
  83453. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  83454. }
  83455. }
  83456. declare module BABYLON {
  83457. /**
  83458. * Interface for attribute information associated with buffer instanciation
  83459. */
  83460. export class InstancingAttributeInfo {
  83461. /**
  83462. * Index/offset of the attribute in the vertex shader
  83463. */
  83464. index: number;
  83465. /**
  83466. * size of the attribute, 1, 2, 3 or 4
  83467. */
  83468. attributeSize: number;
  83469. /**
  83470. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  83471. * default is FLOAT
  83472. */
  83473. attribyteType: number;
  83474. /**
  83475. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  83476. */
  83477. normalized: boolean;
  83478. /**
  83479. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  83480. */
  83481. offset: number;
  83482. /**
  83483. * Name of the GLSL attribute, for debugging purpose only
  83484. */
  83485. attributeName: string;
  83486. }
  83487. /**
  83488. * Define options used to create a depth texture
  83489. */
  83490. export class DepthTextureCreationOptions {
  83491. /** Specifies whether or not a stencil should be allocated in the texture */
  83492. generateStencil?: boolean;
  83493. /** Specifies whether or not bilinear filtering is enable on the texture */
  83494. bilinearFiltering?: boolean;
  83495. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83496. comparisonFunction?: number;
  83497. /** Specifies if the created texture is a cube texture */
  83498. isCube?: boolean;
  83499. }
  83500. /**
  83501. * Class used to describe the capabilities of the engine relatively to the current browser
  83502. */
  83503. export class EngineCapabilities {
  83504. /** Maximum textures units per fragment shader */
  83505. maxTexturesImageUnits: number;
  83506. /** Maximum texture units per vertex shader */
  83507. maxVertexTextureImageUnits: number;
  83508. /** Maximum textures units in the entire pipeline */
  83509. maxCombinedTexturesImageUnits: number;
  83510. /** Maximum texture size */
  83511. maxTextureSize: number;
  83512. /** Maximum cube texture size */
  83513. maxCubemapTextureSize: number;
  83514. /** Maximum render texture size */
  83515. maxRenderTextureSize: number;
  83516. /** Maximum number of vertex attributes */
  83517. maxVertexAttribs: number;
  83518. /** Maximum number of varyings */
  83519. maxVaryingVectors: number;
  83520. /** Maximum number of uniforms per vertex shader */
  83521. maxVertexUniformVectors: number;
  83522. /** Maximum number of uniforms per fragment shader */
  83523. maxFragmentUniformVectors: number;
  83524. /** Defines if standard derivates (dx/dy) are supported */
  83525. standardDerivatives: boolean;
  83526. /** Defines if s3tc texture compression is supported */
  83527. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  83528. /** Defines if pvrtc texture compression is supported */
  83529. pvrtc: any;
  83530. /** Defines if etc1 texture compression is supported */
  83531. etc1: any;
  83532. /** Defines if etc2 texture compression is supported */
  83533. etc2: any;
  83534. /** Defines if astc texture compression is supported */
  83535. astc: any;
  83536. /** Defines if float textures are supported */
  83537. textureFloat: boolean;
  83538. /** Defines if vertex array objects are supported */
  83539. vertexArrayObject: boolean;
  83540. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  83541. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  83542. /** Gets the maximum level of anisotropy supported */
  83543. maxAnisotropy: number;
  83544. /** Defines if instancing is supported */
  83545. instancedArrays: boolean;
  83546. /** Defines if 32 bits indices are supported */
  83547. uintIndices: boolean;
  83548. /** Defines if high precision shaders are supported */
  83549. highPrecisionShaderSupported: boolean;
  83550. /** Defines if depth reading in the fragment shader is supported */
  83551. fragmentDepthSupported: boolean;
  83552. /** Defines if float texture linear filtering is supported*/
  83553. textureFloatLinearFiltering: boolean;
  83554. /** Defines if rendering to float textures is supported */
  83555. textureFloatRender: boolean;
  83556. /** Defines if half float textures are supported*/
  83557. textureHalfFloat: boolean;
  83558. /** Defines if half float texture linear filtering is supported*/
  83559. textureHalfFloatLinearFiltering: boolean;
  83560. /** Defines if rendering to half float textures is supported */
  83561. textureHalfFloatRender: boolean;
  83562. /** Defines if textureLOD shader command is supported */
  83563. textureLOD: boolean;
  83564. /** Defines if draw buffers extension is supported */
  83565. drawBuffersExtension: boolean;
  83566. /** Defines if depth textures are supported */
  83567. depthTextureExtension: boolean;
  83568. /** Defines if float color buffer are supported */
  83569. colorBufferFloat: boolean;
  83570. /** Gets disjoint timer query extension (null if not supported) */
  83571. timerQuery: EXT_disjoint_timer_query;
  83572. /** Defines if timestamp can be used with timer query */
  83573. canUseTimestampForTimerQuery: boolean;
  83574. /** Function used to let the system compiles shaders in background */
  83575. parallelShaderCompile: {
  83576. MAX_SHADER_COMPILER_THREADS_KHR: number;
  83577. maxShaderCompilerThreadsKHR: (thread: number) => void;
  83578. COMPLETION_STATUS_KHR: number;
  83579. };
  83580. }
  83581. /** Interface defining initialization parameters for Engine class */
  83582. export interface EngineOptions extends WebGLContextAttributes {
  83583. /**
  83584. * Defines if the engine should no exceed a specified device ratio
  83585. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  83586. */
  83587. limitDeviceRatio?: number;
  83588. /**
  83589. * Defines if webvr should be enabled automatically
  83590. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83591. */
  83592. autoEnableWebVR?: boolean;
  83593. /**
  83594. * Defines if webgl2 should be turned off even if supported
  83595. * @see http://doc.babylonjs.com/features/webgl2
  83596. */
  83597. disableWebGL2Support?: boolean;
  83598. /**
  83599. * Defines if webaudio should be initialized as well
  83600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83601. */
  83602. audioEngine?: boolean;
  83603. /**
  83604. * Defines if animations should run using a deterministic lock step
  83605. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83606. */
  83607. deterministicLockstep?: boolean;
  83608. /** Defines the maximum steps to use with deterministic lock step mode */
  83609. lockstepMaxSteps?: number;
  83610. /**
  83611. * Defines that engine should ignore context lost events
  83612. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  83613. */
  83614. doNotHandleContextLost?: boolean;
  83615. /**
  83616. * Defines that engine should ignore modifying touch action attribute and style
  83617. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  83618. */
  83619. doNotHandleTouchAction?: boolean;
  83620. }
  83621. /**
  83622. * Defines the interface used by display changed events
  83623. */
  83624. export interface IDisplayChangedEventArgs {
  83625. /** Gets the vrDisplay object (if any) */
  83626. vrDisplay: Nullable<any>;
  83627. /** Gets a boolean indicating if webVR is supported */
  83628. vrSupported: boolean;
  83629. }
  83630. /**
  83631. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  83632. */
  83633. export class Engine {
  83634. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  83635. static ExceptionList: ({
  83636. key: string;
  83637. capture: string;
  83638. captureConstraint: number;
  83639. targets: string[];
  83640. } | {
  83641. key: string;
  83642. capture: null;
  83643. captureConstraint: null;
  83644. targets: string[];
  83645. })[];
  83646. /** Gets the list of created engines */
  83647. static readonly Instances: Engine[];
  83648. /**
  83649. * Gets the latest created engine
  83650. */
  83651. static readonly LastCreatedEngine: Nullable<Engine>;
  83652. /**
  83653. * Gets the latest created scene
  83654. */
  83655. static readonly LastCreatedScene: Nullable<Scene>;
  83656. /**
  83657. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  83658. * @param flag defines which part of the materials must be marked as dirty
  83659. * @param predicate defines a predicate used to filter which materials should be affected
  83660. */
  83661. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  83662. /**
  83663. * Hidden
  83664. */
  83665. static _TextureLoaders: IInternalTextureLoader[];
  83666. /** Defines that alpha blending is disabled */
  83667. static readonly ALPHA_DISABLE: number;
  83668. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  83669. static readonly ALPHA_ADD: number;
  83670. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  83671. static readonly ALPHA_COMBINE: number;
  83672. /** Defines that alpha blending to DEST - SRC * DEST */
  83673. static readonly ALPHA_SUBTRACT: number;
  83674. /** Defines that alpha blending to SRC * DEST */
  83675. static readonly ALPHA_MULTIPLY: number;
  83676. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  83677. static readonly ALPHA_MAXIMIZED: number;
  83678. /** Defines that alpha blending to SRC + DEST */
  83679. static readonly ALPHA_ONEONE: number;
  83680. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  83681. static readonly ALPHA_PREMULTIPLIED: number;
  83682. /**
  83683. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  83684. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  83685. */
  83686. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  83687. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  83688. static readonly ALPHA_INTERPOLATE: number;
  83689. /**
  83690. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  83691. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  83692. */
  83693. static readonly ALPHA_SCREENMODE: number;
  83694. /** Defines that the ressource is not delayed*/
  83695. static readonly DELAYLOADSTATE_NONE: number;
  83696. /** Defines that the ressource was successfully delay loaded */
  83697. static readonly DELAYLOADSTATE_LOADED: number;
  83698. /** Defines that the ressource is currently delay loading */
  83699. static readonly DELAYLOADSTATE_LOADING: number;
  83700. /** Defines that the ressource is delayed and has not started loading */
  83701. static readonly DELAYLOADSTATE_NOTLOADED: number;
  83702. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  83703. static readonly NEVER: number;
  83704. /** 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 */
  83705. static readonly ALWAYS: number;
  83706. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  83707. static readonly LESS: number;
  83708. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  83709. static readonly EQUAL: number;
  83710. /** 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 */
  83711. static readonly LEQUAL: number;
  83712. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  83713. static readonly GREATER: number;
  83714. /** 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 */
  83715. static readonly GEQUAL: number;
  83716. /** 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 */
  83717. static readonly NOTEQUAL: number;
  83718. /** Passed to stencilOperation to specify that stencil value must be kept */
  83719. static readonly KEEP: number;
  83720. /** Passed to stencilOperation to specify that stencil value must be replaced */
  83721. static readonly REPLACE: number;
  83722. /** Passed to stencilOperation to specify that stencil value must be incremented */
  83723. static readonly INCR: number;
  83724. /** Passed to stencilOperation to specify that stencil value must be decremented */
  83725. static readonly DECR: number;
  83726. /** Passed to stencilOperation to specify that stencil value must be inverted */
  83727. static readonly INVERT: number;
  83728. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  83729. static readonly INCR_WRAP: number;
  83730. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  83731. static readonly DECR_WRAP: number;
  83732. /** Texture is not repeating outside of 0..1 UVs */
  83733. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  83734. /** Texture is repeating outside of 0..1 UVs */
  83735. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  83736. /** Texture is repeating and mirrored */
  83737. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  83738. /** ALPHA */
  83739. static readonly TEXTUREFORMAT_ALPHA: number;
  83740. /** LUMINANCE */
  83741. static readonly TEXTUREFORMAT_LUMINANCE: number;
  83742. /** LUMINANCE_ALPHA */
  83743. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  83744. /** RGB */
  83745. static readonly TEXTUREFORMAT_RGB: number;
  83746. /** RGBA */
  83747. static readonly TEXTUREFORMAT_RGBA: number;
  83748. /** RED */
  83749. static readonly TEXTUREFORMAT_RED: number;
  83750. /** RED (2nd reference) */
  83751. static readonly TEXTUREFORMAT_R: number;
  83752. /** RG */
  83753. static readonly TEXTUREFORMAT_RG: number;
  83754. /** RED_INTEGER */
  83755. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  83756. /** RED_INTEGER (2nd reference) */
  83757. static readonly TEXTUREFORMAT_R_INTEGER: number;
  83758. /** RG_INTEGER */
  83759. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  83760. /** RGB_INTEGER */
  83761. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  83762. /** RGBA_INTEGER */
  83763. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  83764. /** UNSIGNED_BYTE */
  83765. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  83766. /** UNSIGNED_BYTE (2nd reference) */
  83767. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  83768. /** FLOAT */
  83769. static readonly TEXTURETYPE_FLOAT: number;
  83770. /** HALF_FLOAT */
  83771. static readonly TEXTURETYPE_HALF_FLOAT: number;
  83772. /** BYTE */
  83773. static readonly TEXTURETYPE_BYTE: number;
  83774. /** SHORT */
  83775. static readonly TEXTURETYPE_SHORT: number;
  83776. /** UNSIGNED_SHORT */
  83777. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  83778. /** INT */
  83779. static readonly TEXTURETYPE_INT: number;
  83780. /** UNSIGNED_INT */
  83781. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  83782. /** UNSIGNED_SHORT_4_4_4_4 */
  83783. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  83784. /** UNSIGNED_SHORT_5_5_5_1 */
  83785. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  83786. /** UNSIGNED_SHORT_5_6_5 */
  83787. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  83788. /** UNSIGNED_INT_2_10_10_10_REV */
  83789. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  83790. /** UNSIGNED_INT_24_8 */
  83791. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  83792. /** UNSIGNED_INT_10F_11F_11F_REV */
  83793. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  83794. /** UNSIGNED_INT_5_9_9_9_REV */
  83795. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  83796. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  83797. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  83798. /** nearest is mag = nearest and min = nearest and mip = linear */
  83799. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  83800. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83801. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  83802. /** Trilinear is mag = linear and min = linear and mip = linear */
  83803. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  83804. /** nearest is mag = nearest and min = nearest and mip = linear */
  83805. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  83806. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83807. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  83808. /** Trilinear is mag = linear and min = linear and mip = linear */
  83809. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  83810. /** mag = nearest and min = nearest and mip = nearest */
  83811. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  83812. /** mag = nearest and min = linear and mip = nearest */
  83813. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  83814. /** mag = nearest and min = linear and mip = linear */
  83815. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  83816. /** mag = nearest and min = linear and mip = none */
  83817. static readonly TEXTURE_NEAREST_LINEAR: number;
  83818. /** mag = nearest and min = nearest and mip = none */
  83819. static readonly TEXTURE_NEAREST_NEAREST: number;
  83820. /** mag = linear and min = nearest and mip = nearest */
  83821. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  83822. /** mag = linear and min = nearest and mip = linear */
  83823. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  83824. /** mag = linear and min = linear and mip = none */
  83825. static readonly TEXTURE_LINEAR_LINEAR: number;
  83826. /** mag = linear and min = nearest and mip = none */
  83827. static readonly TEXTURE_LINEAR_NEAREST: number;
  83828. /** Explicit coordinates mode */
  83829. static readonly TEXTURE_EXPLICIT_MODE: number;
  83830. /** Spherical coordinates mode */
  83831. static readonly TEXTURE_SPHERICAL_MODE: number;
  83832. /** Planar coordinates mode */
  83833. static readonly TEXTURE_PLANAR_MODE: number;
  83834. /** Cubic coordinates mode */
  83835. static readonly TEXTURE_CUBIC_MODE: number;
  83836. /** Projection coordinates mode */
  83837. static readonly TEXTURE_PROJECTION_MODE: number;
  83838. /** Skybox coordinates mode */
  83839. static readonly TEXTURE_SKYBOX_MODE: number;
  83840. /** Inverse Cubic coordinates mode */
  83841. static readonly TEXTURE_INVCUBIC_MODE: number;
  83842. /** Equirectangular coordinates mode */
  83843. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  83844. /** Equirectangular Fixed coordinates mode */
  83845. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  83846. /** Equirectangular Fixed Mirrored coordinates mode */
  83847. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83848. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  83849. static readonly SCALEMODE_FLOOR: number;
  83850. /** Defines that texture rescaling will look for the nearest power of 2 size */
  83851. static readonly SCALEMODE_NEAREST: number;
  83852. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  83853. static readonly SCALEMODE_CEILING: number;
  83854. /**
  83855. * Returns the current version of the framework
  83856. */
  83857. static readonly Version: string;
  83858. /**
  83859. * Returns a string describing the current engine
  83860. */
  83861. readonly description: string;
  83862. /**
  83863. * Gets or sets the epsilon value used by collision engine
  83864. */
  83865. static CollisionsEpsilon: number;
  83866. /**
  83867. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  83868. */
  83869. static ShadersRepository: string;
  83870. /**
  83871. * Method called to create the default loading screen.
  83872. * This can be overriden in your own app.
  83873. * @param canvas The rendering canvas element
  83874. * @returns The loading screen
  83875. */
  83876. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  83877. /**
  83878. * Method called to create the default rescale post process on each engine.
  83879. */
  83880. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  83881. /**
  83882. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  83883. */
  83884. forcePOTTextures: boolean;
  83885. /**
  83886. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  83887. */
  83888. isFullscreen: boolean;
  83889. /**
  83890. * Gets a boolean indicating if the pointer is currently locked
  83891. */
  83892. isPointerLock: boolean;
  83893. /**
  83894. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  83895. */
  83896. cullBackFaces: boolean;
  83897. /**
  83898. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  83899. */
  83900. renderEvenInBackground: boolean;
  83901. /**
  83902. * Gets or sets a boolean indicating that cache can be kept between frames
  83903. */
  83904. preventCacheWipeBetweenFrames: boolean;
  83905. /**
  83906. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  83907. **/
  83908. enableOfflineSupport: boolean;
  83909. /**
  83910. * 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)
  83911. **/
  83912. disableManifestCheck: boolean;
  83913. /**
  83914. * Gets the list of created scenes
  83915. */
  83916. scenes: Scene[];
  83917. /**
  83918. * Event raised when a new scene is created
  83919. */
  83920. onNewSceneAddedObservable: Observable<Scene>;
  83921. /**
  83922. * Gets the list of created postprocesses
  83923. */
  83924. postProcesses: PostProcess[];
  83925. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  83926. validateShaderPrograms: boolean;
  83927. /**
  83928. * Observable event triggered each time the rendering canvas is resized
  83929. */
  83930. onResizeObservable: Observable<Engine>;
  83931. /**
  83932. * Observable event triggered each time the canvas loses focus
  83933. */
  83934. onCanvasBlurObservable: Observable<Engine>;
  83935. /**
  83936. * Observable event triggered each time the canvas gains focus
  83937. */
  83938. onCanvasFocusObservable: Observable<Engine>;
  83939. /**
  83940. * Observable event triggered each time the canvas receives pointerout event
  83941. */
  83942. onCanvasPointerOutObservable: Observable<PointerEvent>;
  83943. /**
  83944. * Observable event triggered before each texture is initialized
  83945. */
  83946. onBeforeTextureInitObservable: Observable<Texture>;
  83947. private _vrDisplay;
  83948. private _vrSupported;
  83949. private _oldSize;
  83950. private _oldHardwareScaleFactor;
  83951. private _vrExclusivePointerMode;
  83952. private _webVRInitPromise;
  83953. /**
  83954. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83955. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83956. */
  83957. readonly isInVRExclusivePointerMode: boolean;
  83958. /**
  83959. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  83960. */
  83961. disableUniformBuffers: boolean;
  83962. /** @hidden */
  83963. _uniformBuffers: UniformBuffer[];
  83964. /**
  83965. * Gets a boolean indicating that the engine supports uniform buffers
  83966. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83967. */
  83968. readonly supportsUniformBuffers: boolean;
  83969. /**
  83970. * Observable raised when the engine begins a new frame
  83971. */
  83972. onBeginFrameObservable: Observable<Engine>;
  83973. /**
  83974. * If set, will be used to request the next animation frame for the render loop
  83975. */
  83976. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  83977. /**
  83978. * Observable raised when the engine ends the current frame
  83979. */
  83980. onEndFrameObservable: Observable<Engine>;
  83981. /**
  83982. * Observable raised when the engine is about to compile a shader
  83983. */
  83984. onBeforeShaderCompilationObservable: Observable<Engine>;
  83985. /**
  83986. * Observable raised when the engine has jsut compiled a shader
  83987. */
  83988. onAfterShaderCompilationObservable: Observable<Engine>;
  83989. /** @hidden */
  83990. _gl: WebGLRenderingContext;
  83991. private _renderingCanvas;
  83992. private _windowIsBackground;
  83993. private _webGLVersion;
  83994. /**
  83995. * Gets a boolean indicating that only power of 2 textures are supported
  83996. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  83997. */
  83998. readonly needPOTTextures: boolean;
  83999. /** @hidden */
  84000. _badOS: boolean;
  84001. /** @hidden */
  84002. _badDesktopOS: boolean;
  84003. /**
  84004. * Gets or sets a value indicating if we want to disable texture binding optimization.
  84005. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  84006. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  84007. */
  84008. disableTextureBindingOptimization: boolean;
  84009. /**
  84010. * Gets the audio engine
  84011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84012. * @ignorenaming
  84013. */
  84014. static audioEngine: IAudioEngine;
  84015. /**
  84016. * Default AudioEngine factory responsible of creating the Audio Engine.
  84017. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  84018. */
  84019. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  84020. /**
  84021. * Default offline support factory responsible of creating a tool used to store data locally.
  84022. * By default, this will create a Database object if the workload has been embedded.
  84023. */
  84024. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  84025. private _onFocus;
  84026. private _onBlur;
  84027. private _onCanvasPointerOut;
  84028. private _onCanvasBlur;
  84029. private _onCanvasFocus;
  84030. private _onFullscreenChange;
  84031. private _onPointerLockChange;
  84032. private _onVRDisplayPointerRestricted;
  84033. private _onVRDisplayPointerUnrestricted;
  84034. private _onVrDisplayConnect;
  84035. private _onVrDisplayDisconnect;
  84036. private _onVrDisplayPresentChange;
  84037. /**
  84038. * Observable signaled when VR display mode changes
  84039. */
  84040. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84041. /**
  84042. * Observable signaled when VR request present is complete
  84043. */
  84044. onVRRequestPresentComplete: Observable<boolean>;
  84045. /**
  84046. * Observable signaled when VR request present starts
  84047. */
  84048. onVRRequestPresentStart: Observable<Engine>;
  84049. private _hardwareScalingLevel;
  84050. /** @hidden */
  84051. protected _caps: EngineCapabilities;
  84052. private _pointerLockRequested;
  84053. private _isStencilEnable;
  84054. private _colorWrite;
  84055. private _loadingScreen;
  84056. /** @hidden */
  84057. _drawCalls: PerfCounter;
  84058. /** @hidden */
  84059. _textureCollisions: PerfCounter;
  84060. private _glVersion;
  84061. private _glRenderer;
  84062. private _glVendor;
  84063. private _videoTextureSupported;
  84064. private _renderingQueueLaunched;
  84065. private _activeRenderLoops;
  84066. private _deterministicLockstep;
  84067. private _lockstepMaxSteps;
  84068. /**
  84069. * Observable signaled when a context lost event is raised
  84070. */
  84071. onContextLostObservable: Observable<Engine>;
  84072. /**
  84073. * Observable signaled when a context restored event is raised
  84074. */
  84075. onContextRestoredObservable: Observable<Engine>;
  84076. private _onContextLost;
  84077. private _onContextRestored;
  84078. private _contextWasLost;
  84079. private _doNotHandleContextLost;
  84080. /**
  84081. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84082. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84083. */
  84084. doNotHandleContextLost: boolean;
  84085. private _performanceMonitor;
  84086. private _fps;
  84087. private _deltaTime;
  84088. /**
  84089. * Turn this value on if you want to pause FPS computation when in background
  84090. */
  84091. disablePerformanceMonitorInBackground: boolean;
  84092. /**
  84093. * Gets the performance monitor attached to this engine
  84094. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84095. */
  84096. readonly performanceMonitor: PerformanceMonitor;
  84097. /** @hidden */
  84098. protected _depthCullingState: _DepthCullingState;
  84099. /** @hidden */
  84100. protected _stencilState: _StencilState;
  84101. /** @hidden */
  84102. protected _alphaState: _AlphaState;
  84103. /** @hidden */
  84104. protected _alphaMode: number;
  84105. protected _internalTexturesCache: InternalTexture[];
  84106. /** @hidden */
  84107. protected _activeChannel: number;
  84108. private _currentTextureChannel;
  84109. /** @hidden */
  84110. protected _boundTexturesCache: {
  84111. [key: string]: Nullable<InternalTexture>;
  84112. };
  84113. /** @hidden */
  84114. protected _currentEffect: Nullable<Effect>;
  84115. /** @hidden */
  84116. protected _currentProgram: Nullable<WebGLProgram>;
  84117. private _compiledEffects;
  84118. private _vertexAttribArraysEnabled;
  84119. /** @hidden */
  84120. protected _cachedViewport: Nullable<Viewport>;
  84121. private _cachedVertexArrayObject;
  84122. /** @hidden */
  84123. protected _cachedVertexBuffers: any;
  84124. /** @hidden */
  84125. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84126. /** @hidden */
  84127. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84128. /** @hidden */
  84129. protected _currentRenderTarget: Nullable<InternalTexture>;
  84130. private _uintIndicesCurrentlySet;
  84131. private _currentBoundBuffer;
  84132. /** @hidden */
  84133. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84134. private _currentBufferPointers;
  84135. private _currentInstanceLocations;
  84136. private _currentInstanceBuffers;
  84137. private _textureUnits;
  84138. private _firstBoundInternalTextureTracker;
  84139. private _lastBoundInternalTextureTracker;
  84140. private _workingCanvas;
  84141. private _workingContext;
  84142. private _rescalePostProcess;
  84143. private _dummyFramebuffer;
  84144. private _externalData;
  84145. private _bindedRenderFunction;
  84146. private _vaoRecordInProgress;
  84147. private _mustWipeVertexAttributes;
  84148. private _emptyTexture;
  84149. private _emptyCubeTexture;
  84150. private _emptyTexture3D;
  84151. /** @hidden */
  84152. _frameHandler: number;
  84153. private _nextFreeTextureSlots;
  84154. private _maxSimultaneousTextures;
  84155. private _activeRequests;
  84156. private _texturesSupported;
  84157. private _textureFormatInUse;
  84158. /**
  84159. * Gets the list of texture formats supported
  84160. */
  84161. readonly texturesSupported: Array<string>;
  84162. /**
  84163. * Gets the list of texture formats in use
  84164. */
  84165. readonly textureFormatInUse: Nullable<string>;
  84166. /**
  84167. * Gets the current viewport
  84168. */
  84169. readonly currentViewport: Nullable<Viewport>;
  84170. /**
  84171. * Gets the default empty texture
  84172. */
  84173. readonly emptyTexture: InternalTexture;
  84174. /**
  84175. * Gets the default empty 3D texture
  84176. */
  84177. readonly emptyTexture3D: InternalTexture;
  84178. /**
  84179. * Gets the default empty cube texture
  84180. */
  84181. readonly emptyCubeTexture: InternalTexture;
  84182. /**
  84183. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84184. */
  84185. readonly premultipliedAlpha: boolean;
  84186. /**
  84187. * Creates a new engine
  84188. * @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
  84189. * @param antialias defines enable antialiasing (default: false)
  84190. * @param options defines further options to be sent to the getContext() function
  84191. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84192. */
  84193. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84194. private _disableTouchAction;
  84195. private _rebuildInternalTextures;
  84196. private _rebuildEffects;
  84197. /**
  84198. * Gets a boolean indicating if all created effects are ready
  84199. * @returns true if all effects are ready
  84200. */
  84201. areAllEffectsReady(): boolean;
  84202. private _rebuildBuffers;
  84203. private _initGLContext;
  84204. /**
  84205. * Gets version of the current webGL context
  84206. */
  84207. readonly webGLVersion: number;
  84208. /**
  84209. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84210. */
  84211. readonly isStencilEnable: boolean;
  84212. private _prepareWorkingCanvas;
  84213. /**
  84214. * Reset the texture cache to empty state
  84215. */
  84216. resetTextureCache(): void;
  84217. /**
  84218. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84219. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84220. * @returns true if engine is in deterministic lock step mode
  84221. */
  84222. isDeterministicLockStep(): boolean;
  84223. /**
  84224. * Gets the max steps when engine is running in deterministic lock step
  84225. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84226. * @returns the max steps
  84227. */
  84228. getLockstepMaxSteps(): number;
  84229. /**
  84230. * Gets an object containing information about the current webGL context
  84231. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84232. */
  84233. getGlInfo(): {
  84234. vendor: string;
  84235. renderer: string;
  84236. version: string;
  84237. };
  84238. /**
  84239. * Gets current aspect ratio
  84240. * @param camera defines the camera to use to get the aspect ratio
  84241. * @param useScreen defines if screen size must be used (or the current render target if any)
  84242. * @returns a number defining the aspect ratio
  84243. */
  84244. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84245. /**
  84246. * Gets current screen aspect ratio
  84247. * @returns a number defining the aspect ratio
  84248. */
  84249. getScreenAspectRatio(): number;
  84250. /**
  84251. * Gets the current render width
  84252. * @param useScreen defines if screen size must be used (or the current render target if any)
  84253. * @returns a number defining the current render width
  84254. */
  84255. getRenderWidth(useScreen?: boolean): number;
  84256. /**
  84257. * Gets the current render height
  84258. * @param useScreen defines if screen size must be used (or the current render target if any)
  84259. * @returns a number defining the current render height
  84260. */
  84261. getRenderHeight(useScreen?: boolean): number;
  84262. /**
  84263. * Gets the HTML canvas attached with the current webGL context
  84264. * @returns a HTML canvas
  84265. */
  84266. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84267. /**
  84268. * Gets the client rect of the HTML canvas attached with the current webGL context
  84269. * @returns a client rectanglee
  84270. */
  84271. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84272. /**
  84273. * Defines the hardware scaling level.
  84274. * By default the hardware scaling level is computed from the window device ratio.
  84275. * 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.
  84276. * @param level defines the level to use
  84277. */
  84278. setHardwareScalingLevel(level: number): void;
  84279. /**
  84280. * Gets the current hardware scaling level.
  84281. * By default the hardware scaling level is computed from the window device ratio.
  84282. * 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.
  84283. * @returns a number indicating the current hardware scaling level
  84284. */
  84285. getHardwareScalingLevel(): number;
  84286. /**
  84287. * Gets the list of loaded textures
  84288. * @returns an array containing all loaded textures
  84289. */
  84290. getLoadedTexturesCache(): InternalTexture[];
  84291. /**
  84292. * Gets the object containing all engine capabilities
  84293. * @returns the EngineCapabilities object
  84294. */
  84295. getCaps(): EngineCapabilities;
  84296. /**
  84297. * Gets the current depth function
  84298. * @returns a number defining the depth function
  84299. */
  84300. getDepthFunction(): Nullable<number>;
  84301. /**
  84302. * Sets the current depth function
  84303. * @param depthFunc defines the function to use
  84304. */
  84305. setDepthFunction(depthFunc: number): void;
  84306. /**
  84307. * Sets the current depth function to GREATER
  84308. */
  84309. setDepthFunctionToGreater(): void;
  84310. /**
  84311. * Sets the current depth function to GEQUAL
  84312. */
  84313. setDepthFunctionToGreaterOrEqual(): void;
  84314. /**
  84315. * Sets the current depth function to LESS
  84316. */
  84317. setDepthFunctionToLess(): void;
  84318. /**
  84319. * Sets the current depth function to LEQUAL
  84320. */
  84321. setDepthFunctionToLessOrEqual(): void;
  84322. /**
  84323. * Gets a boolean indicating if stencil buffer is enabled
  84324. * @returns the current stencil buffer state
  84325. */
  84326. getStencilBuffer(): boolean;
  84327. /**
  84328. * Enable or disable the stencil buffer
  84329. * @param enable defines if the stencil buffer must be enabled or disabled
  84330. */
  84331. setStencilBuffer(enable: boolean): void;
  84332. /**
  84333. * Gets the current stencil mask
  84334. * @returns a number defining the new stencil mask to use
  84335. */
  84336. getStencilMask(): number;
  84337. /**
  84338. * Sets the current stencil mask
  84339. * @param mask defines the new stencil mask to use
  84340. */
  84341. setStencilMask(mask: number): void;
  84342. /**
  84343. * Gets the current stencil function
  84344. * @returns a number defining the stencil function to use
  84345. */
  84346. getStencilFunction(): number;
  84347. /**
  84348. * Gets the current stencil reference value
  84349. * @returns a number defining the stencil reference value to use
  84350. */
  84351. getStencilFunctionReference(): number;
  84352. /**
  84353. * Gets the current stencil mask
  84354. * @returns a number defining the stencil mask to use
  84355. */
  84356. getStencilFunctionMask(): number;
  84357. /**
  84358. * Sets the current stencil function
  84359. * @param stencilFunc defines the new stencil function to use
  84360. */
  84361. setStencilFunction(stencilFunc: number): void;
  84362. /**
  84363. * Sets the current stencil reference
  84364. * @param reference defines the new stencil reference to use
  84365. */
  84366. setStencilFunctionReference(reference: number): void;
  84367. /**
  84368. * Sets the current stencil mask
  84369. * @param mask defines the new stencil mask to use
  84370. */
  84371. setStencilFunctionMask(mask: number): void;
  84372. /**
  84373. * Gets the current stencil operation when stencil fails
  84374. * @returns a number defining stencil operation to use when stencil fails
  84375. */
  84376. getStencilOperationFail(): number;
  84377. /**
  84378. * Gets the current stencil operation when depth fails
  84379. * @returns a number defining stencil operation to use when depth fails
  84380. */
  84381. getStencilOperationDepthFail(): number;
  84382. /**
  84383. * Gets the current stencil operation when stencil passes
  84384. * @returns a number defining stencil operation to use when stencil passes
  84385. */
  84386. getStencilOperationPass(): number;
  84387. /**
  84388. * Sets the stencil operation to use when stencil fails
  84389. * @param operation defines the stencil operation to use when stencil fails
  84390. */
  84391. setStencilOperationFail(operation: number): void;
  84392. /**
  84393. * Sets the stencil operation to use when depth fails
  84394. * @param operation defines the stencil operation to use when depth fails
  84395. */
  84396. setStencilOperationDepthFail(operation: number): void;
  84397. /**
  84398. * Sets the stencil operation to use when stencil passes
  84399. * @param operation defines the stencil operation to use when stencil passes
  84400. */
  84401. setStencilOperationPass(operation: number): void;
  84402. /**
  84403. * Sets a boolean indicating if the dithering state is enabled or disabled
  84404. * @param value defines the dithering state
  84405. */
  84406. setDitheringState(value: boolean): void;
  84407. /**
  84408. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  84409. * @param value defines the rasterizer state
  84410. */
  84411. setRasterizerState(value: boolean): void;
  84412. /**
  84413. * stop executing a render loop function and remove it from the execution array
  84414. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  84415. */
  84416. stopRenderLoop(renderFunction?: () => void): void;
  84417. /** @hidden */
  84418. _renderLoop(): void;
  84419. /**
  84420. * Register and execute a render loop. The engine can have more than one render function
  84421. * @param renderFunction defines the function to continuously execute
  84422. */
  84423. runRenderLoop(renderFunction: () => void): void;
  84424. /**
  84425. * Toggle full screen mode
  84426. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84427. */
  84428. switchFullscreen(requestPointerLock: boolean): void;
  84429. /**
  84430. * Enters full screen mode
  84431. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84432. */
  84433. enterFullscreen(requestPointerLock: boolean): void;
  84434. /**
  84435. * Exits full screen mode
  84436. */
  84437. exitFullscreen(): void;
  84438. /**
  84439. * Clear the current render buffer or the current render target (if any is set up)
  84440. * @param color defines the color to use
  84441. * @param backBuffer defines if the back buffer must be cleared
  84442. * @param depth defines if the depth buffer must be cleared
  84443. * @param stencil defines if the stencil buffer must be cleared
  84444. */
  84445. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  84446. /**
  84447. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  84448. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84449. * @param y defines the y-coordinate of the corner of the clear rectangle
  84450. * @param width defines the width of the clear rectangle
  84451. * @param height defines the height of the clear rectangle
  84452. * @param clearColor defines the clear color
  84453. */
  84454. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  84455. /**
  84456. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  84457. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84458. * @param y defines the y-coordinate of the corner of the clear rectangle
  84459. * @param width defines the width of the clear rectangle
  84460. * @param height defines the height of the clear rectangle
  84461. */
  84462. enableScissor(x: number, y: number, width: number, height: number): void;
  84463. /**
  84464. * Disable previously set scissor test rectangle
  84465. */
  84466. disableScissor(): void;
  84467. private _viewportCached;
  84468. /** @hidden */
  84469. _viewport(x: number, y: number, width: number, height: number): void;
  84470. /**
  84471. * Set the WebGL's viewport
  84472. * @param viewport defines the viewport element to be used
  84473. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  84474. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  84475. */
  84476. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  84477. /**
  84478. * Directly set the WebGL Viewport
  84479. * @param x defines the x coordinate of the viewport (in screen space)
  84480. * @param y defines the y coordinate of the viewport (in screen space)
  84481. * @param width defines the width of the viewport (in screen space)
  84482. * @param height defines the height of the viewport (in screen space)
  84483. * @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
  84484. */
  84485. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  84486. /**
  84487. * Begin a new frame
  84488. */
  84489. beginFrame(): void;
  84490. /**
  84491. * Enf the current frame
  84492. */
  84493. endFrame(): void;
  84494. /**
  84495. * Resize the view according to the canvas' size
  84496. */
  84497. resize(): void;
  84498. /**
  84499. * Force a specific size of the canvas
  84500. * @param width defines the new canvas' width
  84501. * @param height defines the new canvas' height
  84502. */
  84503. setSize(width: number, height: number): void;
  84504. /**
  84505. * Gets a boolean indicating if a webVR device was detected
  84506. * @returns true if a webVR device was detected
  84507. */
  84508. isVRDevicePresent(): boolean;
  84509. /**
  84510. * Gets the current webVR device
  84511. * @returns the current webVR device (or null)
  84512. */
  84513. getVRDevice(): any;
  84514. /**
  84515. * Initializes a webVR display and starts listening to display change events
  84516. * The onVRDisplayChangedObservable will be notified upon these changes
  84517. * @returns The onVRDisplayChangedObservable
  84518. */
  84519. initWebVR(): Observable<IDisplayChangedEventArgs>;
  84520. /**
  84521. * Initializes a webVR display and starts listening to display change events
  84522. * The onVRDisplayChangedObservable will be notified upon these changes
  84523. * @returns A promise containing a VRDisplay and if vr is supported
  84524. */
  84525. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84526. /**
  84527. * Call this function to switch to webVR mode
  84528. * Will do nothing if webVR is not supported or if there is no webVR device
  84529. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84530. */
  84531. enableVR(): void;
  84532. /**
  84533. * Call this function to leave webVR mode
  84534. * Will do nothing if webVR is not supported or if there is no webVR device
  84535. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84536. */
  84537. disableVR(): void;
  84538. private _onVRFullScreenTriggered;
  84539. private _getVRDisplaysAsync;
  84540. /**
  84541. * Binds the frame buffer to the specified texture.
  84542. * @param texture The texture to render to or null for the default canvas
  84543. * @param faceIndex The face of the texture to render to in case of cube texture
  84544. * @param requiredWidth The width of the target to render to
  84545. * @param requiredHeight The height of the target to render to
  84546. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  84547. * @param depthStencilTexture The depth stencil texture to use to render
  84548. * @param lodLevel defines le lod level to bind to the frame buffer
  84549. */
  84550. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  84551. private bindUnboundFramebuffer;
  84552. /**
  84553. * Unbind the current render target texture from the webGL context
  84554. * @param texture defines the render target texture to unbind
  84555. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84556. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84557. */
  84558. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84559. /**
  84560. * Unbind a list of render target textures from the webGL context
  84561. * This is used only when drawBuffer extension or webGL2 are active
  84562. * @param textures defines the render target textures to unbind
  84563. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84564. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84565. */
  84566. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84567. /**
  84568. * Force the mipmap generation for the given render target texture
  84569. * @param texture defines the render target texture to use
  84570. */
  84571. generateMipMapsForCubemap(texture: InternalTexture): void;
  84572. /**
  84573. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  84574. */
  84575. flushFramebuffer(): void;
  84576. /**
  84577. * Unbind the current render target and bind the default framebuffer
  84578. */
  84579. restoreDefaultFramebuffer(): void;
  84580. /**
  84581. * Create an uniform buffer
  84582. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84583. * @param elements defines the content of the uniform buffer
  84584. * @returns the webGL uniform buffer
  84585. */
  84586. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  84587. /**
  84588. * Create a dynamic uniform buffer
  84589. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84590. * @param elements defines the content of the uniform buffer
  84591. * @returns the webGL uniform buffer
  84592. */
  84593. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  84594. /**
  84595. * Update an existing uniform buffer
  84596. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84597. * @param uniformBuffer defines the target uniform buffer
  84598. * @param elements defines the content to update
  84599. * @param offset defines the offset in the uniform buffer where update should start
  84600. * @param count defines the size of the data to update
  84601. */
  84602. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84603. private _resetVertexBufferBinding;
  84604. /**
  84605. * Creates a vertex buffer
  84606. * @param data the data for the vertex buffer
  84607. * @returns the new WebGL static buffer
  84608. */
  84609. createVertexBuffer(data: DataArray): WebGLBuffer;
  84610. /**
  84611. * Creates a dynamic vertex buffer
  84612. * @param data the data for the dynamic vertex buffer
  84613. * @returns the new WebGL dynamic buffer
  84614. */
  84615. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  84616. /**
  84617. * Update a dynamic index buffer
  84618. * @param indexBuffer defines the target index buffer
  84619. * @param indices defines the data to update
  84620. * @param offset defines the offset in the target index buffer where update should start
  84621. */
  84622. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  84623. /**
  84624. * Updates a dynamic vertex buffer.
  84625. * @param vertexBuffer the vertex buffer to update
  84626. * @param data the data used to update the vertex buffer
  84627. * @param byteOffset the byte offset of the data
  84628. * @param byteLength the byte length of the data
  84629. */
  84630. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  84631. private _resetIndexBufferBinding;
  84632. /**
  84633. * Creates a new index buffer
  84634. * @param indices defines the content of the index buffer
  84635. * @param updatable defines if the index buffer must be updatable
  84636. * @returns a new webGL buffer
  84637. */
  84638. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  84639. /**
  84640. * Bind a webGL buffer to the webGL context
  84641. * @param buffer defines the buffer to bind
  84642. */
  84643. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  84644. /**
  84645. * Bind an uniform buffer to the current webGL context
  84646. * @param buffer defines the buffer to bind
  84647. */
  84648. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  84649. /**
  84650. * Bind a buffer to the current webGL context at a given location
  84651. * @param buffer defines the buffer to bind
  84652. * @param location defines the index where to bind the buffer
  84653. */
  84654. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  84655. /**
  84656. * Bind a specific block at a given index in a specific shader program
  84657. * @param shaderProgram defines the shader program
  84658. * @param blockName defines the block name
  84659. * @param index defines the index where to bind the block
  84660. */
  84661. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  84662. private bindIndexBuffer;
  84663. private bindBuffer;
  84664. /**
  84665. * update the bound buffer with the given data
  84666. * @param data defines the data to update
  84667. */
  84668. updateArrayBuffer(data: Float32Array): void;
  84669. private _vertexAttribPointer;
  84670. private _bindIndexBufferWithCache;
  84671. private _bindVertexBuffersAttributes;
  84672. /**
  84673. * Records a vertex array object
  84674. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84675. * @param vertexBuffers defines the list of vertex buffers to store
  84676. * @param indexBuffer defines the index buffer to store
  84677. * @param effect defines the effect to store
  84678. * @returns the new vertex array object
  84679. */
  84680. recordVertexArrayObject(vertexBuffers: {
  84681. [key: string]: VertexBuffer;
  84682. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  84683. /**
  84684. * Bind a specific vertex array object
  84685. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84686. * @param vertexArrayObject defines the vertex array object to bind
  84687. * @param indexBuffer defines the index buffer to bind
  84688. */
  84689. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  84690. /**
  84691. * Bind webGl buffers directly to the webGL context
  84692. * @param vertexBuffer defines the vertex buffer to bind
  84693. * @param indexBuffer defines the index buffer to bind
  84694. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  84695. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  84696. * @param effect defines the effect associated with the vertex buffer
  84697. */
  84698. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  84699. private _unbindVertexArrayObject;
  84700. /**
  84701. * Bind a list of vertex buffers to the webGL context
  84702. * @param vertexBuffers defines the list of vertex buffers to bind
  84703. * @param indexBuffer defines the index buffer to bind
  84704. * @param effect defines the effect associated with the vertex buffers
  84705. */
  84706. bindBuffers(vertexBuffers: {
  84707. [key: string]: Nullable<VertexBuffer>;
  84708. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  84709. /**
  84710. * Unbind all instance attributes
  84711. */
  84712. unbindInstanceAttributes(): void;
  84713. /**
  84714. * Release and free the memory of a vertex array object
  84715. * @param vao defines the vertex array object to delete
  84716. */
  84717. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  84718. /** @hidden */
  84719. _releaseBuffer(buffer: WebGLBuffer): boolean;
  84720. /**
  84721. * Creates a webGL buffer to use with instanciation
  84722. * @param capacity defines the size of the buffer
  84723. * @returns the webGL buffer
  84724. */
  84725. createInstancesBuffer(capacity: number): WebGLBuffer;
  84726. /**
  84727. * Delete a webGL buffer used with instanciation
  84728. * @param buffer defines the webGL buffer to delete
  84729. */
  84730. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  84731. /**
  84732. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  84733. * @param instancesBuffer defines the webGL buffer to update and bind
  84734. * @param data defines the data to store in the buffer
  84735. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  84736. */
  84737. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  84738. /**
  84739. * Apply all cached states (depth, culling, stencil and alpha)
  84740. */
  84741. applyStates(): void;
  84742. /**
  84743. * Send a draw order
  84744. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84745. * @param indexStart defines the starting index
  84746. * @param indexCount defines the number of index to draw
  84747. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84748. */
  84749. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  84750. /**
  84751. * Draw a list of points
  84752. * @param verticesStart defines the index of first vertex to draw
  84753. * @param verticesCount defines the count of vertices to draw
  84754. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84755. */
  84756. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84757. /**
  84758. * Draw a list of unindexed primitives
  84759. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84760. * @param verticesStart defines the index of first vertex to draw
  84761. * @param verticesCount defines the count of vertices to draw
  84762. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84763. */
  84764. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84765. /**
  84766. * Draw a list of indexed primitives
  84767. * @param fillMode defines the primitive to use
  84768. * @param indexStart defines the starting index
  84769. * @param indexCount defines the number of index to draw
  84770. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84771. */
  84772. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  84773. /**
  84774. * Draw a list of unindexed primitives
  84775. * @param fillMode defines the primitive to use
  84776. * @param verticesStart defines the index of first vertex to draw
  84777. * @param verticesCount defines the count of vertices to draw
  84778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84779. */
  84780. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84781. private _drawMode;
  84782. /** @hidden */
  84783. _releaseEffect(effect: Effect): void;
  84784. /** @hidden */
  84785. _deleteProgram(program: WebGLProgram): void;
  84786. /**
  84787. * Create a new effect (used to store vertex/fragment shaders)
  84788. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  84789. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  84790. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  84791. * @param samplers defines an array of string used to represent textures
  84792. * @param defines defines the string containing the defines to use to compile the shaders
  84793. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  84794. * @param onCompiled defines a function to call when the effect creation is successful
  84795. * @param onError defines a function to call when the effect creation has failed
  84796. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  84797. * @returns the new Effect
  84798. */
  84799. 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;
  84800. private _compileShader;
  84801. private _compileRawShader;
  84802. /**
  84803. * Directly creates a webGL program
  84804. * @param vertexCode defines the vertex shader code to use
  84805. * @param fragmentCode defines the fragment shader code to use
  84806. * @param context defines the webGL context to use (if not set, the current one will be used)
  84807. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84808. * @returns the new webGL program
  84809. */
  84810. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84811. /**
  84812. * Creates a webGL program
  84813. * @param vertexCode defines the vertex shader code to use
  84814. * @param fragmentCode defines the fragment shader code to use
  84815. * @param defines defines the string containing the defines to use to compile the shaders
  84816. * @param context defines the webGL context to use (if not set, the current one will be used)
  84817. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84818. * @returns the new webGL program
  84819. */
  84820. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84821. private _createShaderProgram;
  84822. private _finalizeProgram;
  84823. /** @hidden */
  84824. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  84825. /** @hidden */
  84826. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  84827. /**
  84828. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  84829. * @param shaderProgram defines the webGL program to use
  84830. * @param uniformsNames defines the list of uniform names
  84831. * @returns an array of webGL uniform locations
  84832. */
  84833. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  84834. /**
  84835. * Gets the lsit of active attributes for a given webGL program
  84836. * @param shaderProgram defines the webGL program to use
  84837. * @param attributesNames defines the list of attribute names to get
  84838. * @returns an array of indices indicating the offset of each attribute
  84839. */
  84840. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  84841. /**
  84842. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  84843. * @param effect defines the effect to activate
  84844. */
  84845. enableEffect(effect: Nullable<Effect>): void;
  84846. /**
  84847. * Set the value of an uniform to an array of int32
  84848. * @param uniform defines the webGL uniform location where to store the value
  84849. * @param array defines the array of int32 to store
  84850. */
  84851. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84852. /**
  84853. * Set the value of an uniform to an array of int32 (stored as vec2)
  84854. * @param uniform defines the webGL uniform location where to store the value
  84855. * @param array defines the array of int32 to store
  84856. */
  84857. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84858. /**
  84859. * Set the value of an uniform to an array of int32 (stored as vec3)
  84860. * @param uniform defines the webGL uniform location where to store the value
  84861. * @param array defines the array of int32 to store
  84862. */
  84863. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84864. /**
  84865. * Set the value of an uniform to an array of int32 (stored as vec4)
  84866. * @param uniform defines the webGL uniform location where to store the value
  84867. * @param array defines the array of int32 to store
  84868. */
  84869. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84870. /**
  84871. * Set the value of an uniform to an array of float32
  84872. * @param uniform defines the webGL uniform location where to store the value
  84873. * @param array defines the array of float32 to store
  84874. */
  84875. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84876. /**
  84877. * Set the value of an uniform to an array of float32 (stored as vec2)
  84878. * @param uniform defines the webGL uniform location where to store the value
  84879. * @param array defines the array of float32 to store
  84880. */
  84881. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84882. /**
  84883. * Set the value of an uniform to an array of float32 (stored as vec3)
  84884. * @param uniform defines the webGL uniform location where to store the value
  84885. * @param array defines the array of float32 to store
  84886. */
  84887. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84888. /**
  84889. * Set the value of an uniform to an array of float32 (stored as vec4)
  84890. * @param uniform defines the webGL uniform location where to store the value
  84891. * @param array defines the array of float32 to store
  84892. */
  84893. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84894. /**
  84895. * Set the value of an uniform to an array of number
  84896. * @param uniform defines the webGL uniform location where to store the value
  84897. * @param array defines the array of number to store
  84898. */
  84899. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84900. /**
  84901. * Set the value of an uniform to an array of number (stored as vec2)
  84902. * @param uniform defines the webGL uniform location where to store the value
  84903. * @param array defines the array of number to store
  84904. */
  84905. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84906. /**
  84907. * Set the value of an uniform to an array of number (stored as vec3)
  84908. * @param uniform defines the webGL uniform location where to store the value
  84909. * @param array defines the array of number to store
  84910. */
  84911. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84912. /**
  84913. * Set the value of an uniform to an array of number (stored as vec4)
  84914. * @param uniform defines the webGL uniform location where to store the value
  84915. * @param array defines the array of number to store
  84916. */
  84917. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84918. /**
  84919. * Set the value of an uniform to an array of float32 (stored as matrices)
  84920. * @param uniform defines the webGL uniform location where to store the value
  84921. * @param matrices defines the array of float32 to store
  84922. */
  84923. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  84924. /**
  84925. * Set the value of an uniform to a matrix
  84926. * @param uniform defines the webGL uniform location where to store the value
  84927. * @param matrix defines the matrix to store
  84928. */
  84929. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  84930. /**
  84931. * Set the value of an uniform to a matrix (3x3)
  84932. * @param uniform defines the webGL uniform location where to store the value
  84933. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  84934. */
  84935. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84936. /**
  84937. * Set the value of an uniform to a matrix (2x2)
  84938. * @param uniform defines the webGL uniform location where to store the value
  84939. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  84940. */
  84941. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84942. /**
  84943. * Set the value of an uniform to a number (int)
  84944. * @param uniform defines the webGL uniform location where to store the value
  84945. * @param value defines the int number to store
  84946. */
  84947. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  84948. /**
  84949. * Set the value of an uniform to a number (float)
  84950. * @param uniform defines the webGL uniform location where to store the value
  84951. * @param value defines the float number to store
  84952. */
  84953. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  84954. /**
  84955. * Set the value of an uniform to a vec2
  84956. * @param uniform defines the webGL uniform location where to store the value
  84957. * @param x defines the 1st component of the value
  84958. * @param y defines the 2nd component of the value
  84959. */
  84960. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  84961. /**
  84962. * Set the value of an uniform to a vec3
  84963. * @param uniform defines the webGL uniform location where to store the value
  84964. * @param x defines the 1st component of the value
  84965. * @param y defines the 2nd component of the value
  84966. * @param z defines the 3rd component of the value
  84967. */
  84968. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  84969. /**
  84970. * Set the value of an uniform to a boolean
  84971. * @param uniform defines the webGL uniform location where to store the value
  84972. * @param bool defines the boolean to store
  84973. */
  84974. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  84975. /**
  84976. * Set the value of an uniform to a vec4
  84977. * @param uniform defines the webGL uniform location where to store the value
  84978. * @param x defines the 1st component of the value
  84979. * @param y defines the 2nd component of the value
  84980. * @param z defines the 3rd component of the value
  84981. * @param w defines the 4th component of the value
  84982. */
  84983. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  84984. /**
  84985. * Set the value of an uniform to a Color3
  84986. * @param uniform defines the webGL uniform location where to store the value
  84987. * @param color3 defines the color to store
  84988. */
  84989. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  84990. /**
  84991. * Set the value of an uniform to a Color3 and an alpha value
  84992. * @param uniform defines the webGL uniform location where to store the value
  84993. * @param color3 defines the color to store
  84994. * @param alpha defines the alpha component to store
  84995. */
  84996. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  84997. /**
  84998. * Sets a Color4 on a uniform variable
  84999. * @param uniform defines the uniform location
  85000. * @param color4 defines the value to be set
  85001. */
  85002. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  85003. /**
  85004. * Set various states to the webGL context
  85005. * @param culling defines backface culling state
  85006. * @param zOffset defines the value to apply to zOffset (0 by default)
  85007. * @param force defines if states must be applied even if cache is up to date
  85008. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  85009. */
  85010. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  85011. /**
  85012. * Set the z offset to apply to current rendering
  85013. * @param value defines the offset to apply
  85014. */
  85015. setZOffset(value: number): void;
  85016. /**
  85017. * Gets the current value of the zOffset
  85018. * @returns the current zOffset state
  85019. */
  85020. getZOffset(): number;
  85021. /**
  85022. * Enable or disable depth buffering
  85023. * @param enable defines the state to set
  85024. */
  85025. setDepthBuffer(enable: boolean): void;
  85026. /**
  85027. * Gets a boolean indicating if depth writing is enabled
  85028. * @returns the current depth writing state
  85029. */
  85030. getDepthWrite(): boolean;
  85031. /**
  85032. * Enable or disable depth writing
  85033. * @param enable defines the state to set
  85034. */
  85035. setDepthWrite(enable: boolean): void;
  85036. /**
  85037. * Enable or disable color writing
  85038. * @param enable defines the state to set
  85039. */
  85040. setColorWrite(enable: boolean): void;
  85041. /**
  85042. * Gets a boolean indicating if color writing is enabled
  85043. * @returns the current color writing state
  85044. */
  85045. getColorWrite(): boolean;
  85046. /**
  85047. * Sets alpha constants used by some alpha blending modes
  85048. * @param r defines the red component
  85049. * @param g defines the green component
  85050. * @param b defines the blue component
  85051. * @param a defines the alpha component
  85052. */
  85053. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  85054. /**
  85055. * Sets the current alpha mode
  85056. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  85057. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  85058. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85059. */
  85060. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85061. /**
  85062. * Gets the current alpha mode
  85063. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85064. * @returns the current alpha mode
  85065. */
  85066. getAlphaMode(): number;
  85067. /**
  85068. * Clears the list of texture accessible through engine.
  85069. * This can help preventing texture load conflict due to name collision.
  85070. */
  85071. clearInternalTexturesCache(): void;
  85072. /**
  85073. * Force the entire cache to be cleared
  85074. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85075. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85076. */
  85077. wipeCaches(bruteForce?: boolean): void;
  85078. /**
  85079. * Set the compressed texture format to use, based on the formats you have, and the formats
  85080. * supported by the hardware / browser.
  85081. *
  85082. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85083. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85084. * to API arguments needed to compressed textures. This puts the burden on the container
  85085. * generator to house the arcane code for determining these for current & future formats.
  85086. *
  85087. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85088. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85089. *
  85090. * Note: The result of this call is not taken into account when a texture is base64.
  85091. *
  85092. * @param formatsAvailable defines the list of those format families you have created
  85093. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85094. *
  85095. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85096. * @returns The extension selected.
  85097. */
  85098. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85099. private _getSamplingParameters;
  85100. private _partialLoadImg;
  85101. private _cascadeLoadImgs;
  85102. /** @hidden */
  85103. _createTexture(): WebGLTexture;
  85104. /**
  85105. * Usually called from Texture.ts.
  85106. * Passed information to create a WebGLTexture
  85107. * @param urlArg defines a value which contains one of the following:
  85108. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85109. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85110. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85111. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85112. * @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)
  85113. * @param scene needed for loading to the correct scene
  85114. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85115. * @param onLoad optional callback to be called upon successful completion
  85116. * @param onError optional callback to be called upon failure
  85117. * @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
  85118. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85119. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85120. * @param forcedExtension defines the extension to use to pick the right loader
  85121. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85122. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85123. */
  85124. 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;
  85125. private _rescaleTexture;
  85126. /**
  85127. * Update a raw texture
  85128. * @param texture defines the texture to update
  85129. * @param data defines the data to store in the texture
  85130. * @param format defines the format of the data
  85131. * @param invertY defines if data must be stored with Y axis inverted
  85132. * @param compression defines the compression used (null by default)
  85133. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85134. */
  85135. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85136. /**
  85137. * Creates a raw texture
  85138. * @param data defines the data to store in the texture
  85139. * @param width defines the width of the texture
  85140. * @param height defines the height of the texture
  85141. * @param format defines the format of the data
  85142. * @param generateMipMaps defines if the engine should generate the mip levels
  85143. * @param invertY defines if data must be stored with Y axis inverted
  85144. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85145. * @param compression defines the compression used (null by default)
  85146. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85147. * @returns the raw texture inside an InternalTexture
  85148. */
  85149. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85150. private _unpackFlipYCached;
  85151. /**
  85152. * In case you are sharing the context with other applications, it might
  85153. * be interested to not cache the unpack flip y state to ensure a consistent
  85154. * value would be set.
  85155. */
  85156. enableUnpackFlipYCached: boolean;
  85157. /** @hidden */
  85158. _unpackFlipY(value: boolean): void;
  85159. /** @hidden */
  85160. _getUnpackAlignement(): number;
  85161. /**
  85162. * Creates a dynamic texture
  85163. * @param width defines the width of the texture
  85164. * @param height defines the height of the texture
  85165. * @param generateMipMaps defines if the engine should generate the mip levels
  85166. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85167. * @returns the dynamic texture inside an InternalTexture
  85168. */
  85169. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85170. /**
  85171. * Update the sampling mode of a given texture
  85172. * @param samplingMode defines the required sampling mode
  85173. * @param texture defines the texture to update
  85174. */
  85175. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85176. /**
  85177. * Update the content of a dynamic texture
  85178. * @param texture defines the texture to update
  85179. * @param canvas defines the canvas containing the source
  85180. * @param invertY defines if data must be stored with Y axis inverted
  85181. * @param premulAlpha defines if alpha is stored as premultiplied
  85182. * @param format defines the format of the data
  85183. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85184. */
  85185. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85186. /**
  85187. * Update a video texture
  85188. * @param texture defines the texture to update
  85189. * @param video defines the video element to use
  85190. * @param invertY defines if data must be stored with Y axis inverted
  85191. */
  85192. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85193. /**
  85194. * Updates a depth texture Comparison Mode and Function.
  85195. * If the comparison Function is equal to 0, the mode will be set to none.
  85196. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85197. * @param texture The texture to set the comparison function for
  85198. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85199. */
  85200. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85201. private _setupDepthStencilTexture;
  85202. /**
  85203. * Creates a depth stencil texture.
  85204. * This is only available in WebGL 2 or with the depth texture extension available.
  85205. * @param size The size of face edge in the texture.
  85206. * @param options The options defining the texture.
  85207. * @returns The texture
  85208. */
  85209. createDepthStencilTexture(size: number | {
  85210. width: number;
  85211. height: number;
  85212. }, options: DepthTextureCreationOptions): InternalTexture;
  85213. /**
  85214. * Creates a depth stencil texture.
  85215. * This is only available in WebGL 2 or with the depth texture extension available.
  85216. * @param size The size of face edge in the texture.
  85217. * @param options The options defining the texture.
  85218. * @returns The texture
  85219. */
  85220. private _createDepthStencilTexture;
  85221. /**
  85222. * Creates a depth stencil cube texture.
  85223. * This is only available in WebGL 2.
  85224. * @param size The size of face edge in the cube texture.
  85225. * @param options The options defining the cube texture.
  85226. * @returns The cube texture
  85227. */
  85228. private _createDepthStencilCubeTexture;
  85229. /**
  85230. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85231. * @param renderTarget The render target to set the frame buffer for
  85232. */
  85233. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85234. /**
  85235. * Creates a new render target texture
  85236. * @param size defines the size of the texture
  85237. * @param options defines the options used to create the texture
  85238. * @returns a new render target texture stored in an InternalTexture
  85239. */
  85240. createRenderTargetTexture(size: number | {
  85241. width: number;
  85242. height: number;
  85243. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85244. /**
  85245. * Create a multi render target texture
  85246. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85247. * @param size defines the size of the texture
  85248. * @param options defines the creation options
  85249. * @returns the cube texture as an InternalTexture
  85250. */
  85251. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85252. private _setupFramebufferDepthAttachments;
  85253. /**
  85254. * Updates the sample count of a render target texture
  85255. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85256. * @param texture defines the texture to update
  85257. * @param samples defines the sample count to set
  85258. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85259. */
  85260. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85261. /**
  85262. * Update the sample count for a given multiple render target texture
  85263. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85264. * @param textures defines the textures to update
  85265. * @param samples defines the sample count to set
  85266. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85267. */
  85268. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85269. /** @hidden */
  85270. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85271. /** @hidden */
  85272. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85273. /** @hidden */
  85274. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85275. /** @hidden */
  85276. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85277. /**
  85278. * Creates a new render target cube texture
  85279. * @param size defines the size of the texture
  85280. * @param options defines the options used to create the texture
  85281. * @returns a new render target cube texture stored in an InternalTexture
  85282. */
  85283. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85284. /**
  85285. * Creates a cube texture
  85286. * @param rootUrl defines the url where the files to load is located
  85287. * @param scene defines the current scene
  85288. * @param files defines the list of files to load (1 per face)
  85289. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85290. * @param onLoad defines an optional callback raised when the texture is loaded
  85291. * @param onError defines an optional callback raised if there is an issue to load the texture
  85292. * @param format defines the format of the data
  85293. * @param forcedExtension defines the extension to use to pick the right loader
  85294. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85295. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85296. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85297. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85298. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85299. * @returns the cube texture as an InternalTexture
  85300. */
  85301. 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;
  85302. /**
  85303. * @hidden
  85304. */
  85305. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85306. /**
  85307. * Update a raw cube texture
  85308. * @param texture defines the texture to udpdate
  85309. * @param data defines the data to store
  85310. * @param format defines the data format
  85311. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85312. * @param invertY defines if data must be stored with Y axis inverted
  85313. * @param compression defines the compression used (null by default)
  85314. * @param level defines which level of the texture to update
  85315. */
  85316. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85317. /**
  85318. * Creates a new raw cube texture
  85319. * @param data defines the array of data to use to create each face
  85320. * @param size defines the size of the textures
  85321. * @param format defines the format of the data
  85322. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85323. * @param generateMipMaps defines if the engine should generate the mip levels
  85324. * @param invertY defines if data must be stored with Y axis inverted
  85325. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85326. * @param compression defines the compression used (null by default)
  85327. * @returns the cube texture as an InternalTexture
  85328. */
  85329. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85330. /**
  85331. * Creates a new raw cube texture from a specified url
  85332. * @param url defines the url where the data is located
  85333. * @param scene defines the current scene
  85334. * @param size defines the size of the textures
  85335. * @param format defines the format of the data
  85336. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85337. * @param noMipmap defines if the engine should avoid generating the mip levels
  85338. * @param callback defines a callback used to extract texture data from loaded data
  85339. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85340. * @param onLoad defines a callback called when texture is loaded
  85341. * @param onError defines a callback called if there is an error
  85342. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85343. * @param invertY defines if data must be stored with Y axis inverted
  85344. * @returns the cube texture as an InternalTexture
  85345. */
  85346. 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;
  85347. /**
  85348. * Update a raw 3D texture
  85349. * @param texture defines the texture to update
  85350. * @param data defines the data to store
  85351. * @param format defines the data format
  85352. * @param invertY defines if data must be stored with Y axis inverted
  85353. * @param compression defines the used compression (can be null)
  85354. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85355. */
  85356. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85357. /**
  85358. * Creates a new raw 3D texture
  85359. * @param data defines the data used to create the texture
  85360. * @param width defines the width of the texture
  85361. * @param height defines the height of the texture
  85362. * @param depth defines the depth of the texture
  85363. * @param format defines the format of the texture
  85364. * @param generateMipMaps defines if the engine must generate mip levels
  85365. * @param invertY defines if data must be stored with Y axis inverted
  85366. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85367. * @param compression defines the compressed used (can be null)
  85368. * @param textureType defines the compressed used (can be null)
  85369. * @returns a new raw 3D texture (stored in an InternalTexture)
  85370. */
  85371. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  85372. private _prepareWebGLTextureContinuation;
  85373. private _prepareWebGLTexture;
  85374. private _convertRGBtoRGBATextureData;
  85375. /** @hidden */
  85376. _releaseFramebufferObjects(texture: InternalTexture): void;
  85377. /** @hidden */
  85378. _releaseTexture(texture: InternalTexture): void;
  85379. private setProgram;
  85380. private _boundUniforms;
  85381. /**
  85382. * Binds an effect to the webGL context
  85383. * @param effect defines the effect to bind
  85384. */
  85385. bindSamplers(effect: Effect): void;
  85386. private _moveBoundTextureOnTop;
  85387. private _getCorrectTextureChannel;
  85388. private _linkTrackers;
  85389. private _removeDesignatedSlot;
  85390. private _activateCurrentTexture;
  85391. /** @hidden */
  85392. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  85393. /** @hidden */
  85394. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  85395. /**
  85396. * Sets a texture to the webGL context from a postprocess
  85397. * @param channel defines the channel to use
  85398. * @param postProcess defines the source postprocess
  85399. */
  85400. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  85401. /**
  85402. * Binds the output of the passed in post process to the texture channel specified
  85403. * @param channel The channel the texture should be bound to
  85404. * @param postProcess The post process which's output should be bound
  85405. */
  85406. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  85407. /**
  85408. * Unbind all textures from the webGL context
  85409. */
  85410. unbindAllTextures(): void;
  85411. /**
  85412. * Sets a texture to the according uniform.
  85413. * @param channel The texture channel
  85414. * @param uniform The uniform to set
  85415. * @param texture The texture to apply
  85416. */
  85417. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  85418. /**
  85419. * Sets a depth stencil texture from a render target to the according uniform.
  85420. * @param channel The texture channel
  85421. * @param uniform The uniform to set
  85422. * @param texture The render target texture containing the depth stencil texture to apply
  85423. */
  85424. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  85425. private _bindSamplerUniformToChannel;
  85426. private _getTextureWrapMode;
  85427. private _setTexture;
  85428. /**
  85429. * Sets an array of texture to the webGL context
  85430. * @param channel defines the channel where the texture array must be set
  85431. * @param uniform defines the associated uniform location
  85432. * @param textures defines the array of textures to bind
  85433. */
  85434. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  85435. /** @hidden */
  85436. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  85437. private _setTextureParameterFloat;
  85438. private _setTextureParameterInteger;
  85439. /**
  85440. * Reads pixels from the current frame buffer. Please note that this function can be slow
  85441. * @param x defines the x coordinate of the rectangle where pixels must be read
  85442. * @param y defines the y coordinate of the rectangle where pixels must be read
  85443. * @param width defines the width of the rectangle where pixels must be read
  85444. * @param height defines the height of the rectangle where pixels must be read
  85445. * @returns a Uint8Array containing RGBA colors
  85446. */
  85447. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  85448. /**
  85449. * Add an externaly attached data from its key.
  85450. * This method call will fail and return false, if such key already exists.
  85451. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  85452. * @param key the unique key that identifies the data
  85453. * @param data the data object to associate to the key for this Engine instance
  85454. * @return true if no such key were already present and the data was added successfully, false otherwise
  85455. */
  85456. addExternalData<T>(key: string, data: T): boolean;
  85457. /**
  85458. * Get an externaly attached data from its key
  85459. * @param key the unique key that identifies the data
  85460. * @return the associated data, if present (can be null), or undefined if not present
  85461. */
  85462. getExternalData<T>(key: string): T;
  85463. /**
  85464. * Get an externaly attached data from its key, create it using a factory if it's not already present
  85465. * @param key the unique key that identifies the data
  85466. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  85467. * @return the associated data, can be null if the factory returned null.
  85468. */
  85469. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  85470. /**
  85471. * Remove an externaly attached data from the Engine instance
  85472. * @param key the unique key that identifies the data
  85473. * @return true if the data was successfully removed, false if it doesn't exist
  85474. */
  85475. removeExternalData(key: string): boolean;
  85476. /**
  85477. * Unbind all vertex attributes from the webGL context
  85478. */
  85479. unbindAllAttributes(): void;
  85480. /**
  85481. * 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
  85482. */
  85483. releaseEffects(): void;
  85484. /**
  85485. * Dispose and release all associated resources
  85486. */
  85487. dispose(): void;
  85488. /**
  85489. * Display the loading screen
  85490. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85491. */
  85492. displayLoadingUI(): void;
  85493. /**
  85494. * Hide the loading screen
  85495. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85496. */
  85497. hideLoadingUI(): void;
  85498. /**
  85499. * Gets the current loading screen object
  85500. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85501. */
  85502. /**
  85503. * Sets the current loading screen object
  85504. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85505. */
  85506. loadingScreen: ILoadingScreen;
  85507. /**
  85508. * Sets the current loading screen text
  85509. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85510. */
  85511. loadingUIText: string;
  85512. /**
  85513. * Sets the current loading screen background color
  85514. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85515. */
  85516. loadingUIBackgroundColor: string;
  85517. /**
  85518. * Attach a new callback raised when context lost event is fired
  85519. * @param callback defines the callback to call
  85520. */
  85521. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85522. /**
  85523. * Attach a new callback raised when context restored event is fired
  85524. * @param callback defines the callback to call
  85525. */
  85526. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85527. /**
  85528. * Gets the source code of the vertex shader associated with a specific webGL program
  85529. * @param program defines the program to use
  85530. * @returns a string containing the source code of the vertex shader associated with the program
  85531. */
  85532. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  85533. /**
  85534. * Gets the source code of the fragment shader associated with a specific webGL program
  85535. * @param program defines the program to use
  85536. * @returns a string containing the source code of the fragment shader associated with the program
  85537. */
  85538. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  85539. /**
  85540. * Get the current error code of the webGL context
  85541. * @returns the error code
  85542. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  85543. */
  85544. getError(): number;
  85545. /**
  85546. * Gets the current framerate
  85547. * @returns a number representing the framerate
  85548. */
  85549. getFps(): number;
  85550. /**
  85551. * Gets the time spent between current and previous frame
  85552. * @returns a number representing the delta time in ms
  85553. */
  85554. getDeltaTime(): number;
  85555. private _measureFps;
  85556. /** @hidden */
  85557. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  85558. private _canRenderToFloatFramebuffer;
  85559. private _canRenderToHalfFloatFramebuffer;
  85560. private _canRenderToFramebuffer;
  85561. /** @hidden */
  85562. _getWebGLTextureType(type: number): number;
  85563. private _getInternalFormat;
  85564. /** @hidden */
  85565. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  85566. /** @hidden */
  85567. _getRGBAMultiSampleBufferFormat(type: number): number;
  85568. /** @hidden */
  85569. _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;
  85570. /** @hidden */
  85571. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  85572. private _partialLoadFile;
  85573. private _cascadeLoadFiles;
  85574. /**
  85575. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  85576. * @returns true if the engine can be created
  85577. * @ignorenaming
  85578. */
  85579. static isSupported(): boolean;
  85580. }
  85581. }
  85582. declare module BABYLON {
  85583. /**
  85584. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85585. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85586. */
  85587. export class EffectFallbacks {
  85588. private _defines;
  85589. private _currentRank;
  85590. private _maxRank;
  85591. private _mesh;
  85592. /**
  85593. * Removes the fallback from the bound mesh.
  85594. */
  85595. unBindMesh(): void;
  85596. /**
  85597. * Adds a fallback on the specified property.
  85598. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85599. * @param define The name of the define in the shader
  85600. */
  85601. addFallback(rank: number, define: string): void;
  85602. /**
  85603. * Sets the mesh to use CPU skinning when needing to fallback.
  85604. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85605. * @param mesh The mesh to use the fallbacks.
  85606. */
  85607. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85608. /**
  85609. * Checks to see if more fallbacks are still availible.
  85610. */
  85611. readonly isMoreFallbacks: boolean;
  85612. /**
  85613. * Removes the defines that shoould be removed when falling back.
  85614. * @param currentDefines defines the current define statements for the shader.
  85615. * @param effect defines the current effect we try to compile
  85616. * @returns The resulting defines with defines of the current rank removed.
  85617. */
  85618. reduce(currentDefines: string, effect: Effect): string;
  85619. }
  85620. /**
  85621. * Options to be used when creating an effect.
  85622. */
  85623. export class EffectCreationOptions {
  85624. /**
  85625. * Atrributes that will be used in the shader.
  85626. */
  85627. attributes: string[];
  85628. /**
  85629. * Uniform varible names that will be set in the shader.
  85630. */
  85631. uniformsNames: string[];
  85632. /**
  85633. * Uniform buffer varible names that will be set in the shader.
  85634. */
  85635. uniformBuffersNames: string[];
  85636. /**
  85637. * Sampler texture variable names that will be set in the shader.
  85638. */
  85639. samplers: string[];
  85640. /**
  85641. * Define statements that will be set in the shader.
  85642. */
  85643. defines: any;
  85644. /**
  85645. * Possible fallbacks for this effect to improve performance when needed.
  85646. */
  85647. fallbacks: Nullable<EffectFallbacks>;
  85648. /**
  85649. * Callback that will be called when the shader is compiled.
  85650. */
  85651. onCompiled: Nullable<(effect: Effect) => void>;
  85652. /**
  85653. * Callback that will be called if an error occurs during shader compilation.
  85654. */
  85655. onError: Nullable<(effect: Effect, errors: string) => void>;
  85656. /**
  85657. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85658. */
  85659. indexParameters: any;
  85660. /**
  85661. * Max number of lights that can be used in the shader.
  85662. */
  85663. maxSimultaneousLights: number;
  85664. /**
  85665. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  85666. */
  85667. transformFeedbackVaryings: Nullable<string[]>;
  85668. }
  85669. /**
  85670. * Effect containing vertex and fragment shader that can be executed on an object.
  85671. */
  85672. export class Effect {
  85673. /**
  85674. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85675. */
  85676. static ShadersRepository: string;
  85677. /**
  85678. * Name of the effect.
  85679. */
  85680. name: any;
  85681. /**
  85682. * String container all the define statements that should be set on the shader.
  85683. */
  85684. defines: string;
  85685. /**
  85686. * Callback that will be called when the shader is compiled.
  85687. */
  85688. onCompiled: Nullable<(effect: Effect) => void>;
  85689. /**
  85690. * Callback that will be called if an error occurs during shader compilation.
  85691. */
  85692. onError: Nullable<(effect: Effect, errors: string) => void>;
  85693. /**
  85694. * Callback that will be called when effect is bound.
  85695. */
  85696. onBind: Nullable<(effect: Effect) => void>;
  85697. /**
  85698. * Unique ID of the effect.
  85699. */
  85700. uniqueId: number;
  85701. /**
  85702. * Observable that will be called when the shader is compiled.
  85703. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  85704. */
  85705. onCompileObservable: Observable<Effect>;
  85706. /**
  85707. * Observable that will be called if an error occurs during shader compilation.
  85708. */
  85709. onErrorObservable: Observable<Effect>;
  85710. /** @hidden */
  85711. _onBindObservable: Nullable<Observable<Effect>>;
  85712. /**
  85713. * Observable that will be called when effect is bound.
  85714. */
  85715. readonly onBindObservable: Observable<Effect>;
  85716. /** @hidden */
  85717. _bonesComputationForcedToCPU: boolean;
  85718. private static _uniqueIdSeed;
  85719. private _engine;
  85720. private _uniformBuffersNames;
  85721. private _uniformsNames;
  85722. private _samplers;
  85723. private _isReady;
  85724. private _compilationError;
  85725. private _attributesNames;
  85726. private _attributes;
  85727. private _uniforms;
  85728. /**
  85729. * Key for the effect.
  85730. * @hidden
  85731. */
  85732. _key: string;
  85733. private _indexParameters;
  85734. private _fallbacks;
  85735. private _vertexSourceCode;
  85736. private _fragmentSourceCode;
  85737. private _vertexSourceCodeOverride;
  85738. private _fragmentSourceCodeOverride;
  85739. private _transformFeedbackVaryings;
  85740. /**
  85741. * Compiled shader to webGL program.
  85742. * @hidden
  85743. */
  85744. _program: WebGLProgram;
  85745. private _valueCache;
  85746. private static _baseCache;
  85747. /**
  85748. * Instantiates an effect.
  85749. * An effect can be used to create/manage/execute vertex and fragment shaders.
  85750. * @param baseName Name of the effect.
  85751. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  85752. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  85753. * @param samplers List of sampler variables that will be passed to the shader.
  85754. * @param engine Engine to be used to render the effect
  85755. * @param defines Define statements to be added to the shader.
  85756. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  85757. * @param onCompiled Callback that will be called when the shader is compiled.
  85758. * @param onError Callback that will be called if an error occurs during shader compilation.
  85759. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85760. */
  85761. 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);
  85762. /**
  85763. * Unique key for this effect
  85764. */
  85765. readonly key: string;
  85766. /**
  85767. * If the effect has been compiled and prepared.
  85768. * @returns if the effect is compiled and prepared.
  85769. */
  85770. isReady(): boolean;
  85771. /**
  85772. * The engine the effect was initialized with.
  85773. * @returns the engine.
  85774. */
  85775. getEngine(): Engine;
  85776. /**
  85777. * The compiled webGL program for the effect
  85778. * @returns the webGL program.
  85779. */
  85780. getProgram(): WebGLProgram;
  85781. /**
  85782. * The set of names of attribute variables for the shader.
  85783. * @returns An array of attribute names.
  85784. */
  85785. getAttributesNames(): string[];
  85786. /**
  85787. * Returns the attribute at the given index.
  85788. * @param index The index of the attribute.
  85789. * @returns The location of the attribute.
  85790. */
  85791. getAttributeLocation(index: number): number;
  85792. /**
  85793. * Returns the attribute based on the name of the variable.
  85794. * @param name of the attribute to look up.
  85795. * @returns the attribute location.
  85796. */
  85797. getAttributeLocationByName(name: string): number;
  85798. /**
  85799. * The number of attributes.
  85800. * @returns the numnber of attributes.
  85801. */
  85802. getAttributesCount(): number;
  85803. /**
  85804. * Gets the index of a uniform variable.
  85805. * @param uniformName of the uniform to look up.
  85806. * @returns the index.
  85807. */
  85808. getUniformIndex(uniformName: string): number;
  85809. /**
  85810. * Returns the attribute based on the name of the variable.
  85811. * @param uniformName of the uniform to look up.
  85812. * @returns the location of the uniform.
  85813. */
  85814. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  85815. /**
  85816. * Returns an array of sampler variable names
  85817. * @returns The array of sampler variable neames.
  85818. */
  85819. getSamplers(): string[];
  85820. /**
  85821. * The error from the last compilation.
  85822. * @returns the error string.
  85823. */
  85824. getCompilationError(): string;
  85825. /**
  85826. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  85827. * @param func The callback to be used.
  85828. */
  85829. executeWhenCompiled(func: (effect: Effect) => void): void;
  85830. private _checkIsReady;
  85831. /** @hidden */
  85832. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  85833. /** @hidden */
  85834. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  85835. /** @hidden */
  85836. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  85837. private _processShaderConversion;
  85838. private _processIncludes;
  85839. private _processPrecision;
  85840. /**
  85841. * Recompiles the webGL program
  85842. * @param vertexSourceCode The source code for the vertex shader.
  85843. * @param fragmentSourceCode The source code for the fragment shader.
  85844. * @param onCompiled Callback called when completed.
  85845. * @param onError Callback called on error.
  85846. * @hidden
  85847. */
  85848. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  85849. /**
  85850. * Gets the uniform locations of the the specified variable names
  85851. * @param names THe names of the variables to lookup.
  85852. * @returns Array of locations in the same order as variable names.
  85853. */
  85854. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  85855. /**
  85856. * Prepares the effect
  85857. * @hidden
  85858. */
  85859. _prepareEffect(): void;
  85860. /**
  85861. * Checks if the effect is supported. (Must be called after compilation)
  85862. */
  85863. readonly isSupported: boolean;
  85864. /**
  85865. * Binds a texture to the engine to be used as output of the shader.
  85866. * @param channel Name of the output variable.
  85867. * @param texture Texture to bind.
  85868. * @hidden
  85869. */
  85870. _bindTexture(channel: string, texture: InternalTexture): void;
  85871. /**
  85872. * Sets a texture on the engine to be used in the shader.
  85873. * @param channel Name of the sampler variable.
  85874. * @param texture Texture to set.
  85875. */
  85876. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  85877. /**
  85878. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  85879. * @param channel Name of the sampler variable.
  85880. * @param texture Texture to set.
  85881. */
  85882. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  85883. /**
  85884. * Sets an array of textures on the engine to be used in the shader.
  85885. * @param channel Name of the variable.
  85886. * @param textures Textures to set.
  85887. */
  85888. setTextureArray(channel: string, textures: BaseTexture[]): void;
  85889. /**
  85890. * 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)
  85891. * @param channel Name of the sampler variable.
  85892. * @param postProcess Post process to get the input texture from.
  85893. */
  85894. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  85895. /**
  85896. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  85897. * 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)
  85898. * @param channel Name of the sampler variable.
  85899. * @param postProcess Post process to get the output texture from.
  85900. */
  85901. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  85902. /** @hidden */
  85903. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  85904. /** @hidden */
  85905. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  85906. /** @hidden */
  85907. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  85908. /** @hidden */
  85909. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  85910. /**
  85911. * Binds a buffer to a uniform.
  85912. * @param buffer Buffer to bind.
  85913. * @param name Name of the uniform variable to bind to.
  85914. */
  85915. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  85916. /**
  85917. * Binds block to a uniform.
  85918. * @param blockName Name of the block to bind.
  85919. * @param index Index to bind.
  85920. */
  85921. bindUniformBlock(blockName: string, index: number): void;
  85922. /**
  85923. * Sets an interger value on a uniform variable.
  85924. * @param uniformName Name of the variable.
  85925. * @param value Value to be set.
  85926. * @returns this effect.
  85927. */
  85928. setInt(uniformName: string, value: number): Effect;
  85929. /**
  85930. * Sets an int array on a uniform variable.
  85931. * @param uniformName Name of the variable.
  85932. * @param array array to be set.
  85933. * @returns this effect.
  85934. */
  85935. setIntArray(uniformName: string, array: Int32Array): Effect;
  85936. /**
  85937. * 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)
  85938. * @param uniformName Name of the variable.
  85939. * @param array array to be set.
  85940. * @returns this effect.
  85941. */
  85942. setIntArray2(uniformName: string, array: Int32Array): Effect;
  85943. /**
  85944. * 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)
  85945. * @param uniformName Name of the variable.
  85946. * @param array array to be set.
  85947. * @returns this effect.
  85948. */
  85949. setIntArray3(uniformName: string, array: Int32Array): Effect;
  85950. /**
  85951. * 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)
  85952. * @param uniformName Name of the variable.
  85953. * @param array array to be set.
  85954. * @returns this effect.
  85955. */
  85956. setIntArray4(uniformName: string, array: Int32Array): Effect;
  85957. /**
  85958. * Sets an float array on a uniform variable.
  85959. * @param uniformName Name of the variable.
  85960. * @param array array to be set.
  85961. * @returns this effect.
  85962. */
  85963. setFloatArray(uniformName: string, array: Float32Array): Effect;
  85964. /**
  85965. * 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)
  85966. * @param uniformName Name of the variable.
  85967. * @param array array to be set.
  85968. * @returns this effect.
  85969. */
  85970. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  85971. /**
  85972. * 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)
  85973. * @param uniformName Name of the variable.
  85974. * @param array array to be set.
  85975. * @returns this effect.
  85976. */
  85977. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  85978. /**
  85979. * 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)
  85980. * @param uniformName Name of the variable.
  85981. * @param array array to be set.
  85982. * @returns this effect.
  85983. */
  85984. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  85985. /**
  85986. * Sets an array on a uniform variable.
  85987. * @param uniformName Name of the variable.
  85988. * @param array array to be set.
  85989. * @returns this effect.
  85990. */
  85991. setArray(uniformName: string, array: number[]): Effect;
  85992. /**
  85993. * 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)
  85994. * @param uniformName Name of the variable.
  85995. * @param array array to be set.
  85996. * @returns this effect.
  85997. */
  85998. setArray2(uniformName: string, array: number[]): Effect;
  85999. /**
  86000. * 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)
  86001. * @param uniformName Name of the variable.
  86002. * @param array array to be set.
  86003. * @returns this effect.
  86004. */
  86005. setArray3(uniformName: string, array: number[]): Effect;
  86006. /**
  86007. * 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)
  86008. * @param uniformName Name of the variable.
  86009. * @param array array to be set.
  86010. * @returns this effect.
  86011. */
  86012. setArray4(uniformName: string, array: number[]): Effect;
  86013. /**
  86014. * Sets matrices on a uniform variable.
  86015. * @param uniformName Name of the variable.
  86016. * @param matrices matrices to be set.
  86017. * @returns this effect.
  86018. */
  86019. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  86020. /**
  86021. * Sets matrix on a uniform variable.
  86022. * @param uniformName Name of the variable.
  86023. * @param matrix matrix to be set.
  86024. * @returns this effect.
  86025. */
  86026. setMatrix(uniformName: string, matrix: Matrix): Effect;
  86027. /**
  86028. * 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)
  86029. * @param uniformName Name of the variable.
  86030. * @param matrix matrix to be set.
  86031. * @returns this effect.
  86032. */
  86033. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  86034. /**
  86035. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86036. * @param uniformName Name of the variable.
  86037. * @param matrix matrix to be set.
  86038. * @returns this effect.
  86039. */
  86040. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  86041. /**
  86042. * Sets a float on a uniform variable.
  86043. * @param uniformName Name of the variable.
  86044. * @param value value to be set.
  86045. * @returns this effect.
  86046. */
  86047. setFloat(uniformName: string, value: number): Effect;
  86048. /**
  86049. * Sets a boolean on a uniform variable.
  86050. * @param uniformName Name of the variable.
  86051. * @param bool value to be set.
  86052. * @returns this effect.
  86053. */
  86054. setBool(uniformName: string, bool: boolean): Effect;
  86055. /**
  86056. * Sets a Vector2 on a uniform variable.
  86057. * @param uniformName Name of the variable.
  86058. * @param vector2 vector2 to be set.
  86059. * @returns this effect.
  86060. */
  86061. setVector2(uniformName: string, vector2: Vector2): Effect;
  86062. /**
  86063. * Sets a float2 on a uniform variable.
  86064. * @param uniformName Name of the variable.
  86065. * @param x First float in float2.
  86066. * @param y Second float in float2.
  86067. * @returns this effect.
  86068. */
  86069. setFloat2(uniformName: string, x: number, y: number): Effect;
  86070. /**
  86071. * Sets a Vector3 on a uniform variable.
  86072. * @param uniformName Name of the variable.
  86073. * @param vector3 Value to be set.
  86074. * @returns this effect.
  86075. */
  86076. setVector3(uniformName: string, vector3: Vector3): Effect;
  86077. /**
  86078. * Sets a float3 on a uniform variable.
  86079. * @param uniformName Name of the variable.
  86080. * @param x First float in float3.
  86081. * @param y Second float in float3.
  86082. * @param z Third float in float3.
  86083. * @returns this effect.
  86084. */
  86085. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86086. /**
  86087. * Sets a Vector4 on a uniform variable.
  86088. * @param uniformName Name of the variable.
  86089. * @param vector4 Value to be set.
  86090. * @returns this effect.
  86091. */
  86092. setVector4(uniformName: string, vector4: Vector4): Effect;
  86093. /**
  86094. * Sets a float4 on a uniform variable.
  86095. * @param uniformName Name of the variable.
  86096. * @param x First float in float4.
  86097. * @param y Second float in float4.
  86098. * @param z Third float in float4.
  86099. * @param w Fourth float in float4.
  86100. * @returns this effect.
  86101. */
  86102. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86103. /**
  86104. * Sets a Color3 on a uniform variable.
  86105. * @param uniformName Name of the variable.
  86106. * @param color3 Value to be set.
  86107. * @returns this effect.
  86108. */
  86109. setColor3(uniformName: string, color3: Color3): Effect;
  86110. /**
  86111. * Sets a Color4 on a uniform variable.
  86112. * @param uniformName Name of the variable.
  86113. * @param color3 Value to be set.
  86114. * @param alpha Alpha value to be set.
  86115. * @returns this effect.
  86116. */
  86117. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86118. /**
  86119. * Sets a Color4 on a uniform variable
  86120. * @param uniformName defines the name of the variable
  86121. * @param color4 defines the value to be set
  86122. * @returns this effect.
  86123. */
  86124. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86125. /**
  86126. * This function will add a new shader to the shader store
  86127. * @param name the name of the shader
  86128. * @param pixelShader optional pixel shader content
  86129. * @param vertexShader optional vertex shader content
  86130. */
  86131. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86132. /**
  86133. * Store of each shader (The can be looked up using effect.key)
  86134. */
  86135. static ShadersStore: {
  86136. [key: string]: string;
  86137. };
  86138. /**
  86139. * Store of each included file for a shader (The can be looked up using effect.key)
  86140. */
  86141. static IncludesShadersStore: {
  86142. [key: string]: string;
  86143. };
  86144. /**
  86145. * Resets the cache of effects.
  86146. */
  86147. static ResetCache(): void;
  86148. }
  86149. }
  86150. declare module BABYLON {
  86151. /**
  86152. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86153. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86154. * 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;
  86155. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86156. */
  86157. export class ColorCurves {
  86158. private _dirty;
  86159. private _tempColor;
  86160. private _globalCurve;
  86161. private _highlightsCurve;
  86162. private _midtonesCurve;
  86163. private _shadowsCurve;
  86164. private _positiveCurve;
  86165. private _negativeCurve;
  86166. private _globalHue;
  86167. private _globalDensity;
  86168. private _globalSaturation;
  86169. private _globalExposure;
  86170. /**
  86171. * Gets the global Hue value.
  86172. * 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).
  86173. */
  86174. /**
  86175. * Sets the global Hue value.
  86176. * 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).
  86177. */
  86178. globalHue: number;
  86179. /**
  86180. * Gets the global Density value.
  86181. * 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.
  86182. * Values less than zero provide a filter of opposite hue.
  86183. */
  86184. /**
  86185. * Sets the global Density value.
  86186. * 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.
  86187. * Values less than zero provide a filter of opposite hue.
  86188. */
  86189. globalDensity: number;
  86190. /**
  86191. * Gets the global Saturation value.
  86192. * 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.
  86193. */
  86194. /**
  86195. * Sets the global Saturation value.
  86196. * 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.
  86197. */
  86198. globalSaturation: number;
  86199. /**
  86200. * Gets the global Exposure value.
  86201. * 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.
  86202. */
  86203. /**
  86204. * Sets the global Exposure value.
  86205. * 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.
  86206. */
  86207. globalExposure: number;
  86208. private _highlightsHue;
  86209. private _highlightsDensity;
  86210. private _highlightsSaturation;
  86211. private _highlightsExposure;
  86212. /**
  86213. * Gets the highlights Hue value.
  86214. * 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).
  86215. */
  86216. /**
  86217. * Sets the highlights Hue value.
  86218. * 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).
  86219. */
  86220. highlightsHue: number;
  86221. /**
  86222. * Gets the highlights Density value.
  86223. * 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.
  86224. * Values less than zero provide a filter of opposite hue.
  86225. */
  86226. /**
  86227. * Sets the highlights Density value.
  86228. * 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.
  86229. * Values less than zero provide a filter of opposite hue.
  86230. */
  86231. highlightsDensity: number;
  86232. /**
  86233. * Gets the highlights Saturation value.
  86234. * 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.
  86235. */
  86236. /**
  86237. * Sets the highlights Saturation value.
  86238. * 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.
  86239. */
  86240. highlightsSaturation: number;
  86241. /**
  86242. * Gets the highlights Exposure value.
  86243. * 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.
  86244. */
  86245. /**
  86246. * Sets the highlights Exposure value.
  86247. * 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.
  86248. */
  86249. highlightsExposure: number;
  86250. private _midtonesHue;
  86251. private _midtonesDensity;
  86252. private _midtonesSaturation;
  86253. private _midtonesExposure;
  86254. /**
  86255. * Gets the midtones Hue value.
  86256. * 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).
  86257. */
  86258. /**
  86259. * Sets the midtones Hue value.
  86260. * 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).
  86261. */
  86262. midtonesHue: number;
  86263. /**
  86264. * Gets the midtones Density value.
  86265. * 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.
  86266. * Values less than zero provide a filter of opposite hue.
  86267. */
  86268. /**
  86269. * Sets the midtones Density value.
  86270. * 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.
  86271. * Values less than zero provide a filter of opposite hue.
  86272. */
  86273. midtonesDensity: number;
  86274. /**
  86275. * Gets the midtones Saturation value.
  86276. * 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.
  86277. */
  86278. /**
  86279. * Sets the midtones Saturation value.
  86280. * 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.
  86281. */
  86282. midtonesSaturation: number;
  86283. /**
  86284. * Gets the midtones Exposure value.
  86285. * 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.
  86286. */
  86287. /**
  86288. * Sets the midtones Exposure value.
  86289. * 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.
  86290. */
  86291. midtonesExposure: number;
  86292. private _shadowsHue;
  86293. private _shadowsDensity;
  86294. private _shadowsSaturation;
  86295. private _shadowsExposure;
  86296. /**
  86297. * Gets the shadows Hue value.
  86298. * 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).
  86299. */
  86300. /**
  86301. * Sets the shadows Hue value.
  86302. * 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).
  86303. */
  86304. shadowsHue: number;
  86305. /**
  86306. * Gets the shadows Density value.
  86307. * 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.
  86308. * Values less than zero provide a filter of opposite hue.
  86309. */
  86310. /**
  86311. * Sets the shadows Density value.
  86312. * 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.
  86313. * Values less than zero provide a filter of opposite hue.
  86314. */
  86315. shadowsDensity: number;
  86316. /**
  86317. * Gets the shadows Saturation value.
  86318. * 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.
  86319. */
  86320. /**
  86321. * Sets the shadows Saturation value.
  86322. * 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.
  86323. */
  86324. shadowsSaturation: number;
  86325. /**
  86326. * Gets the shadows Exposure value.
  86327. * 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.
  86328. */
  86329. /**
  86330. * Sets the shadows Exposure value.
  86331. * 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.
  86332. */
  86333. shadowsExposure: number;
  86334. /**
  86335. * Returns the class name
  86336. * @returns The class name
  86337. */
  86338. getClassName(): string;
  86339. /**
  86340. * Binds the color curves to the shader.
  86341. * @param colorCurves The color curve to bind
  86342. * @param effect The effect to bind to
  86343. * @param positiveUniform The positive uniform shader parameter
  86344. * @param neutralUniform The neutral uniform shader parameter
  86345. * @param negativeUniform The negative uniform shader parameter
  86346. */
  86347. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86348. /**
  86349. * Prepare the list of uniforms associated with the ColorCurves effects.
  86350. * @param uniformsList The list of uniforms used in the effect
  86351. */
  86352. static PrepareUniforms(uniformsList: string[]): void;
  86353. /**
  86354. * Returns color grading data based on a hue, density, saturation and exposure value.
  86355. * @param filterHue The hue of the color filter.
  86356. * @param filterDensity The density of the color filter.
  86357. * @param saturation The saturation.
  86358. * @param exposure The exposure.
  86359. * @param result The result data container.
  86360. */
  86361. private getColorGradingDataToRef;
  86362. /**
  86363. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86364. * @param value The input slider value in range [-100,100].
  86365. * @returns Adjusted value.
  86366. */
  86367. private static applyColorGradingSliderNonlinear;
  86368. /**
  86369. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86370. * @param hue The hue (H) input.
  86371. * @param saturation The saturation (S) input.
  86372. * @param brightness The brightness (B) input.
  86373. * @result An RGBA color represented as Vector4.
  86374. */
  86375. private static fromHSBToRef;
  86376. /**
  86377. * Returns a value clamped between min and max
  86378. * @param value The value to clamp
  86379. * @param min The minimum of value
  86380. * @param max The maximum of value
  86381. * @returns The clamped value.
  86382. */
  86383. private static clamp;
  86384. /**
  86385. * Clones the current color curve instance.
  86386. * @return The cloned curves
  86387. */
  86388. clone(): ColorCurves;
  86389. /**
  86390. * Serializes the current color curve instance to a json representation.
  86391. * @return a JSON representation
  86392. */
  86393. serialize(): any;
  86394. /**
  86395. * Parses the color curve from a json representation.
  86396. * @param source the JSON source to parse
  86397. * @return The parsed curves
  86398. */
  86399. static Parse(source: any): ColorCurves;
  86400. }
  86401. }
  86402. declare module BABYLON {
  86403. /**
  86404. * Interface to follow in your material defines to integrate easily the
  86405. * Image proccessing functions.
  86406. * @hidden
  86407. */
  86408. export interface IImageProcessingConfigurationDefines {
  86409. IMAGEPROCESSING: boolean;
  86410. VIGNETTE: boolean;
  86411. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86412. VIGNETTEBLENDMODEOPAQUE: boolean;
  86413. TONEMAPPING: boolean;
  86414. TONEMAPPING_ACES: boolean;
  86415. CONTRAST: boolean;
  86416. EXPOSURE: boolean;
  86417. COLORCURVES: boolean;
  86418. COLORGRADING: boolean;
  86419. COLORGRADING3D: boolean;
  86420. SAMPLER3DGREENDEPTH: boolean;
  86421. SAMPLER3DBGRMAP: boolean;
  86422. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86423. }
  86424. /**
  86425. * @hidden
  86426. */
  86427. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86428. IMAGEPROCESSING: boolean;
  86429. VIGNETTE: boolean;
  86430. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86431. VIGNETTEBLENDMODEOPAQUE: boolean;
  86432. TONEMAPPING: boolean;
  86433. TONEMAPPING_ACES: boolean;
  86434. CONTRAST: boolean;
  86435. COLORCURVES: boolean;
  86436. COLORGRADING: boolean;
  86437. COLORGRADING3D: boolean;
  86438. SAMPLER3DGREENDEPTH: boolean;
  86439. SAMPLER3DBGRMAP: boolean;
  86440. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86441. EXPOSURE: boolean;
  86442. constructor();
  86443. }
  86444. /**
  86445. * This groups together the common properties used for image processing either in direct forward pass
  86446. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86447. * or not.
  86448. */
  86449. export class ImageProcessingConfiguration {
  86450. /**
  86451. * Default tone mapping applied in BabylonJS.
  86452. */
  86453. static readonly TONEMAPPING_STANDARD: number;
  86454. /**
  86455. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86456. * to other engines rendering to increase portability.
  86457. */
  86458. static readonly TONEMAPPING_ACES: number;
  86459. /**
  86460. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86461. */
  86462. colorCurves: Nullable<ColorCurves>;
  86463. private _colorCurvesEnabled;
  86464. /**
  86465. * Gets wether the color curves effect is enabled.
  86466. */
  86467. /**
  86468. * Sets wether the color curves effect is enabled.
  86469. */
  86470. colorCurvesEnabled: boolean;
  86471. private _colorGradingTexture;
  86472. /**
  86473. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86474. */
  86475. /**
  86476. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86477. */
  86478. colorGradingTexture: Nullable<BaseTexture>;
  86479. private _colorGradingEnabled;
  86480. /**
  86481. * Gets wether the color grading effect is enabled.
  86482. */
  86483. /**
  86484. * Sets wether the color grading effect is enabled.
  86485. */
  86486. colorGradingEnabled: boolean;
  86487. private _colorGradingWithGreenDepth;
  86488. /**
  86489. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86490. */
  86491. /**
  86492. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86493. */
  86494. colorGradingWithGreenDepth: boolean;
  86495. private _colorGradingBGR;
  86496. /**
  86497. * Gets wether the color grading texture contains BGR values.
  86498. */
  86499. /**
  86500. * Sets wether the color grading texture contains BGR values.
  86501. */
  86502. colorGradingBGR: boolean;
  86503. /** @hidden */
  86504. _exposure: number;
  86505. /**
  86506. * Gets the Exposure used in the effect.
  86507. */
  86508. /**
  86509. * Sets the Exposure used in the effect.
  86510. */
  86511. exposure: number;
  86512. private _toneMappingEnabled;
  86513. /**
  86514. * Gets wether the tone mapping effect is enabled.
  86515. */
  86516. /**
  86517. * Sets wether the tone mapping effect is enabled.
  86518. */
  86519. toneMappingEnabled: boolean;
  86520. private _toneMappingType;
  86521. /**
  86522. * Gets the type of tone mapping effect.
  86523. */
  86524. /**
  86525. * Sets the type of tone mapping effect used in BabylonJS.
  86526. */
  86527. toneMappingType: number;
  86528. protected _contrast: number;
  86529. /**
  86530. * Gets the contrast used in the effect.
  86531. */
  86532. /**
  86533. * Sets the contrast used in the effect.
  86534. */
  86535. contrast: number;
  86536. /**
  86537. * Vignette stretch size.
  86538. */
  86539. vignetteStretch: number;
  86540. /**
  86541. * Vignette centre X Offset.
  86542. */
  86543. vignetteCentreX: number;
  86544. /**
  86545. * Vignette centre Y Offset.
  86546. */
  86547. vignetteCentreY: number;
  86548. /**
  86549. * Vignette weight or intensity of the vignette effect.
  86550. */
  86551. vignetteWeight: number;
  86552. /**
  86553. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86554. * if vignetteEnabled is set to true.
  86555. */
  86556. vignetteColor: Color4;
  86557. /**
  86558. * Camera field of view used by the Vignette effect.
  86559. */
  86560. vignetteCameraFov: number;
  86561. private _vignetteBlendMode;
  86562. /**
  86563. * Gets the vignette blend mode allowing different kind of effect.
  86564. */
  86565. /**
  86566. * Sets the vignette blend mode allowing different kind of effect.
  86567. */
  86568. vignetteBlendMode: number;
  86569. private _vignetteEnabled;
  86570. /**
  86571. * Gets wether the vignette effect is enabled.
  86572. */
  86573. /**
  86574. * Sets wether the vignette effect is enabled.
  86575. */
  86576. vignetteEnabled: boolean;
  86577. private _applyByPostProcess;
  86578. /**
  86579. * Gets wether the image processing is applied through a post process or not.
  86580. */
  86581. /**
  86582. * Sets wether the image processing is applied through a post process or not.
  86583. */
  86584. applyByPostProcess: boolean;
  86585. private _isEnabled;
  86586. /**
  86587. * Gets wether the image processing is enabled or not.
  86588. */
  86589. /**
  86590. * Sets wether the image processing is enabled or not.
  86591. */
  86592. isEnabled: boolean;
  86593. /**
  86594. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86595. */
  86596. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86597. /**
  86598. * Method called each time the image processing information changes requires to recompile the effect.
  86599. */
  86600. protected _updateParameters(): void;
  86601. /**
  86602. * Gets the current class name.
  86603. * @return "ImageProcessingConfiguration"
  86604. */
  86605. getClassName(): string;
  86606. /**
  86607. * Prepare the list of uniforms associated with the Image Processing effects.
  86608. * @param uniforms The list of uniforms used in the effect
  86609. * @param defines the list of defines currently in use
  86610. */
  86611. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86612. /**
  86613. * Prepare the list of samplers associated with the Image Processing effects.
  86614. * @param samplersList The list of uniforms used in the effect
  86615. * @param defines the list of defines currently in use
  86616. */
  86617. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86618. /**
  86619. * Prepare the list of defines associated to the shader.
  86620. * @param defines the list of defines to complete
  86621. * @param forPostProcess Define if we are currently in post process mode or not
  86622. */
  86623. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86624. /**
  86625. * Returns true if all the image processing information are ready.
  86626. * @returns True if ready, otherwise, false
  86627. */
  86628. isReady(): boolean;
  86629. /**
  86630. * Binds the image processing to the shader.
  86631. * @param effect The effect to bind to
  86632. * @param aspectRatio Define the current aspect ratio of the effect
  86633. */
  86634. bind(effect: Effect, aspectRatio?: number): void;
  86635. /**
  86636. * Clones the current image processing instance.
  86637. * @return The cloned image processing
  86638. */
  86639. clone(): ImageProcessingConfiguration;
  86640. /**
  86641. * Serializes the current image processing instance to a json representation.
  86642. * @return a JSON representation
  86643. */
  86644. serialize(): any;
  86645. /**
  86646. * Parses the image processing from a json representation.
  86647. * @param source the JSON source to parse
  86648. * @return The parsed image processing
  86649. */
  86650. static Parse(source: any): ImageProcessingConfiguration;
  86651. private static _VIGNETTEMODE_MULTIPLY;
  86652. private static _VIGNETTEMODE_OPAQUE;
  86653. /**
  86654. * Used to apply the vignette as a mix with the pixel color.
  86655. */
  86656. static readonly VIGNETTEMODE_MULTIPLY: number;
  86657. /**
  86658. * Used to apply the vignette as a replacement of the pixel color.
  86659. */
  86660. static readonly VIGNETTEMODE_OPAQUE: number;
  86661. }
  86662. }
  86663. declare module BABYLON {
  86664. /**
  86665. * This represents all the required information to add a fresnel effect on a material:
  86666. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  86667. */
  86668. export class FresnelParameters {
  86669. private _isEnabled;
  86670. /**
  86671. * Define if the fresnel effect is enable or not.
  86672. */
  86673. isEnabled: boolean;
  86674. /**
  86675. * Define the color used on edges (grazing angle)
  86676. */
  86677. leftColor: Color3;
  86678. /**
  86679. * Define the color used on center
  86680. */
  86681. rightColor: Color3;
  86682. /**
  86683. * Define bias applied to computed fresnel term
  86684. */
  86685. bias: number;
  86686. /**
  86687. * Defined the power exponent applied to fresnel term
  86688. */
  86689. power: number;
  86690. /**
  86691. * Clones the current fresnel and its valuues
  86692. * @returns a clone fresnel configuration
  86693. */
  86694. clone(): FresnelParameters;
  86695. /**
  86696. * Serializes the current fresnel parameters to a JSON representation.
  86697. * @return the JSON serialization
  86698. */
  86699. serialize(): any;
  86700. /**
  86701. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  86702. * @param parsedFresnelParameters Define the JSON representation
  86703. * @returns the parsed parameters
  86704. */
  86705. static Parse(parsedFresnelParameters: any): FresnelParameters;
  86706. }
  86707. }
  86708. declare module BABYLON {
  86709. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  86710. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86711. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86712. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86713. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86714. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86715. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86716. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86717. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86718. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86719. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86720. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86721. /**
  86722. * Decorator used to define property that can be serialized as reference to a camera
  86723. * @param sourceName defines the name of the property to decorate
  86724. */
  86725. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86726. /**
  86727. * Class used to help serialization objects
  86728. */
  86729. export class SerializationHelper {
  86730. /** hidden */
  86731. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  86732. /** hidden */
  86733. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  86734. /** hidden */
  86735. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  86736. /** hidden */
  86737. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  86738. /**
  86739. * Appends the serialized animations from the source animations
  86740. * @param source Source containing the animations
  86741. * @param destination Target to store the animations
  86742. */
  86743. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  86744. /**
  86745. * Static function used to serialized a specific entity
  86746. * @param entity defines the entity to serialize
  86747. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  86748. * @returns a JSON compatible object representing the serialization of the entity
  86749. */
  86750. static Serialize<T>(entity: T, serializationObject?: any): any;
  86751. /**
  86752. * Creates a new entity from a serialization data object
  86753. * @param creationFunction defines a function used to instanciated the new entity
  86754. * @param source defines the source serialization data
  86755. * @param scene defines the hosting scene
  86756. * @param rootUrl defines the root url for resources
  86757. * @returns a new entity
  86758. */
  86759. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  86760. /**
  86761. * Clones an object
  86762. * @param creationFunction defines the function used to instanciate the new object
  86763. * @param source defines the source object
  86764. * @returns the cloned object
  86765. */
  86766. static Clone<T>(creationFunction: () => T, source: T): T;
  86767. /**
  86768. * Instanciates a new object based on a source one (some data will be shared between both object)
  86769. * @param creationFunction defines the function used to instanciate the new object
  86770. * @param source defines the source object
  86771. * @returns the new object
  86772. */
  86773. static Instanciate<T>(creationFunction: () => T, source: T): T;
  86774. }
  86775. }
  86776. declare module BABYLON {
  86777. /**
  86778. * This is the base class of all the camera used in the application.
  86779. * @see http://doc.babylonjs.com/features/cameras
  86780. */
  86781. export class Camera extends Node {
  86782. /** @hidden */
  86783. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  86784. /**
  86785. * This is the default projection mode used by the cameras.
  86786. * It helps recreating a feeling of perspective and better appreciate depth.
  86787. * This is the best way to simulate real life cameras.
  86788. */
  86789. static readonly PERSPECTIVE_CAMERA: number;
  86790. /**
  86791. * This helps creating camera with an orthographic mode.
  86792. * 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.
  86793. */
  86794. static readonly ORTHOGRAPHIC_CAMERA: number;
  86795. /**
  86796. * This is the default FOV mode for perspective cameras.
  86797. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  86798. */
  86799. static readonly FOVMODE_VERTICAL_FIXED: number;
  86800. /**
  86801. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  86802. */
  86803. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  86804. /**
  86805. * This specifies ther is no need for a camera rig.
  86806. * Basically only one eye is rendered corresponding to the camera.
  86807. */
  86808. static readonly RIG_MODE_NONE: number;
  86809. /**
  86810. * Simulates a camera Rig with one blue eye and one red eye.
  86811. * This can be use with 3d blue and red glasses.
  86812. */
  86813. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  86814. /**
  86815. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  86816. */
  86817. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  86818. /**
  86819. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  86820. */
  86821. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  86822. /**
  86823. * Defines that both eyes of the camera will be rendered over under each other.
  86824. */
  86825. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  86826. /**
  86827. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  86828. */
  86829. static readonly RIG_MODE_VR: number;
  86830. /**
  86831. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  86832. */
  86833. static readonly RIG_MODE_WEBVR: number;
  86834. /**
  86835. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  86836. */
  86837. static readonly RIG_MODE_CUSTOM: number;
  86838. /**
  86839. * Defines if by default attaching controls should prevent the default javascript event to continue.
  86840. */
  86841. static ForceAttachControlToAlwaysPreventDefault: boolean;
  86842. /**
  86843. * @hidden
  86844. * Might be removed once multiview will be a thing
  86845. */
  86846. static UseAlternateWebVRRendering: boolean;
  86847. /**
  86848. * Define the input manager associated with the camera.
  86849. */
  86850. inputs: CameraInputsManager<Camera>;
  86851. /** @hidden */
  86852. _position: Vector3;
  86853. /**
  86854. * Define the current local position of the camera in the scene
  86855. */
  86856. position: Vector3;
  86857. /**
  86858. * The vector the camera should consider as up.
  86859. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  86860. */
  86861. upVector: Vector3;
  86862. /**
  86863. * Define the current limit on the left side for an orthographic camera
  86864. * In scene unit
  86865. */
  86866. orthoLeft: Nullable<number>;
  86867. /**
  86868. * Define the current limit on the right side for an orthographic camera
  86869. * In scene unit
  86870. */
  86871. orthoRight: Nullable<number>;
  86872. /**
  86873. * Define the current limit on the bottom side for an orthographic camera
  86874. * In scene unit
  86875. */
  86876. orthoBottom: Nullable<number>;
  86877. /**
  86878. * Define the current limit on the top side for an orthographic camera
  86879. * In scene unit
  86880. */
  86881. orthoTop: Nullable<number>;
  86882. /**
  86883. * Field Of View is set in Radians. (default is 0.8)
  86884. */
  86885. fov: number;
  86886. /**
  86887. * Define the minimum distance the camera can see from.
  86888. * This is important to note that the depth buffer are not infinite and the closer it starts
  86889. * the more your scene might encounter depth fighting issue.
  86890. */
  86891. minZ: number;
  86892. /**
  86893. * Define the maximum distance the camera can see to.
  86894. * This is important to note that the depth buffer are not infinite and the further it end
  86895. * the more your scene might encounter depth fighting issue.
  86896. */
  86897. maxZ: number;
  86898. /**
  86899. * Define the default inertia of the camera.
  86900. * This helps giving a smooth feeling to the camera movement.
  86901. */
  86902. inertia: number;
  86903. /**
  86904. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  86905. */
  86906. mode: number;
  86907. /**
  86908. * Define wether the camera is intermediate.
  86909. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  86910. */
  86911. isIntermediate: boolean;
  86912. /**
  86913. * Define the viewport of the camera.
  86914. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  86915. */
  86916. viewport: Viewport;
  86917. /**
  86918. * Restricts the camera to viewing objects with the same layerMask.
  86919. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  86920. */
  86921. layerMask: number;
  86922. /**
  86923. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  86924. */
  86925. fovMode: number;
  86926. /**
  86927. * Rig mode of the camera.
  86928. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  86929. * This is normally controlled byt the camera themselves as internal use.
  86930. */
  86931. cameraRigMode: number;
  86932. /**
  86933. * Defines the distance between both "eyes" in case of a RIG
  86934. */
  86935. interaxialDistance: number;
  86936. /**
  86937. * Defines if stereoscopic rendering is done side by side or over under.
  86938. */
  86939. isStereoscopicSideBySide: boolean;
  86940. /**
  86941. * 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
  86942. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  86943. * else in the scene.
  86944. */
  86945. customRenderTargets: RenderTargetTexture[];
  86946. /**
  86947. * When set, the camera will render to this render target instead of the default canvas
  86948. */
  86949. outputRenderTarget: Nullable<RenderTargetTexture>;
  86950. /**
  86951. * Observable triggered when the camera view matrix has changed.
  86952. */
  86953. onViewMatrixChangedObservable: Observable<Camera>;
  86954. /**
  86955. * Observable triggered when the camera Projection matrix has changed.
  86956. */
  86957. onProjectionMatrixChangedObservable: Observable<Camera>;
  86958. /**
  86959. * Observable triggered when the inputs have been processed.
  86960. */
  86961. onAfterCheckInputsObservable: Observable<Camera>;
  86962. /**
  86963. * Observable triggered when reset has been called and applied to the camera.
  86964. */
  86965. onRestoreStateObservable: Observable<Camera>;
  86966. /** @hidden */
  86967. _cameraRigParams: any;
  86968. /** @hidden */
  86969. _rigCameras: Camera[];
  86970. /** @hidden */
  86971. _rigPostProcess: Nullable<PostProcess>;
  86972. protected _webvrViewMatrix: Matrix;
  86973. /** @hidden */
  86974. _skipRendering: boolean;
  86975. /** @hidden */
  86976. _alternateCamera: Camera;
  86977. /** @hidden */
  86978. _projectionMatrix: Matrix;
  86979. /** @hidden */
  86980. _postProcesses: Nullable<PostProcess>[];
  86981. /** @hidden */
  86982. _activeMeshes: SmartArray<AbstractMesh>;
  86983. protected _globalPosition: Vector3;
  86984. /** hidden */
  86985. _computedViewMatrix: Matrix;
  86986. private _doNotComputeProjectionMatrix;
  86987. private _transformMatrix;
  86988. private _frustumPlanes;
  86989. private _refreshFrustumPlanes;
  86990. private _storedFov;
  86991. private _stateStored;
  86992. /**
  86993. * Instantiates a new camera object.
  86994. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  86995. * @see http://doc.babylonjs.com/features/cameras
  86996. * @param name Defines the name of the camera in the scene
  86997. * @param position Defines the position of the camera
  86998. * @param scene Defines the scene the camera belongs too
  86999. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87000. */
  87001. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87002. /**
  87003. * Store current camera state (fov, position, etc..)
  87004. * @returns the camera
  87005. */
  87006. storeState(): Camera;
  87007. /**
  87008. * Restores the camera state values if it has been stored. You must call storeState() first
  87009. */
  87010. protected _restoreStateValues(): boolean;
  87011. /**
  87012. * Restored camera state. You must call storeState() first.
  87013. * @returns true if restored and false otherwise
  87014. */
  87015. restoreState(): boolean;
  87016. /**
  87017. * Gets the class name of the camera.
  87018. * @returns the class name
  87019. */
  87020. getClassName(): string;
  87021. /** @hidden */
  87022. readonly _isCamera: boolean;
  87023. /**
  87024. * Gets a string representation of the camera useful for debug purpose.
  87025. * @param fullDetails Defines that a more verboe level of logging is required
  87026. * @returns the string representation
  87027. */
  87028. toString(fullDetails?: boolean): string;
  87029. /**
  87030. * Gets the current world space position of the camera.
  87031. */
  87032. readonly globalPosition: Vector3;
  87033. /**
  87034. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87035. * @returns the active meshe list
  87036. */
  87037. getActiveMeshes(): SmartArray<AbstractMesh>;
  87038. /**
  87039. * Check wether a mesh is part of the current active mesh list of the camera
  87040. * @param mesh Defines the mesh to check
  87041. * @returns true if active, false otherwise
  87042. */
  87043. isActiveMesh(mesh: Mesh): boolean;
  87044. /**
  87045. * Is this camera ready to be used/rendered
  87046. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87047. * @return true if the camera is ready
  87048. */
  87049. isReady(completeCheck?: boolean): boolean;
  87050. /** @hidden */
  87051. _initCache(): void;
  87052. /** @hidden */
  87053. _updateCache(ignoreParentClass?: boolean): void;
  87054. /** @hidden */
  87055. _isSynchronized(): boolean;
  87056. /** @hidden */
  87057. _isSynchronizedViewMatrix(): boolean;
  87058. /** @hidden */
  87059. _isSynchronizedProjectionMatrix(): boolean;
  87060. /**
  87061. * Attach the input controls to a specific dom element to get the input from.
  87062. * @param element Defines the element the controls should be listened from
  87063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87064. */
  87065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87066. /**
  87067. * Detach the current controls from the specified dom element.
  87068. * @param element Defines the element to stop listening the inputs from
  87069. */
  87070. detachControl(element: HTMLElement): void;
  87071. /**
  87072. * Update the camera state according to the different inputs gathered during the frame.
  87073. */
  87074. update(): void;
  87075. /** @hidden */
  87076. _checkInputs(): void;
  87077. /** @hidden */
  87078. readonly rigCameras: Camera[];
  87079. /**
  87080. * Gets the post process used by the rig cameras
  87081. */
  87082. readonly rigPostProcess: Nullable<PostProcess>;
  87083. /**
  87084. * Internal, gets the first post proces.
  87085. * @returns the first post process to be run on this camera.
  87086. */
  87087. _getFirstPostProcess(): Nullable<PostProcess>;
  87088. private _cascadePostProcessesToRigCams;
  87089. /**
  87090. * Attach a post process to the camera.
  87091. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87092. * @param postProcess The post process to attach to the camera
  87093. * @param insertAt The position of the post process in case several of them are in use in the scene
  87094. * @returns the position the post process has been inserted at
  87095. */
  87096. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87097. /**
  87098. * Detach a post process to the camera.
  87099. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87100. * @param postProcess The post process to detach from the camera
  87101. */
  87102. detachPostProcess(postProcess: PostProcess): void;
  87103. /**
  87104. * Gets the current world matrix of the camera
  87105. */
  87106. getWorldMatrix(): Matrix;
  87107. /** @hidden */
  87108. _getViewMatrix(): Matrix;
  87109. /**
  87110. * Gets the current view matrix of the camera.
  87111. * @param force forces the camera to recompute the matrix without looking at the cached state
  87112. * @returns the view matrix
  87113. */
  87114. getViewMatrix(force?: boolean): Matrix;
  87115. /**
  87116. * Freeze the projection matrix.
  87117. * It will prevent the cache check of the camera projection compute and can speed up perf
  87118. * if no parameter of the camera are meant to change
  87119. * @param projection Defines manually a projection if necessary
  87120. */
  87121. freezeProjectionMatrix(projection?: Matrix): void;
  87122. /**
  87123. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87124. */
  87125. unfreezeProjectionMatrix(): void;
  87126. /**
  87127. * Gets the current projection matrix of the camera.
  87128. * @param force forces the camera to recompute the matrix without looking at the cached state
  87129. * @returns the projection matrix
  87130. */
  87131. getProjectionMatrix(force?: boolean): Matrix;
  87132. /**
  87133. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87134. * @returns a Matrix
  87135. */
  87136. getTransformationMatrix(): Matrix;
  87137. private _updateFrustumPlanes;
  87138. /**
  87139. * Checks if a cullable object (mesh...) is in the camera frustum
  87140. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87141. * @param target The object to check
  87142. * @returns true if the object is in frustum otherwise false
  87143. */
  87144. isInFrustum(target: ICullable): boolean;
  87145. /**
  87146. * Checks if a cullable object (mesh...) is in the camera frustum
  87147. * Unlike isInFrustum this cheks the full bounding box
  87148. * @param target The object to check
  87149. * @returns true if the object is in frustum otherwise false
  87150. */
  87151. isCompletelyInFrustum(target: ICullable): boolean;
  87152. /**
  87153. * Gets a ray in the forward direction from the camera.
  87154. * @param length Defines the length of the ray to create
  87155. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87156. * @param origin Defines the start point of the ray which defaults to the camera position
  87157. * @returns the forward ray
  87158. */
  87159. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87160. /**
  87161. * Releases resources associated with this node.
  87162. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87163. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87164. */
  87165. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87166. /** @hidden */
  87167. _isLeftCamera: boolean;
  87168. /**
  87169. * Gets the left camera of a rig setup in case of Rigged Camera
  87170. */
  87171. readonly isLeftCamera: boolean;
  87172. /** @hidden */
  87173. _isRightCamera: boolean;
  87174. /**
  87175. * Gets the right camera of a rig setup in case of Rigged Camera
  87176. */
  87177. readonly isRightCamera: boolean;
  87178. /**
  87179. * Gets the left camera of a rig setup in case of Rigged Camera
  87180. */
  87181. readonly leftCamera: Nullable<FreeCamera>;
  87182. /**
  87183. * Gets the right camera of a rig setup in case of Rigged Camera
  87184. */
  87185. readonly rightCamera: Nullable<FreeCamera>;
  87186. /**
  87187. * Gets the left camera target of a rig setup in case of Rigged Camera
  87188. * @returns the target position
  87189. */
  87190. getLeftTarget(): Nullable<Vector3>;
  87191. /**
  87192. * Gets the right camera target of a rig setup in case of Rigged Camera
  87193. * @returns the target position
  87194. */
  87195. getRightTarget(): Nullable<Vector3>;
  87196. /**
  87197. * @hidden
  87198. */
  87199. setCameraRigMode(mode: number, rigParams: any): void;
  87200. /** @hidden */
  87201. static _setStereoscopicRigMode(camera: Camera): void;
  87202. /** @hidden */
  87203. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87204. /** @hidden */
  87205. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87206. /** @hidden */
  87207. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87208. /** @hidden */
  87209. _getVRProjectionMatrix(): Matrix;
  87210. protected _updateCameraRotationMatrix(): void;
  87211. protected _updateWebVRCameraRotationMatrix(): void;
  87212. /**
  87213. * This function MUST be overwritten by the different WebVR cameras available.
  87214. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87215. * @hidden
  87216. */
  87217. _getWebVRProjectionMatrix(): Matrix;
  87218. /**
  87219. * This function MUST be overwritten by the different WebVR cameras available.
  87220. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87221. * @hidden
  87222. */
  87223. _getWebVRViewMatrix(): Matrix;
  87224. /** @hidden */
  87225. setCameraRigParameter(name: string, value: any): void;
  87226. /**
  87227. * needs to be overridden by children so sub has required properties to be copied
  87228. * @hidden
  87229. */
  87230. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87231. /**
  87232. * May need to be overridden by children
  87233. * @hidden
  87234. */
  87235. _updateRigCameras(): void;
  87236. /** @hidden */
  87237. _setupInputs(): void;
  87238. /**
  87239. * Serialiaze the camera setup to a json represention
  87240. * @returns the JSON representation
  87241. */
  87242. serialize(): any;
  87243. /**
  87244. * Clones the current camera.
  87245. * @param name The cloned camera name
  87246. * @returns the cloned camera
  87247. */
  87248. clone(name: string): Camera;
  87249. /**
  87250. * Gets the direction of the camera relative to a given local axis.
  87251. * @param localAxis Defines the reference axis to provide a relative direction.
  87252. * @return the direction
  87253. */
  87254. getDirection(localAxis: Vector3): Vector3;
  87255. /**
  87256. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87257. * @param localAxis Defines the reference axis to provide a relative direction.
  87258. * @param result Defines the vector to store the result in
  87259. */
  87260. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87261. /**
  87262. * Gets a camera constructor for a given camera type
  87263. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87264. * @param name The name of the camera the result will be able to instantiate
  87265. * @param scene The scene the result will construct the camera in
  87266. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87267. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87268. * @returns a factory method to construc the camera
  87269. */
  87270. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87271. /**
  87272. * Compute the world matrix of the camera.
  87273. * @returns the camera workd matrix
  87274. */
  87275. computeWorldMatrix(): Matrix;
  87276. /**
  87277. * Parse a JSON and creates the camera from the parsed information
  87278. * @param parsedCamera The JSON to parse
  87279. * @param scene The scene to instantiate the camera in
  87280. * @returns the newly constructed camera
  87281. */
  87282. static Parse(parsedCamera: any, scene: Scene): Camera;
  87283. }
  87284. }
  87285. declare module BABYLON {
  87286. /**
  87287. * Interface for any object that can request an animation frame
  87288. */
  87289. export interface ICustomAnimationFrameRequester {
  87290. /**
  87291. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87292. */
  87293. renderFunction?: Function;
  87294. /**
  87295. * Called to request the next frame to render to
  87296. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87297. */
  87298. requestAnimationFrame: Function;
  87299. /**
  87300. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87301. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87302. */
  87303. requestID?: number;
  87304. }
  87305. /**
  87306. * Interface containing an array of animations
  87307. */
  87308. export interface IAnimatable {
  87309. /**
  87310. * Array of animations
  87311. */
  87312. animations: Array<Animation>;
  87313. }
  87314. /** Interface used by value gradients (color, factor, ...) */
  87315. export interface IValueGradient {
  87316. /**
  87317. * Gets or sets the gradient value (between 0 and 1)
  87318. */
  87319. gradient: number;
  87320. }
  87321. /** Class used to store color4 gradient */
  87322. export class ColorGradient implements IValueGradient {
  87323. /**
  87324. * Gets or sets the gradient value (between 0 and 1)
  87325. */
  87326. gradient: number;
  87327. /**
  87328. * Gets or sets first associated color
  87329. */
  87330. color1: Color4;
  87331. /**
  87332. * Gets or sets second associated color
  87333. */
  87334. color2?: Color4;
  87335. /**
  87336. * Will get a color picked randomly between color1 and color2.
  87337. * If color2 is undefined then color1 will be used
  87338. * @param result defines the target Color4 to store the result in
  87339. */
  87340. getColorToRef(result: Color4): void;
  87341. }
  87342. /** Class used to store color 3 gradient */
  87343. export class Color3Gradient implements IValueGradient {
  87344. /**
  87345. * Gets or sets the gradient value (between 0 and 1)
  87346. */
  87347. gradient: number;
  87348. /**
  87349. * Gets or sets the associated color
  87350. */
  87351. color: Color3;
  87352. }
  87353. /** Class used to store factor gradient */
  87354. export class FactorGradient implements IValueGradient {
  87355. /**
  87356. * Gets or sets the gradient value (between 0 and 1)
  87357. */
  87358. gradient: number;
  87359. /**
  87360. * Gets or sets first associated factor
  87361. */
  87362. factor1: number;
  87363. /**
  87364. * Gets or sets second associated factor
  87365. */
  87366. factor2?: number;
  87367. /**
  87368. * Will get a number picked randomly between factor1 and factor2.
  87369. * If factor2 is undefined then factor1 will be used
  87370. * @returns the picked number
  87371. */
  87372. getFactor(): number;
  87373. }
  87374. /**
  87375. * @ignore
  87376. * Application error to support additional information when loading a file
  87377. */
  87378. export class LoadFileError extends Error {
  87379. /** defines the optional XHR request */
  87380. request?: XMLHttpRequest | undefined;
  87381. private static _setPrototypeOf;
  87382. /**
  87383. * Creates a new LoadFileError
  87384. * @param message defines the message of the error
  87385. * @param request defines the optional XHR request
  87386. */
  87387. constructor(message: string,
  87388. /** defines the optional XHR request */
  87389. request?: XMLHttpRequest | undefined);
  87390. }
  87391. /**
  87392. * Class used to define a retry strategy when error happens while loading assets
  87393. */
  87394. export class RetryStrategy {
  87395. /**
  87396. * Function used to defines an exponential back off strategy
  87397. * @param maxRetries defines the maximum number of retries (3 by default)
  87398. * @param baseInterval defines the interval between retries
  87399. * @returns the strategy function to use
  87400. */
  87401. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87402. }
  87403. /**
  87404. * File request interface
  87405. */
  87406. export interface IFileRequest {
  87407. /**
  87408. * Raised when the request is complete (success or error).
  87409. */
  87410. onCompleteObservable: Observable<IFileRequest>;
  87411. /**
  87412. * Aborts the request for a file.
  87413. */
  87414. abort: () => void;
  87415. }
  87416. /**
  87417. * Class containing a set of static utilities functions
  87418. */
  87419. export class Tools {
  87420. /**
  87421. * Gets or sets the base URL to use to load assets
  87422. */
  87423. static BaseUrl: string;
  87424. /**
  87425. * Enable/Disable Custom HTTP Request Headers globally.
  87426. * default = false
  87427. * @see CustomRequestHeaders
  87428. */
  87429. static UseCustomRequestHeaders: boolean;
  87430. /**
  87431. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  87432. * i.e. when loading files, where the server/service expects an Authorization header.
  87433. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  87434. */
  87435. static CustomRequestHeaders: {
  87436. [key: string]: string;
  87437. };
  87438. /**
  87439. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  87440. */
  87441. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87442. /**
  87443. * Default behaviour for cors in the application.
  87444. * It can be a string if the expected behavior is identical in the entire app.
  87445. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  87446. */
  87447. static CorsBehavior: string | ((url: string | string[]) => string);
  87448. /**
  87449. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  87450. * @ignorenaming
  87451. */
  87452. static UseFallbackTexture: boolean;
  87453. /**
  87454. * Use this object to register external classes like custom textures or material
  87455. * to allow the laoders to instantiate them
  87456. */
  87457. static RegisteredExternalClasses: {
  87458. [key: string]: Object;
  87459. };
  87460. /**
  87461. * Texture content used if a texture cannot loaded
  87462. * @ignorenaming
  87463. */
  87464. static fallbackTexture: string;
  87465. /**
  87466. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  87467. * @param u defines the coordinate on X axis
  87468. * @param v defines the coordinate on Y axis
  87469. * @param width defines the width of the source data
  87470. * @param height defines the height of the source data
  87471. * @param pixels defines the source byte array
  87472. * @param color defines the output color
  87473. */
  87474. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  87475. /**
  87476. * Interpolates between a and b via alpha
  87477. * @param a The lower value (returned when alpha = 0)
  87478. * @param b The upper value (returned when alpha = 1)
  87479. * @param alpha The interpolation-factor
  87480. * @return The mixed value
  87481. */
  87482. static Mix(a: number, b: number, alpha: number): number;
  87483. /**
  87484. * Tries to instantiate a new object from a given class name
  87485. * @param className defines the class name to instantiate
  87486. * @returns the new object or null if the system was not able to do the instantiation
  87487. */
  87488. static Instantiate(className: string): any;
  87489. /**
  87490. * Provides a slice function that will work even on IE
  87491. * @param data defines the array to slice
  87492. * @param start defines the start of the data (optional)
  87493. * @param end defines the end of the data (optional)
  87494. * @returns the new sliced array
  87495. */
  87496. static Slice<T>(data: T, start?: number, end?: number): T;
  87497. /**
  87498. * Polyfill for setImmediate
  87499. * @param action defines the action to execute after the current execution block
  87500. */
  87501. static SetImmediate(action: () => void): void;
  87502. /**
  87503. * Function indicating if a number is an exponent of 2
  87504. * @param value defines the value to test
  87505. * @returns true if the value is an exponent of 2
  87506. */
  87507. static IsExponentOfTwo(value: number): boolean;
  87508. private static _tmpFloatArray;
  87509. /**
  87510. * Returns the nearest 32-bit single precision float representation of a Number
  87511. * @param value A Number. If the parameter is of a different type, it will get converted
  87512. * to a number or to NaN if it cannot be converted
  87513. * @returns number
  87514. */
  87515. static FloatRound(value: number): number;
  87516. /**
  87517. * Find the next highest power of two.
  87518. * @param x Number to start search from.
  87519. * @return Next highest power of two.
  87520. */
  87521. static CeilingPOT(x: number): number;
  87522. /**
  87523. * Find the next lowest power of two.
  87524. * @param x Number to start search from.
  87525. * @return Next lowest power of two.
  87526. */
  87527. static FloorPOT(x: number): number;
  87528. /**
  87529. * Find the nearest power of two.
  87530. * @param x Number to start search from.
  87531. * @return Next nearest power of two.
  87532. */
  87533. static NearestPOT(x: number): number;
  87534. /**
  87535. * Get the closest exponent of two
  87536. * @param value defines the value to approximate
  87537. * @param max defines the maximum value to return
  87538. * @param mode defines how to define the closest value
  87539. * @returns closest exponent of two of the given value
  87540. */
  87541. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  87542. /**
  87543. * Extracts the filename from a path
  87544. * @param path defines the path to use
  87545. * @returns the filename
  87546. */
  87547. static GetFilename(path: string): string;
  87548. /**
  87549. * Extracts the "folder" part of a path (everything before the filename).
  87550. * @param uri The URI to extract the info from
  87551. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  87552. * @returns The "folder" part of the path
  87553. */
  87554. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  87555. /**
  87556. * Extracts text content from a DOM element hierarchy
  87557. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  87558. */
  87559. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  87560. /**
  87561. * Convert an angle in radians to degrees
  87562. * @param angle defines the angle to convert
  87563. * @returns the angle in degrees
  87564. */
  87565. static ToDegrees(angle: number): number;
  87566. /**
  87567. * Convert an angle in degrees to radians
  87568. * @param angle defines the angle to convert
  87569. * @returns the angle in radians
  87570. */
  87571. static ToRadians(angle: number): number;
  87572. /**
  87573. * Encode a buffer to a base64 string
  87574. * @param buffer defines the buffer to encode
  87575. * @returns the encoded string
  87576. */
  87577. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  87578. /**
  87579. * Extracts minimum and maximum values from a list of indexed positions
  87580. * @param positions defines the positions to use
  87581. * @param indices defines the indices to the positions
  87582. * @param indexStart defines the start index
  87583. * @param indexCount defines the end index
  87584. * @param bias defines bias value to add to the result
  87585. * @return minimum and maximum values
  87586. */
  87587. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87588. minimum: Vector3;
  87589. maximum: Vector3;
  87590. };
  87591. /**
  87592. * Extracts minimum and maximum values from a list of positions
  87593. * @param positions defines the positions to use
  87594. * @param start defines the start index in the positions array
  87595. * @param count defines the number of positions to handle
  87596. * @param bias defines bias value to add to the result
  87597. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87598. * @return minimum and maximum values
  87599. */
  87600. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87601. minimum: Vector3;
  87602. maximum: Vector3;
  87603. };
  87604. /**
  87605. * Returns an array if obj is not an array
  87606. * @param obj defines the object to evaluate as an array
  87607. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  87608. * @returns either obj directly if obj is an array or a new array containing obj
  87609. */
  87610. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  87611. /**
  87612. * Gets the pointer prefix to use
  87613. * @returns "pointer" if touch is enabled. Else returns "mouse"
  87614. */
  87615. static GetPointerPrefix(): string;
  87616. /**
  87617. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  87618. * @param func - the function to be called
  87619. * @param requester - the object that will request the next frame. Falls back to window.
  87620. * @returns frame number
  87621. */
  87622. static QueueNewFrame(func: () => void, requester?: any): number;
  87623. /**
  87624. * Ask the browser to promote the current element to fullscreen rendering mode
  87625. * @param element defines the DOM element to promote
  87626. */
  87627. static RequestFullscreen(element: HTMLElement): void;
  87628. /**
  87629. * Asks the browser to exit fullscreen mode
  87630. */
  87631. static ExitFullscreen(): void;
  87632. /**
  87633. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87634. * @param url define the url we are trying
  87635. * @param element define the dom element where to configure the cors policy
  87636. */
  87637. static SetCorsBehavior(url: string | string[], element: {
  87638. crossOrigin: string | null;
  87639. }): void;
  87640. /**
  87641. * Removes unwanted characters from an url
  87642. * @param url defines the url to clean
  87643. * @returns the cleaned url
  87644. */
  87645. static CleanUrl(url: string): string;
  87646. /**
  87647. * Gets or sets a function used to pre-process url before using them to load assets
  87648. */
  87649. static PreprocessUrl: (url: string) => string;
  87650. /**
  87651. * Loads an image as an HTMLImageElement.
  87652. * @param input url string, ArrayBuffer, or Blob to load
  87653. * @param onLoad callback called when the image successfully loads
  87654. * @param onError callback called when the image fails to load
  87655. * @param offlineProvider offline provider for caching
  87656. * @returns the HTMLImageElement of the loaded image
  87657. */
  87658. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  87659. /**
  87660. * Loads a file
  87661. * @param url url string, ArrayBuffer, or Blob to load
  87662. * @param onSuccess callback called when the file successfully loads
  87663. * @param onProgress callback called while file is loading (if the server supports this mode)
  87664. * @param offlineProvider defines the offline provider for caching
  87665. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87666. * @param onError callback called when the file fails to load
  87667. * @returns a file request object
  87668. */
  87669. 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;
  87670. /**
  87671. * Load a script (identified by an url). When the url returns, the
  87672. * content of this file is added into a new script element, attached to the DOM (body element)
  87673. * @param scriptUrl defines the url of the script to laod
  87674. * @param onSuccess defines the callback called when the script is loaded
  87675. * @param onError defines the callback to call if an error occurs
  87676. */
  87677. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  87678. /**
  87679. * Loads a file from a blob
  87680. * @param fileToLoad defines the blob to use
  87681. * @param callback defines the callback to call when data is loaded
  87682. * @param progressCallback defines the callback to call during loading process
  87683. * @returns a file request object
  87684. */
  87685. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  87686. /**
  87687. * Loads a file
  87688. * @param fileToLoad defines the file to load
  87689. * @param callback defines the callback to call when data is loaded
  87690. * @param progressCallBack defines the callback to call during loading process
  87691. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87692. * @returns a file request object
  87693. */
  87694. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  87695. /**
  87696. * Creates a data url from a given string content
  87697. * @param content defines the content to convert
  87698. * @returns the new data url link
  87699. */
  87700. static FileAsURL(content: string): string;
  87701. /**
  87702. * Format the given number to a specific decimal format
  87703. * @param value defines the number to format
  87704. * @param decimals defines the number of decimals to use
  87705. * @returns the formatted string
  87706. */
  87707. static Format(value: number, decimals?: number): string;
  87708. /**
  87709. * Checks if a given vector is inside a specific range
  87710. * @param v defines the vector to test
  87711. * @param min defines the minimum range
  87712. * @param max defines the maximum range
  87713. */
  87714. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  87715. /**
  87716. * Tries to copy an object by duplicating every property
  87717. * @param source defines the source object
  87718. * @param destination defines the target object
  87719. * @param doNotCopyList defines a list of properties to avoid
  87720. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  87721. */
  87722. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  87723. /**
  87724. * Gets a boolean indicating if the given object has no own property
  87725. * @param obj defines the object to test
  87726. * @returns true if object has no own property
  87727. */
  87728. static IsEmpty(obj: any): boolean;
  87729. /**
  87730. * Function used to register events at window level
  87731. * @param events defines the events to register
  87732. */
  87733. static RegisterTopRootEvents(events: {
  87734. name: string;
  87735. handler: Nullable<(e: FocusEvent) => any>;
  87736. }[]): void;
  87737. /**
  87738. * Function used to unregister events from window level
  87739. * @param events defines the events to unregister
  87740. */
  87741. static UnregisterTopRootEvents(events: {
  87742. name: string;
  87743. handler: Nullable<(e: FocusEvent) => any>;
  87744. }[]): void;
  87745. /**
  87746. * @ignore
  87747. */
  87748. static _ScreenshotCanvas: HTMLCanvasElement;
  87749. /**
  87750. * Dumps the current bound framebuffer
  87751. * @param width defines the rendering width
  87752. * @param height defines the rendering height
  87753. * @param engine defines the hosting engine
  87754. * @param successCallback defines the callback triggered once the data are available
  87755. * @param mimeType defines the mime type of the result
  87756. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  87757. */
  87758. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87759. /**
  87760. * Converts the canvas data to blob.
  87761. * This acts as a polyfill for browsers not supporting the to blob function.
  87762. * @param canvas Defines the canvas to extract the data from
  87763. * @param successCallback Defines the callback triggered once the data are available
  87764. * @param mimeType Defines the mime type of the result
  87765. */
  87766. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  87767. /**
  87768. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  87769. * @param successCallback defines the callback triggered once the data are available
  87770. * @param mimeType defines the mime type of the result
  87771. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  87772. */
  87773. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87774. /**
  87775. * Downloads a blob in the browser
  87776. * @param blob defines the blob to download
  87777. * @param fileName defines the name of the downloaded file
  87778. */
  87779. static Download(blob: Blob, fileName: string): void;
  87780. /**
  87781. * Captures a screenshot of the current rendering
  87782. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87783. * @param engine defines the rendering engine
  87784. * @param camera defines the source camera
  87785. * @param size This parameter can be set to a single number or to an object with the
  87786. * following (optional) properties: precision, width, height. If a single number is passed,
  87787. * it will be used for both width and height. If an object is passed, the screenshot size
  87788. * will be derived from the parameters. The precision property is a multiplier allowing
  87789. * rendering at a higher or lower resolution
  87790. * @param successCallback defines the callback receives a single parameter which contains the
  87791. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87792. * src parameter of an <img> to display it
  87793. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  87794. * Check your browser for supported MIME types
  87795. */
  87796. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  87797. /**
  87798. * Generates an image screenshot from the specified camera.
  87799. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87800. * @param engine The engine to use for rendering
  87801. * @param camera The camera to use for rendering
  87802. * @param size This parameter can be set to a single number or to an object with the
  87803. * following (optional) properties: precision, width, height. If a single number is passed,
  87804. * it will be used for both width and height. If an object is passed, the screenshot size
  87805. * will be derived from the parameters. The precision property is a multiplier allowing
  87806. * rendering at a higher or lower resolution
  87807. * @param successCallback The callback receives a single parameter which contains the
  87808. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87809. * src parameter of an <img> to display it
  87810. * @param mimeType The MIME type of the screenshot image (default: image/png).
  87811. * Check your browser for supported MIME types
  87812. * @param samples Texture samples (default: 1)
  87813. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  87814. * @param fileName A name for for the downloaded file.
  87815. */
  87816. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  87817. /**
  87818. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87819. * Be aware Math.random() could cause collisions, but:
  87820. * "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"
  87821. * @returns a pseudo random id
  87822. */
  87823. static RandomId(): string;
  87824. /**
  87825. * Test if the given uri is a base64 string
  87826. * @param uri The uri to test
  87827. * @return True if the uri is a base64 string or false otherwise
  87828. */
  87829. static IsBase64(uri: string): boolean;
  87830. /**
  87831. * Decode the given base64 uri.
  87832. * @param uri The uri to decode
  87833. * @return The decoded base64 data.
  87834. */
  87835. static DecodeBase64(uri: string): ArrayBuffer;
  87836. /**
  87837. * No log
  87838. */
  87839. static readonly NoneLogLevel: number;
  87840. /**
  87841. * Only message logs
  87842. */
  87843. static readonly MessageLogLevel: number;
  87844. /**
  87845. * Only warning logs
  87846. */
  87847. static readonly WarningLogLevel: number;
  87848. /**
  87849. * Only error logs
  87850. */
  87851. static readonly ErrorLogLevel: number;
  87852. /**
  87853. * All logs
  87854. */
  87855. static readonly AllLogLevel: number;
  87856. /**
  87857. * Gets a value indicating the number of loading errors
  87858. * @ignorenaming
  87859. */
  87860. static readonly errorsCount: number;
  87861. /**
  87862. * Callback called when a new log is added
  87863. */
  87864. static OnNewCacheEntry: (entry: string) => void;
  87865. /**
  87866. * Log a message to the console
  87867. * @param message defines the message to log
  87868. */
  87869. static Log(message: string): void;
  87870. /**
  87871. * Write a warning message to the console
  87872. * @param message defines the message to log
  87873. */
  87874. static Warn(message: string): void;
  87875. /**
  87876. * Write an error message to the console
  87877. * @param message defines the message to log
  87878. */
  87879. static Error(message: string): void;
  87880. /**
  87881. * Gets current log cache (list of logs)
  87882. */
  87883. static readonly LogCache: string;
  87884. /**
  87885. * Clears the log cache
  87886. */
  87887. static ClearLogCache(): void;
  87888. /**
  87889. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  87890. */
  87891. static LogLevels: number;
  87892. /**
  87893. * Checks if the loaded document was accessed via `file:`-Protocol.
  87894. * @returns boolean
  87895. */
  87896. static IsFileURL(): boolean;
  87897. /**
  87898. * Checks if the window object exists
  87899. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  87900. */
  87901. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  87902. /**
  87903. * No performance log
  87904. */
  87905. static readonly PerformanceNoneLogLevel: number;
  87906. /**
  87907. * Use user marks to log performance
  87908. */
  87909. static readonly PerformanceUserMarkLogLevel: number;
  87910. /**
  87911. * Log performance to the console
  87912. */
  87913. static readonly PerformanceConsoleLogLevel: number;
  87914. private static _performance;
  87915. /**
  87916. * Sets the current performance log level
  87917. */
  87918. static PerformanceLogLevel: number;
  87919. private static _StartPerformanceCounterDisabled;
  87920. private static _EndPerformanceCounterDisabled;
  87921. private static _StartUserMark;
  87922. private static _EndUserMark;
  87923. private static _StartPerformanceConsole;
  87924. private static _EndPerformanceConsole;
  87925. /**
  87926. * Injects the @see CustomRequestHeaders into the given request
  87927. * @param request the request that should be used for injection
  87928. */
  87929. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  87930. /**
  87931. * Starts a performance counter
  87932. */
  87933. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87934. /**
  87935. * Ends a specific performance coutner
  87936. */
  87937. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87938. /**
  87939. * Gets either window.performance.now() if supported or Date.now() else
  87940. */
  87941. static readonly Now: number;
  87942. /**
  87943. * This method will return the name of the class used to create the instance of the given object.
  87944. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  87945. * @param object the object to get the class name from
  87946. * @param isType defines if the object is actually a type
  87947. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  87948. */
  87949. static GetClassName(object: any, isType?: boolean): string;
  87950. /**
  87951. * Gets the first element of an array satisfying a given predicate
  87952. * @param array defines the array to browse
  87953. * @param predicate defines the predicate to use
  87954. * @returns null if not found or the element
  87955. */
  87956. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  87957. /**
  87958. * This method will return the name of the full name of the class, including its owning module (if any).
  87959. * 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).
  87960. * @param object the object to get the class name from
  87961. * @param isType defines if the object is actually a type
  87962. * @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.
  87963. * @ignorenaming
  87964. */
  87965. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  87966. /**
  87967. * Returns a promise that resolves after the given amount of time.
  87968. * @param delay Number of milliseconds to delay
  87969. * @returns Promise that resolves after the given amount of time
  87970. */
  87971. static DelayAsync(delay: number): Promise<void>;
  87972. /**
  87973. * Gets the current gradient from an array of IValueGradient
  87974. * @param ratio defines the current ratio to get
  87975. * @param gradients defines the array of IValueGradient
  87976. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  87977. */
  87978. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  87979. }
  87980. /**
  87981. * This class is used to track a performance counter which is number based.
  87982. * The user has access to many properties which give statistics of different nature.
  87983. *
  87984. * The implementer can track two kinds of Performance Counter: time and count.
  87985. * 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.
  87986. * 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.
  87987. */
  87988. export class PerfCounter {
  87989. /**
  87990. * Gets or sets a global boolean to turn on and off all the counters
  87991. */
  87992. static Enabled: boolean;
  87993. /**
  87994. * Returns the smallest value ever
  87995. */
  87996. readonly min: number;
  87997. /**
  87998. * Returns the biggest value ever
  87999. */
  88000. readonly max: number;
  88001. /**
  88002. * Returns the average value since the performance counter is running
  88003. */
  88004. readonly average: number;
  88005. /**
  88006. * Returns the average value of the last second the counter was monitored
  88007. */
  88008. readonly lastSecAverage: number;
  88009. /**
  88010. * Returns the current value
  88011. */
  88012. readonly current: number;
  88013. /**
  88014. * Gets the accumulated total
  88015. */
  88016. readonly total: number;
  88017. /**
  88018. * Gets the total value count
  88019. */
  88020. readonly count: number;
  88021. /**
  88022. * Creates a new counter
  88023. */
  88024. constructor();
  88025. /**
  88026. * Call this method to start monitoring a new frame.
  88027. * 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.
  88028. */
  88029. fetchNewFrame(): void;
  88030. /**
  88031. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  88032. * @param newCount the count value to add to the monitored count
  88033. * @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.
  88034. */
  88035. addCount(newCount: number, fetchResult: boolean): void;
  88036. /**
  88037. * Start monitoring this performance counter
  88038. */
  88039. beginMonitoring(): void;
  88040. /**
  88041. * Compute the time lapsed since the previous beginMonitoring() call.
  88042. * @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
  88043. */
  88044. endMonitoring(newFrame?: boolean): void;
  88045. private _fetchResult;
  88046. private _startMonitoringTime;
  88047. private _min;
  88048. private _max;
  88049. private _average;
  88050. private _current;
  88051. private _totalValueCount;
  88052. private _totalAccumulated;
  88053. private _lastSecAverage;
  88054. private _lastSecAccumulated;
  88055. private _lastSecTime;
  88056. private _lastSecValueCount;
  88057. }
  88058. /**
  88059. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88060. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88061. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88062. * @param name The name of the class, case should be preserved
  88063. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88064. */
  88065. export function className(name: string, module?: string): (target: Object) => void;
  88066. /**
  88067. * An implementation of a loop for asynchronous functions.
  88068. */
  88069. export class AsyncLoop {
  88070. /**
  88071. * Defines the number of iterations for the loop
  88072. */
  88073. iterations: number;
  88074. /**
  88075. * Defines the current index of the loop.
  88076. */
  88077. index: number;
  88078. private _done;
  88079. private _fn;
  88080. private _successCallback;
  88081. /**
  88082. * Constructor.
  88083. * @param iterations the number of iterations.
  88084. * @param func the function to run each iteration
  88085. * @param successCallback the callback that will be called upon succesful execution
  88086. * @param offset starting offset.
  88087. */
  88088. constructor(
  88089. /**
  88090. * Defines the number of iterations for the loop
  88091. */
  88092. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88093. /**
  88094. * Execute the next iteration. Must be called after the last iteration was finished.
  88095. */
  88096. executeNext(): void;
  88097. /**
  88098. * Break the loop and run the success callback.
  88099. */
  88100. breakLoop(): void;
  88101. /**
  88102. * Create and run an async loop.
  88103. * @param iterations the number of iterations.
  88104. * @param fn the function to run each iteration
  88105. * @param successCallback the callback that will be called upon succesful execution
  88106. * @param offset starting offset.
  88107. * @returns the created async loop object
  88108. */
  88109. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88110. /**
  88111. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88112. * @param iterations total number of iterations
  88113. * @param syncedIterations number of synchronous iterations in each async iteration.
  88114. * @param fn the function to call each iteration.
  88115. * @param callback a success call back that will be called when iterating stops.
  88116. * @param breakFunction a break condition (optional)
  88117. * @param timeout timeout settings for the setTimeout function. default - 0.
  88118. * @returns the created async loop object
  88119. */
  88120. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88121. }
  88122. }
  88123. declare module BABYLON {
  88124. /** @hidden */
  88125. export interface ICollisionCoordinator {
  88126. createCollider(): Collider;
  88127. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88128. init(scene: Scene): void;
  88129. }
  88130. /** @hidden */
  88131. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88132. private _scene;
  88133. private _scaledPosition;
  88134. private _scaledVelocity;
  88135. private _finalPosition;
  88136. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88137. createCollider(): Collider;
  88138. init(scene: Scene): void;
  88139. private _collideWithWorld;
  88140. }
  88141. }
  88142. declare module BABYLON {
  88143. /**
  88144. * This class defines the direct association between an animation and a target
  88145. */
  88146. export class TargetedAnimation {
  88147. /**
  88148. * Animation to perform
  88149. */
  88150. animation: Animation;
  88151. /**
  88152. * Target to animate
  88153. */
  88154. target: any;
  88155. }
  88156. /**
  88157. * Use this class to create coordinated animations on multiple targets
  88158. */
  88159. export class AnimationGroup implements IDisposable {
  88160. /** The name of the animation group */
  88161. name: string;
  88162. private _scene;
  88163. private _targetedAnimations;
  88164. private _animatables;
  88165. private _from;
  88166. private _to;
  88167. private _isStarted;
  88168. private _isPaused;
  88169. private _speedRatio;
  88170. /**
  88171. * Gets or sets the unique id of the node
  88172. */
  88173. uniqueId: number;
  88174. /**
  88175. * This observable will notify when one animation have ended
  88176. */
  88177. onAnimationEndObservable: Observable<TargetedAnimation>;
  88178. /**
  88179. * Observer raised when one animation loops
  88180. */
  88181. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88182. /**
  88183. * This observable will notify when all animations have ended.
  88184. */
  88185. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88186. /**
  88187. * This observable will notify when all animations have paused.
  88188. */
  88189. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88190. /**
  88191. * This observable will notify when all animations are playing.
  88192. */
  88193. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88194. /**
  88195. * Gets the first frame
  88196. */
  88197. readonly from: number;
  88198. /**
  88199. * Gets the last frame
  88200. */
  88201. readonly to: number;
  88202. /**
  88203. * Define if the animations are started
  88204. */
  88205. readonly isStarted: boolean;
  88206. /**
  88207. * Gets a value indicating that the current group is playing
  88208. */
  88209. readonly isPlaying: boolean;
  88210. /**
  88211. * Gets or sets the speed ratio to use for all animations
  88212. */
  88213. /**
  88214. * Gets or sets the speed ratio to use for all animations
  88215. */
  88216. speedRatio: number;
  88217. /**
  88218. * Gets the targeted animations for this animation group
  88219. */
  88220. readonly targetedAnimations: Array<TargetedAnimation>;
  88221. /**
  88222. * returning the list of animatables controlled by this animation group.
  88223. */
  88224. readonly animatables: Array<Animatable>;
  88225. /**
  88226. * Instantiates a new Animation Group.
  88227. * This helps managing several animations at once.
  88228. * @see http://doc.babylonjs.com/how_to/group
  88229. * @param name Defines the name of the group
  88230. * @param scene Defines the scene the group belongs to
  88231. */
  88232. constructor(
  88233. /** The name of the animation group */
  88234. name: string, scene?: Nullable<Scene>);
  88235. /**
  88236. * Add an animation (with its target) in the group
  88237. * @param animation defines the animation we want to add
  88238. * @param target defines the target of the animation
  88239. * @returns the TargetedAnimation object
  88240. */
  88241. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88242. /**
  88243. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88244. * It can add constant keys at begin or end
  88245. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88246. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88247. * @returns the animation group
  88248. */
  88249. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88250. /**
  88251. * Start all animations on given targets
  88252. * @param loop defines if animations must loop
  88253. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88254. * @param from defines the from key (optional)
  88255. * @param to defines the to key (optional)
  88256. * @returns the current animation group
  88257. */
  88258. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88259. /**
  88260. * Pause all animations
  88261. * @returns the animation group
  88262. */
  88263. pause(): AnimationGroup;
  88264. /**
  88265. * Play all animations to initial state
  88266. * This function will start() the animations if they were not started or will restart() them if they were paused
  88267. * @param loop defines if animations must loop
  88268. * @returns the animation group
  88269. */
  88270. play(loop?: boolean): AnimationGroup;
  88271. /**
  88272. * Reset all animations to initial state
  88273. * @returns the animation group
  88274. */
  88275. reset(): AnimationGroup;
  88276. /**
  88277. * Restart animations from key 0
  88278. * @returns the animation group
  88279. */
  88280. restart(): AnimationGroup;
  88281. /**
  88282. * Stop all animations
  88283. * @returns the animation group
  88284. */
  88285. stop(): AnimationGroup;
  88286. /**
  88287. * Set animation weight for all animatables
  88288. * @param weight defines the weight to use
  88289. * @return the animationGroup
  88290. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88291. */
  88292. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88293. /**
  88294. * Synchronize and normalize all animatables with a source animatable
  88295. * @param root defines the root animatable to synchronize with
  88296. * @return the animationGroup
  88297. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88298. */
  88299. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88300. /**
  88301. * Goes to a specific frame in this animation group
  88302. * @param frame the frame number to go to
  88303. * @return the animationGroup
  88304. */
  88305. goToFrame(frame: number): AnimationGroup;
  88306. /**
  88307. * Dispose all associated resources
  88308. */
  88309. dispose(): void;
  88310. private _checkAnimationGroupEnded;
  88311. /**
  88312. * Clone the current animation group and returns a copy
  88313. * @param newName defines the name of the new group
  88314. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88315. * @returns the new aniamtion group
  88316. */
  88317. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88318. /**
  88319. * Returns a new AnimationGroup object parsed from the source provided.
  88320. * @param parsedAnimationGroup defines the source
  88321. * @param scene defines the scene that will receive the animationGroup
  88322. * @returns a new AnimationGroup
  88323. */
  88324. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88325. /**
  88326. * Returns the string "AnimationGroup"
  88327. * @returns "AnimationGroup"
  88328. */
  88329. getClassName(): string;
  88330. /**
  88331. * Creates a detailled string about the object
  88332. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88333. * @returns a string representing the object
  88334. */
  88335. toString(fullDetails?: boolean): string;
  88336. }
  88337. }
  88338. declare module BABYLON {
  88339. /**
  88340. * Define an interface for all classes that will hold resources
  88341. */
  88342. export interface IDisposable {
  88343. /**
  88344. * Releases all held resources
  88345. */
  88346. dispose(): void;
  88347. }
  88348. /** Interface defining initialization parameters for Scene class */
  88349. export interface SceneOptions {
  88350. /**
  88351. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88352. * It will improve performance when the number of geometries becomes important.
  88353. */
  88354. useGeometryUniqueIdsMap?: boolean;
  88355. /**
  88356. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  88357. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88358. */
  88359. useMaterialMeshMap?: boolean;
  88360. /**
  88361. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88362. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88363. */
  88364. useClonedMeshhMap?: boolean;
  88365. }
  88366. /**
  88367. * Represents a scene to be rendered by the engine.
  88368. * @see http://doc.babylonjs.com/features/scene
  88369. */
  88370. export class Scene extends AbstractScene implements IAnimatable {
  88371. private static _uniqueIdCounter;
  88372. /** The fog is deactivated */
  88373. static readonly FOGMODE_NONE: number;
  88374. /** The fog density is following an exponential function */
  88375. static readonly FOGMODE_EXP: number;
  88376. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  88377. static readonly FOGMODE_EXP2: number;
  88378. /** The fog density is following a linear function. */
  88379. static readonly FOGMODE_LINEAR: number;
  88380. /**
  88381. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  88382. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88383. */
  88384. static MinDeltaTime: number;
  88385. /**
  88386. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  88387. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88388. */
  88389. static MaxDeltaTime: number;
  88390. /**
  88391. * Factory used to create the default material.
  88392. * @param name The name of the material to create
  88393. * @param scene The scene to create the material for
  88394. * @returns The default material
  88395. */
  88396. static DefaultMaterialFactory(scene: Scene): Material;
  88397. /**
  88398. * Factory used to create the a collision coordinator.
  88399. * @returns The collision coordinator
  88400. */
  88401. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  88402. /** @hidden */
  88403. readonly _isScene: boolean;
  88404. /**
  88405. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  88406. */
  88407. autoClear: boolean;
  88408. /**
  88409. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  88410. */
  88411. autoClearDepthAndStencil: boolean;
  88412. /**
  88413. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  88414. */
  88415. clearColor: Color4;
  88416. /**
  88417. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  88418. */
  88419. ambientColor: Color3;
  88420. /** @hidden */
  88421. _environmentBRDFTexture: BaseTexture;
  88422. /** @hidden */
  88423. protected _environmentTexture: Nullable<BaseTexture>;
  88424. /**
  88425. * Texture used in all pbr material as the reflection texture.
  88426. * As in the majority of the scene they are the same (exception for multi room and so on),
  88427. * this is easier to reference from here than from all the materials.
  88428. */
  88429. /**
  88430. * Texture used in all pbr material as the reflection texture.
  88431. * As in the majority of the scene they are the same (exception for multi room and so on),
  88432. * this is easier to set here than in all the materials.
  88433. */
  88434. environmentTexture: Nullable<BaseTexture>;
  88435. /** @hidden */
  88436. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88437. /**
  88438. * Default image processing configuration used either in the rendering
  88439. * Forward main pass or through the imageProcessingPostProcess if present.
  88440. * As in the majority of the scene they are the same (exception for multi camera),
  88441. * this is easier to reference from here than from all the materials and post process.
  88442. *
  88443. * No setter as we it is a shared configuration, you can set the values instead.
  88444. */
  88445. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  88446. private _forceWireframe;
  88447. /**
  88448. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  88449. */
  88450. forceWireframe: boolean;
  88451. private _forcePointsCloud;
  88452. /**
  88453. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  88454. */
  88455. forcePointsCloud: boolean;
  88456. /**
  88457. * Gets or sets the active clipplane 1
  88458. */
  88459. clipPlane: Nullable<Plane>;
  88460. /**
  88461. * Gets or sets the active clipplane 2
  88462. */
  88463. clipPlane2: Nullable<Plane>;
  88464. /**
  88465. * Gets or sets the active clipplane 3
  88466. */
  88467. clipPlane3: Nullable<Plane>;
  88468. /**
  88469. * Gets or sets the active clipplane 4
  88470. */
  88471. clipPlane4: Nullable<Plane>;
  88472. /**
  88473. * Gets or sets a boolean indicating if animations are enabled
  88474. */
  88475. animationsEnabled: boolean;
  88476. private _animationPropertiesOverride;
  88477. /**
  88478. * Gets or sets the animation properties override
  88479. */
  88480. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88481. /**
  88482. * Gets or sets a boolean indicating if a constant deltatime has to be used
  88483. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  88484. */
  88485. useConstantAnimationDeltaTime: boolean;
  88486. /**
  88487. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  88488. * Please note that it requires to run a ray cast through the scene on every frame
  88489. */
  88490. constantlyUpdateMeshUnderPointer: boolean;
  88491. /**
  88492. * Defines the HTML cursor to use when hovering over interactive elements
  88493. */
  88494. hoverCursor: string;
  88495. /**
  88496. * Defines the HTML default cursor to use (empty by default)
  88497. */
  88498. defaultCursor: string;
  88499. /**
  88500. * This is used to call preventDefault() on pointer down
  88501. * in order to block unwanted artifacts like system double clicks
  88502. */
  88503. preventDefaultOnPointerDown: boolean;
  88504. /**
  88505. * This is used to call preventDefault() on pointer up
  88506. * in order to block unwanted artifacts like system double clicks
  88507. */
  88508. preventDefaultOnPointerUp: boolean;
  88509. /**
  88510. * Gets or sets user defined metadata
  88511. */
  88512. metadata: any;
  88513. /**
  88514. * For internal use only. Please do not use.
  88515. */
  88516. reservedDataStore: any;
  88517. /**
  88518. * Gets the name of the plugin used to load this scene (null by default)
  88519. */
  88520. loadingPluginName: string;
  88521. /**
  88522. * Use this array to add regular expressions used to disable offline support for specific urls
  88523. */
  88524. disableOfflineSupportExceptionRules: RegExp[];
  88525. /**
  88526. * An event triggered when the scene is disposed.
  88527. */
  88528. onDisposeObservable: Observable<Scene>;
  88529. private _onDisposeObserver;
  88530. /** Sets a function to be executed when this scene is disposed. */
  88531. onDispose: () => void;
  88532. /**
  88533. * An event triggered before rendering the scene (right after animations and physics)
  88534. */
  88535. onBeforeRenderObservable: Observable<Scene>;
  88536. private _onBeforeRenderObserver;
  88537. /** Sets a function to be executed before rendering this scene */
  88538. beforeRender: Nullable<() => void>;
  88539. /**
  88540. * An event triggered after rendering the scene
  88541. */
  88542. onAfterRenderObservable: Observable<Scene>;
  88543. private _onAfterRenderObserver;
  88544. /** Sets a function to be executed after rendering this scene */
  88545. afterRender: Nullable<() => void>;
  88546. /**
  88547. * An event triggered before animating the scene
  88548. */
  88549. onBeforeAnimationsObservable: Observable<Scene>;
  88550. /**
  88551. * An event triggered after animations processing
  88552. */
  88553. onAfterAnimationsObservable: Observable<Scene>;
  88554. /**
  88555. * An event triggered before draw calls are ready to be sent
  88556. */
  88557. onBeforeDrawPhaseObservable: Observable<Scene>;
  88558. /**
  88559. * An event triggered after draw calls have been sent
  88560. */
  88561. onAfterDrawPhaseObservable: Observable<Scene>;
  88562. /**
  88563. * An event triggered when the scene is ready
  88564. */
  88565. onReadyObservable: Observable<Scene>;
  88566. /**
  88567. * An event triggered before rendering a camera
  88568. */
  88569. onBeforeCameraRenderObservable: Observable<Camera>;
  88570. private _onBeforeCameraRenderObserver;
  88571. /** Sets a function to be executed before rendering a camera*/
  88572. beforeCameraRender: () => void;
  88573. /**
  88574. * An event triggered after rendering a camera
  88575. */
  88576. onAfterCameraRenderObservable: Observable<Camera>;
  88577. private _onAfterCameraRenderObserver;
  88578. /** Sets a function to be executed after rendering a camera*/
  88579. afterCameraRender: () => void;
  88580. /**
  88581. * An event triggered when active meshes evaluation is about to start
  88582. */
  88583. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  88584. /**
  88585. * An event triggered when active meshes evaluation is done
  88586. */
  88587. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  88588. /**
  88589. * An event triggered when particles rendering is about to start
  88590. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88591. */
  88592. onBeforeParticlesRenderingObservable: Observable<Scene>;
  88593. /**
  88594. * An event triggered when particles rendering is done
  88595. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88596. */
  88597. onAfterParticlesRenderingObservable: Observable<Scene>;
  88598. /**
  88599. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  88600. */
  88601. onDataLoadedObservable: Observable<Scene>;
  88602. /**
  88603. * An event triggered when a camera is created
  88604. */
  88605. onNewCameraAddedObservable: Observable<Camera>;
  88606. /**
  88607. * An event triggered when a camera is removed
  88608. */
  88609. onCameraRemovedObservable: Observable<Camera>;
  88610. /**
  88611. * An event triggered when a light is created
  88612. */
  88613. onNewLightAddedObservable: Observable<Light>;
  88614. /**
  88615. * An event triggered when a light is removed
  88616. */
  88617. onLightRemovedObservable: Observable<Light>;
  88618. /**
  88619. * An event triggered when a geometry is created
  88620. */
  88621. onNewGeometryAddedObservable: Observable<Geometry>;
  88622. /**
  88623. * An event triggered when a geometry is removed
  88624. */
  88625. onGeometryRemovedObservable: Observable<Geometry>;
  88626. /**
  88627. * An event triggered when a transform node is created
  88628. */
  88629. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  88630. /**
  88631. * An event triggered when a transform node is removed
  88632. */
  88633. onTransformNodeRemovedObservable: Observable<TransformNode>;
  88634. /**
  88635. * An event triggered when a mesh is created
  88636. */
  88637. onNewMeshAddedObservable: Observable<AbstractMesh>;
  88638. /**
  88639. * An event triggered when a mesh is removed
  88640. */
  88641. onMeshRemovedObservable: Observable<AbstractMesh>;
  88642. /**
  88643. * An event triggered when a material is created
  88644. */
  88645. onNewMaterialAddedObservable: Observable<Material>;
  88646. /**
  88647. * An event triggered when a material is removed
  88648. */
  88649. onMaterialRemovedObservable: Observable<Material>;
  88650. /**
  88651. * An event triggered when a texture is created
  88652. */
  88653. onNewTextureAddedObservable: Observable<BaseTexture>;
  88654. /**
  88655. * An event triggered when a texture is removed
  88656. */
  88657. onTextureRemovedObservable: Observable<BaseTexture>;
  88658. /**
  88659. * An event triggered when render targets are about to be rendered
  88660. * Can happen multiple times per frame.
  88661. */
  88662. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  88663. /**
  88664. * An event triggered when render targets were rendered.
  88665. * Can happen multiple times per frame.
  88666. */
  88667. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  88668. /**
  88669. * An event triggered before calculating deterministic simulation step
  88670. */
  88671. onBeforeStepObservable: Observable<Scene>;
  88672. /**
  88673. * An event triggered after calculating deterministic simulation step
  88674. */
  88675. onAfterStepObservable: Observable<Scene>;
  88676. /**
  88677. * An event triggered when the activeCamera property is updated
  88678. */
  88679. onActiveCameraChanged: Observable<Scene>;
  88680. /**
  88681. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  88682. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88683. * 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)
  88684. */
  88685. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88686. /**
  88687. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  88688. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88689. * 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)
  88690. */
  88691. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88692. /**
  88693. * This Observable will when a mesh has been imported into the scene.
  88694. */
  88695. onMeshImportedObservable: Observable<AbstractMesh>;
  88696. /**
  88697. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  88698. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  88699. */
  88700. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  88701. /** @hidden */
  88702. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  88703. /**
  88704. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  88705. */
  88706. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  88707. /**
  88708. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  88709. */
  88710. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  88711. /**
  88712. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  88713. */
  88714. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  88715. private _onPointerMove;
  88716. private _onPointerDown;
  88717. private _onPointerUp;
  88718. /** Callback called when a pointer move is detected */
  88719. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88720. /** Callback called when a pointer down is detected */
  88721. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88722. /** Callback called when a pointer up is detected */
  88723. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  88724. /** Callback called when a pointer pick is detected */
  88725. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  88726. /**
  88727. * 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).
  88728. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  88729. */
  88730. onPrePointerObservable: Observable<PointerInfoPre>;
  88731. /**
  88732. * Observable event triggered each time an input event is received from the rendering canvas
  88733. */
  88734. onPointerObservable: Observable<PointerInfo>;
  88735. /**
  88736. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  88737. */
  88738. readonly unTranslatedPointer: Vector2;
  88739. /** The distance in pixel that you have to move to prevent some events */
  88740. static DragMovementThreshold: number;
  88741. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  88742. static LongPressDelay: number;
  88743. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  88744. static DoubleClickDelay: number;
  88745. /** If you need to check double click without raising a single click at first click, enable this flag */
  88746. static ExclusiveDoubleClickMode: boolean;
  88747. private _initClickEvent;
  88748. private _initActionManager;
  88749. private _delayedSimpleClick;
  88750. private _delayedSimpleClickTimeout;
  88751. private _previousDelayedSimpleClickTimeout;
  88752. private _meshPickProceed;
  88753. private _previousButtonPressed;
  88754. private _currentPickResult;
  88755. private _previousPickResult;
  88756. private _totalPointersPressed;
  88757. private _doubleClickOccured;
  88758. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  88759. cameraToUseForPointers: Nullable<Camera>;
  88760. private _pointerX;
  88761. private _pointerY;
  88762. private _unTranslatedPointerX;
  88763. private _unTranslatedPointerY;
  88764. private _startingPointerPosition;
  88765. private _previousStartingPointerPosition;
  88766. private _startingPointerTime;
  88767. private _previousStartingPointerTime;
  88768. private _pointerCaptures;
  88769. private _timeAccumulator;
  88770. private _currentStepId;
  88771. private _currentInternalStep;
  88772. /** @hidden */
  88773. _mirroredCameraPosition: Nullable<Vector3>;
  88774. /**
  88775. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  88776. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  88777. */
  88778. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  88779. /**
  88780. * Observable event triggered each time an keyboard event is received from the hosting window
  88781. */
  88782. onKeyboardObservable: Observable<KeyboardInfo>;
  88783. private _onKeyDown;
  88784. private _onKeyUp;
  88785. private _onCanvasFocusObserver;
  88786. private _onCanvasBlurObserver;
  88787. private _useRightHandedSystem;
  88788. /**
  88789. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  88790. */
  88791. useRightHandedSystem: boolean;
  88792. /**
  88793. * Sets the step Id used by deterministic lock step
  88794. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88795. * @param newStepId defines the step Id
  88796. */
  88797. setStepId(newStepId: number): void;
  88798. /**
  88799. * Gets the step Id used by deterministic lock step
  88800. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88801. * @returns the step Id
  88802. */
  88803. getStepId(): number;
  88804. /**
  88805. * Gets the internal step used by deterministic lock step
  88806. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88807. * @returns the internal step
  88808. */
  88809. getInternalStep(): number;
  88810. private _fogEnabled;
  88811. /**
  88812. * Gets or sets a boolean indicating if fog is enabled on this scene
  88813. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88814. * (Default is true)
  88815. */
  88816. fogEnabled: boolean;
  88817. private _fogMode;
  88818. /**
  88819. * Gets or sets the fog mode to use
  88820. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88821. * | mode | value |
  88822. * | --- | --- |
  88823. * | FOGMODE_NONE | 0 |
  88824. * | FOGMODE_EXP | 1 |
  88825. * | FOGMODE_EXP2 | 2 |
  88826. * | FOGMODE_LINEAR | 3 |
  88827. */
  88828. fogMode: number;
  88829. /**
  88830. * Gets or sets the fog color to use
  88831. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88832. * (Default is Color3(0.2, 0.2, 0.3))
  88833. */
  88834. fogColor: Color3;
  88835. /**
  88836. * Gets or sets the fog density to use
  88837. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88838. * (Default is 0.1)
  88839. */
  88840. fogDensity: number;
  88841. /**
  88842. * Gets or sets the fog start distance to use
  88843. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88844. * (Default is 0)
  88845. */
  88846. fogStart: number;
  88847. /**
  88848. * Gets or sets the fog end distance to use
  88849. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88850. * (Default is 1000)
  88851. */
  88852. fogEnd: number;
  88853. private _shadowsEnabled;
  88854. /**
  88855. * Gets or sets a boolean indicating if shadows are enabled on this scene
  88856. */
  88857. shadowsEnabled: boolean;
  88858. private _lightsEnabled;
  88859. /**
  88860. * Gets or sets a boolean indicating if lights are enabled on this scene
  88861. */
  88862. lightsEnabled: boolean;
  88863. /** All of the active cameras added to this scene. */
  88864. activeCameras: Camera[];
  88865. private _activeCamera;
  88866. /** Gets or sets the current active camera */
  88867. activeCamera: Nullable<Camera>;
  88868. private _defaultMaterial;
  88869. /** The default material used on meshes when no material is affected */
  88870. /** The default material used on meshes when no material is affected */
  88871. defaultMaterial: Material;
  88872. private _texturesEnabled;
  88873. /**
  88874. * Gets or sets a boolean indicating if textures are enabled on this scene
  88875. */
  88876. texturesEnabled: boolean;
  88877. /**
  88878. * Gets or sets a boolean indicating if particles are enabled on this scene
  88879. */
  88880. particlesEnabled: boolean;
  88881. /**
  88882. * Gets or sets a boolean indicating if sprites are enabled on this scene
  88883. */
  88884. spritesEnabled: boolean;
  88885. private _skeletonsEnabled;
  88886. /**
  88887. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  88888. */
  88889. skeletonsEnabled: boolean;
  88890. /**
  88891. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  88892. */
  88893. lensFlaresEnabled: boolean;
  88894. /**
  88895. * Gets or sets a boolean indicating if collisions are enabled on this scene
  88896. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88897. */
  88898. collisionsEnabled: boolean;
  88899. private _collisionCoordinator;
  88900. /** @hidden */
  88901. readonly collisionCoordinator: ICollisionCoordinator;
  88902. /**
  88903. * Defines the gravity applied to this scene (used only for collisions)
  88904. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88905. */
  88906. gravity: Vector3;
  88907. /**
  88908. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  88909. */
  88910. postProcessesEnabled: boolean;
  88911. /**
  88912. * The list of postprocesses added to the scene
  88913. */
  88914. postProcesses: PostProcess[];
  88915. /**
  88916. * Gets the current postprocess manager
  88917. */
  88918. postProcessManager: PostProcessManager;
  88919. /**
  88920. * Gets or sets a boolean indicating if render targets are enabled on this scene
  88921. */
  88922. renderTargetsEnabled: boolean;
  88923. /**
  88924. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  88925. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  88926. */
  88927. dumpNextRenderTargets: boolean;
  88928. /**
  88929. * The list of user defined render targets added to the scene
  88930. */
  88931. customRenderTargets: RenderTargetTexture[];
  88932. /**
  88933. * Defines if texture loading must be delayed
  88934. * If true, textures will only be loaded when they need to be rendered
  88935. */
  88936. useDelayedTextureLoading: boolean;
  88937. /**
  88938. * Gets the list of meshes imported to the scene through SceneLoader
  88939. */
  88940. importedMeshesFiles: String[];
  88941. /**
  88942. * Gets or sets a boolean indicating if probes are enabled on this scene
  88943. */
  88944. probesEnabled: boolean;
  88945. /**
  88946. * Gets or sets the current offline provider to use to store scene data
  88947. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  88948. */
  88949. offlineProvider: IOfflineProvider;
  88950. /**
  88951. * Gets or sets the action manager associated with the scene
  88952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88953. */
  88954. actionManager: AbstractActionManager;
  88955. private _meshesForIntersections;
  88956. /**
  88957. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  88958. */
  88959. proceduralTexturesEnabled: boolean;
  88960. private _engine;
  88961. private _totalVertices;
  88962. /** @hidden */
  88963. _activeIndices: PerfCounter;
  88964. /** @hidden */
  88965. _activeParticles: PerfCounter;
  88966. /** @hidden */
  88967. _activeBones: PerfCounter;
  88968. private _animationRatio;
  88969. /** @hidden */
  88970. _animationTimeLast: number;
  88971. /** @hidden */
  88972. _animationTime: number;
  88973. /**
  88974. * Gets or sets a general scale for animation speed
  88975. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  88976. */
  88977. animationTimeScale: number;
  88978. /** @hidden */
  88979. _cachedMaterial: Nullable<Material>;
  88980. /** @hidden */
  88981. _cachedEffect: Nullable<Effect>;
  88982. /** @hidden */
  88983. _cachedVisibility: Nullable<number>;
  88984. private _renderId;
  88985. private _frameId;
  88986. private _executeWhenReadyTimeoutId;
  88987. private _intermediateRendering;
  88988. private _viewUpdateFlag;
  88989. private _projectionUpdateFlag;
  88990. private _alternateViewUpdateFlag;
  88991. private _alternateProjectionUpdateFlag;
  88992. /** @hidden */
  88993. _toBeDisposed: Nullable<IDisposable>[];
  88994. private _activeRequests;
  88995. /** @hidden */
  88996. _pendingData: any[];
  88997. private _isDisposed;
  88998. /**
  88999. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  89000. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  89001. */
  89002. dispatchAllSubMeshesOfActiveMeshes: boolean;
  89003. private _activeMeshes;
  89004. private _processedMaterials;
  89005. private _renderTargets;
  89006. /** @hidden */
  89007. _activeParticleSystems: SmartArray<IParticleSystem>;
  89008. private _activeSkeletons;
  89009. private _softwareSkinnedMeshes;
  89010. private _renderingManager;
  89011. /** @hidden */
  89012. _activeAnimatables: Animatable[];
  89013. private _transformMatrix;
  89014. private _sceneUbo;
  89015. private _alternateSceneUbo;
  89016. private _viewMatrix;
  89017. private _projectionMatrix;
  89018. private _alternateViewMatrix;
  89019. private _alternateProjectionMatrix;
  89020. private _alternateTransformMatrix;
  89021. private _useAlternateCameraConfiguration;
  89022. private _alternateRendering;
  89023. private _wheelEventName;
  89024. /** @hidden */
  89025. _forcedViewPosition: Nullable<Vector3>;
  89026. /** @hidden */
  89027. readonly _isAlternateRenderingEnabled: boolean;
  89028. private _frustumPlanes;
  89029. /**
  89030. * Gets the list of frustum planes (built from the active camera)
  89031. */
  89032. readonly frustumPlanes: Plane[];
  89033. /**
  89034. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  89035. * This is useful if there are more lights that the maximum simulteanous authorized
  89036. */
  89037. requireLightSorting: boolean;
  89038. /** @hidden */
  89039. readonly useMaterialMeshMap: boolean;
  89040. /** @hidden */
  89041. readonly useClonedMeshhMap: boolean;
  89042. private _pointerOverMesh;
  89043. private _pickedDownMesh;
  89044. private _pickedUpMesh;
  89045. private _externalData;
  89046. private _uid;
  89047. /**
  89048. * @hidden
  89049. * Backing store of defined scene components.
  89050. */
  89051. _components: ISceneComponent[];
  89052. /**
  89053. * @hidden
  89054. * Backing store of defined scene components.
  89055. */
  89056. _serializableComponents: ISceneSerializableComponent[];
  89057. /**
  89058. * List of components to register on the next registration step.
  89059. */
  89060. private _transientComponents;
  89061. /**
  89062. * Registers the transient components if needed.
  89063. */
  89064. private _registerTransientComponents;
  89065. /**
  89066. * @hidden
  89067. * Add a component to the scene.
  89068. * Note that the ccomponent could be registered on th next frame if this is called after
  89069. * the register component stage.
  89070. * @param component Defines the component to add to the scene
  89071. */
  89072. _addComponent(component: ISceneComponent): void;
  89073. /**
  89074. * @hidden
  89075. * Gets a component from the scene.
  89076. * @param name defines the name of the component to retrieve
  89077. * @returns the component or null if not present
  89078. */
  89079. _getComponent(name: string): Nullable<ISceneComponent>;
  89080. /**
  89081. * @hidden
  89082. * Defines the actions happening before camera updates.
  89083. */
  89084. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89085. /**
  89086. * @hidden
  89087. * Defines the actions happening before clear the canvas.
  89088. */
  89089. _beforeClearStage: Stage<SimpleStageAction>;
  89090. /**
  89091. * @hidden
  89092. * Defines the actions when collecting render targets for the frame.
  89093. */
  89094. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89095. /**
  89096. * @hidden
  89097. * Defines the actions happening for one camera in the frame.
  89098. */
  89099. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89100. /**
  89101. * @hidden
  89102. * Defines the actions happening during the per mesh ready checks.
  89103. */
  89104. _isReadyForMeshStage: Stage<MeshStageAction>;
  89105. /**
  89106. * @hidden
  89107. * Defines the actions happening before evaluate active mesh checks.
  89108. */
  89109. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89110. /**
  89111. * @hidden
  89112. * Defines the actions happening during the evaluate sub mesh checks.
  89113. */
  89114. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89115. /**
  89116. * @hidden
  89117. * Defines the actions happening during the active mesh stage.
  89118. */
  89119. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89120. /**
  89121. * @hidden
  89122. * Defines the actions happening during the per camera render target step.
  89123. */
  89124. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89125. /**
  89126. * @hidden
  89127. * Defines the actions happening just before the active camera is drawing.
  89128. */
  89129. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89130. /**
  89131. * @hidden
  89132. * Defines the actions happening just before a render target is drawing.
  89133. */
  89134. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89135. /**
  89136. * @hidden
  89137. * Defines the actions happening just before a rendering group is drawing.
  89138. */
  89139. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89140. /**
  89141. * @hidden
  89142. * Defines the actions happening just before a mesh is drawing.
  89143. */
  89144. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89145. /**
  89146. * @hidden
  89147. * Defines the actions happening just after a mesh has been drawn.
  89148. */
  89149. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89150. /**
  89151. * @hidden
  89152. * Defines the actions happening just after a rendering group has been drawn.
  89153. */
  89154. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89155. /**
  89156. * @hidden
  89157. * Defines the actions happening just after the active camera has been drawn.
  89158. */
  89159. _afterCameraDrawStage: Stage<CameraStageAction>;
  89160. /**
  89161. * @hidden
  89162. * Defines the actions happening just after a render target has been drawn.
  89163. */
  89164. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89165. /**
  89166. * @hidden
  89167. * Defines the actions happening just after rendering all cameras and computing intersections.
  89168. */
  89169. _afterRenderStage: Stage<SimpleStageAction>;
  89170. /**
  89171. * @hidden
  89172. * Defines the actions happening when a pointer move event happens.
  89173. */
  89174. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89175. /**
  89176. * @hidden
  89177. * Defines the actions happening when a pointer down event happens.
  89178. */
  89179. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89180. /**
  89181. * @hidden
  89182. * Defines the actions happening when a pointer up event happens.
  89183. */
  89184. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89185. /**
  89186. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89187. */
  89188. private geometriesByUniqueId;
  89189. /**
  89190. * Creates a new Scene
  89191. * @param engine defines the engine to use to render this scene
  89192. * @param options defines the scene options
  89193. */
  89194. constructor(engine: Engine, options?: SceneOptions);
  89195. private _defaultMeshCandidates;
  89196. /**
  89197. * @hidden
  89198. */
  89199. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89200. private _defaultSubMeshCandidates;
  89201. /**
  89202. * @hidden
  89203. */
  89204. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89205. /**
  89206. * Sets the default candidate providers for the scene.
  89207. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89208. * and getCollidingSubMeshCandidates to their default function
  89209. */
  89210. setDefaultCandidateProviders(): void;
  89211. /**
  89212. * Gets the mesh that is currently under the pointer
  89213. */
  89214. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89215. /**
  89216. * Gets or sets the current on-screen X position of the pointer
  89217. */
  89218. pointerX: number;
  89219. /**
  89220. * Gets or sets the current on-screen Y position of the pointer
  89221. */
  89222. pointerY: number;
  89223. /**
  89224. * Gets the cached material (ie. the latest rendered one)
  89225. * @returns the cached material
  89226. */
  89227. getCachedMaterial(): Nullable<Material>;
  89228. /**
  89229. * Gets the cached effect (ie. the latest rendered one)
  89230. * @returns the cached effect
  89231. */
  89232. getCachedEffect(): Nullable<Effect>;
  89233. /**
  89234. * Gets the cached visibility state (ie. the latest rendered one)
  89235. * @returns the cached visibility state
  89236. */
  89237. getCachedVisibility(): Nullable<number>;
  89238. /**
  89239. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89240. * @param material defines the current material
  89241. * @param effect defines the current effect
  89242. * @param visibility defines the current visibility state
  89243. * @returns true if one parameter is not cached
  89244. */
  89245. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89246. /**
  89247. * Gets the engine associated with the scene
  89248. * @returns an Engine
  89249. */
  89250. getEngine(): Engine;
  89251. /**
  89252. * Gets the total number of vertices rendered per frame
  89253. * @returns the total number of vertices rendered per frame
  89254. */
  89255. getTotalVertices(): number;
  89256. /**
  89257. * Gets the performance counter for total vertices
  89258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89259. */
  89260. readonly totalVerticesPerfCounter: PerfCounter;
  89261. /**
  89262. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89263. * @returns the total number of active indices rendered per frame
  89264. */
  89265. getActiveIndices(): number;
  89266. /**
  89267. * Gets the performance counter for active indices
  89268. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89269. */
  89270. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89271. /**
  89272. * Gets the total number of active particles rendered per frame
  89273. * @returns the total number of active particles rendered per frame
  89274. */
  89275. getActiveParticles(): number;
  89276. /**
  89277. * Gets the performance counter for active particles
  89278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89279. */
  89280. readonly activeParticlesPerfCounter: PerfCounter;
  89281. /**
  89282. * Gets the total number of active bones rendered per frame
  89283. * @returns the total number of active bones rendered per frame
  89284. */
  89285. getActiveBones(): number;
  89286. /**
  89287. * Gets the performance counter for active bones
  89288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89289. */
  89290. readonly activeBonesPerfCounter: PerfCounter;
  89291. /**
  89292. * Gets the array of active meshes
  89293. * @returns an array of AbstractMesh
  89294. */
  89295. getActiveMeshes(): SmartArray<AbstractMesh>;
  89296. /**
  89297. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89298. * @returns a number
  89299. */
  89300. getAnimationRatio(): number;
  89301. /**
  89302. * Gets an unique Id for the current render phase
  89303. * @returns a number
  89304. */
  89305. getRenderId(): number;
  89306. /**
  89307. * Gets an unique Id for the current frame
  89308. * @returns a number
  89309. */
  89310. getFrameId(): number;
  89311. /** Call this function if you want to manually increment the render Id*/
  89312. incrementRenderId(): void;
  89313. private _updatePointerPosition;
  89314. private _createUbo;
  89315. private _createAlternateUbo;
  89316. private _setRayOnPointerInfo;
  89317. /**
  89318. * Use this method to simulate a pointer move on a mesh
  89319. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89320. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89321. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89322. * @returns the current scene
  89323. */
  89324. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89325. private _processPointerMove;
  89326. private _checkPrePointerObservable;
  89327. /**
  89328. * Use this method to simulate a pointer down on a mesh
  89329. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89330. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89331. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89332. * @returns the current scene
  89333. */
  89334. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89335. private _processPointerDown;
  89336. /**
  89337. * Use this method to simulate a pointer up on a mesh
  89338. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89339. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89340. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89341. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89342. * @returns the current scene
  89343. */
  89344. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89345. private _processPointerUp;
  89346. /**
  89347. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89348. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89349. * @returns true if the pointer was captured
  89350. */
  89351. isPointerCaptured(pointerId?: number): boolean;
  89352. /** @hidden */
  89353. _isPointerSwiping(): boolean;
  89354. /**
  89355. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89356. * @param attachUp defines if you want to attach events to pointerup
  89357. * @param attachDown defines if you want to attach events to pointerdown
  89358. * @param attachMove defines if you want to attach events to pointermove
  89359. */
  89360. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  89361. /** Detaches all event handlers*/
  89362. detachControl(): void;
  89363. /**
  89364. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  89365. * Delay loaded resources are not taking in account
  89366. * @return true if all required resources are ready
  89367. */
  89368. isReady(): boolean;
  89369. /** Resets all cached information relative to material (including effect and visibility) */
  89370. resetCachedMaterial(): void;
  89371. /**
  89372. * Registers a function to be called before every frame render
  89373. * @param func defines the function to register
  89374. */
  89375. registerBeforeRender(func: () => void): void;
  89376. /**
  89377. * Unregisters a function called before every frame render
  89378. * @param func defines the function to unregister
  89379. */
  89380. unregisterBeforeRender(func: () => void): void;
  89381. /**
  89382. * Registers a function to be called after every frame render
  89383. * @param func defines the function to register
  89384. */
  89385. registerAfterRender(func: () => void): void;
  89386. /**
  89387. * Unregisters a function called after every frame render
  89388. * @param func defines the function to unregister
  89389. */
  89390. unregisterAfterRender(func: () => void): void;
  89391. private _executeOnceBeforeRender;
  89392. /**
  89393. * The provided function will run before render once and will be disposed afterwards.
  89394. * A timeout delay can be provided so that the function will be executed in N ms.
  89395. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  89396. * @param func The function to be executed.
  89397. * @param timeout optional delay in ms
  89398. */
  89399. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  89400. /** @hidden */
  89401. _addPendingData(data: any): void;
  89402. /** @hidden */
  89403. _removePendingData(data: any): void;
  89404. /**
  89405. * Returns the number of items waiting to be loaded
  89406. * @returns the number of items waiting to be loaded
  89407. */
  89408. getWaitingItemsCount(): number;
  89409. /**
  89410. * Returns a boolean indicating if the scene is still loading data
  89411. */
  89412. readonly isLoading: boolean;
  89413. /**
  89414. * Registers a function to be executed when the scene is ready
  89415. * @param {Function} func - the function to be executed
  89416. */
  89417. executeWhenReady(func: () => void): void;
  89418. /**
  89419. * Returns a promise that resolves when the scene is ready
  89420. * @returns A promise that resolves when the scene is ready
  89421. */
  89422. whenReadyAsync(): Promise<void>;
  89423. /** @hidden */
  89424. _checkIsReady(): void;
  89425. /**
  89426. * Gets all animatable attached to the scene
  89427. */
  89428. readonly animatables: Animatable[];
  89429. /**
  89430. * Resets the last animation time frame.
  89431. * Useful to override when animations start running when loading a scene for the first time.
  89432. */
  89433. resetLastAnimationTimeFrame(): void;
  89434. /** @hidden */
  89435. _switchToAlternateCameraConfiguration(active: boolean): void;
  89436. /**
  89437. * Gets the current view matrix
  89438. * @returns a Matrix
  89439. */
  89440. getViewMatrix(): Matrix;
  89441. /**
  89442. * Gets the current projection matrix
  89443. * @returns a Matrix
  89444. */
  89445. getProjectionMatrix(): Matrix;
  89446. /**
  89447. * Gets the current transform matrix
  89448. * @returns a Matrix made of View * Projection
  89449. */
  89450. getTransformMatrix(): Matrix;
  89451. /**
  89452. * Sets the current transform matrix
  89453. * @param view defines the View matrix to use
  89454. * @param projection defines the Projection matrix to use
  89455. */
  89456. setTransformMatrix(view: Matrix, projection: Matrix): void;
  89457. /** @hidden */
  89458. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  89459. /**
  89460. * Gets the uniform buffer used to store scene data
  89461. * @returns a UniformBuffer
  89462. */
  89463. getSceneUniformBuffer(): UniformBuffer;
  89464. /**
  89465. * Gets an unique (relatively to the current scene) Id
  89466. * @returns an unique number for the scene
  89467. */
  89468. getUniqueId(): number;
  89469. /**
  89470. * Add a mesh to the list of scene's meshes
  89471. * @param newMesh defines the mesh to add
  89472. * @param recursive if all child meshes should also be added to the scene
  89473. */
  89474. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  89475. /**
  89476. * Remove a mesh for the list of scene's meshes
  89477. * @param toRemove defines the mesh to remove
  89478. * @param recursive if all child meshes should also be removed from the scene
  89479. * @returns the index where the mesh was in the mesh list
  89480. */
  89481. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  89482. /**
  89483. * Add a transform node to the list of scene's transform nodes
  89484. * @param newTransformNode defines the transform node to add
  89485. */
  89486. addTransformNode(newTransformNode: TransformNode): void;
  89487. /**
  89488. * Remove a transform node for the list of scene's transform nodes
  89489. * @param toRemove defines the transform node to remove
  89490. * @returns the index where the transform node was in the transform node list
  89491. */
  89492. removeTransformNode(toRemove: TransformNode): number;
  89493. /**
  89494. * Remove a skeleton for the list of scene's skeletons
  89495. * @param toRemove defines the skeleton to remove
  89496. * @returns the index where the skeleton was in the skeleton list
  89497. */
  89498. removeSkeleton(toRemove: Skeleton): number;
  89499. /**
  89500. * Remove a morph target for the list of scene's morph targets
  89501. * @param toRemove defines the morph target to remove
  89502. * @returns the index where the morph target was in the morph target list
  89503. */
  89504. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  89505. /**
  89506. * Remove a light for the list of scene's lights
  89507. * @param toRemove defines the light to remove
  89508. * @returns the index where the light was in the light list
  89509. */
  89510. removeLight(toRemove: Light): number;
  89511. /**
  89512. * Remove a camera for the list of scene's cameras
  89513. * @param toRemove defines the camera to remove
  89514. * @returns the index where the camera was in the camera list
  89515. */
  89516. removeCamera(toRemove: Camera): number;
  89517. /**
  89518. * Remove a particle system for the list of scene's particle systems
  89519. * @param toRemove defines the particle system to remove
  89520. * @returns the index where the particle system was in the particle system list
  89521. */
  89522. removeParticleSystem(toRemove: IParticleSystem): number;
  89523. /**
  89524. * Remove a animation for the list of scene's animations
  89525. * @param toRemove defines the animation to remove
  89526. * @returns the index where the animation was in the animation list
  89527. */
  89528. removeAnimation(toRemove: Animation): number;
  89529. /**
  89530. * Removes the given animation group from this scene.
  89531. * @param toRemove The animation group to remove
  89532. * @returns The index of the removed animation group
  89533. */
  89534. removeAnimationGroup(toRemove: AnimationGroup): number;
  89535. /**
  89536. * Removes the given multi-material from this scene.
  89537. * @param toRemove The multi-material to remove
  89538. * @returns The index of the removed multi-material
  89539. */
  89540. removeMultiMaterial(toRemove: MultiMaterial): number;
  89541. /**
  89542. * Removes the given material from this scene.
  89543. * @param toRemove The material to remove
  89544. * @returns The index of the removed material
  89545. */
  89546. removeMaterial(toRemove: Material): number;
  89547. /**
  89548. * Removes the given action manager from this scene.
  89549. * @param toRemove The action manager to remove
  89550. * @returns The index of the removed action manager
  89551. */
  89552. removeActionManager(toRemove: AbstractActionManager): number;
  89553. /**
  89554. * Removes the given texture from this scene.
  89555. * @param toRemove The texture to remove
  89556. * @returns The index of the removed texture
  89557. */
  89558. removeTexture(toRemove: BaseTexture): number;
  89559. /**
  89560. * Adds the given light to this scene
  89561. * @param newLight The light to add
  89562. */
  89563. addLight(newLight: Light): void;
  89564. /**
  89565. * Sorts the list list based on light priorities
  89566. */
  89567. sortLightsByPriority(): void;
  89568. /**
  89569. * Adds the given camera to this scene
  89570. * @param newCamera The camera to add
  89571. */
  89572. addCamera(newCamera: Camera): void;
  89573. /**
  89574. * Adds the given skeleton to this scene
  89575. * @param newSkeleton The skeleton to add
  89576. */
  89577. addSkeleton(newSkeleton: Skeleton): void;
  89578. /**
  89579. * Adds the given particle system to this scene
  89580. * @param newParticleSystem The particle system to add
  89581. */
  89582. addParticleSystem(newParticleSystem: IParticleSystem): void;
  89583. /**
  89584. * Adds the given animation to this scene
  89585. * @param newAnimation The animation to add
  89586. */
  89587. addAnimation(newAnimation: Animation): void;
  89588. /**
  89589. * Adds the given animation group to this scene.
  89590. * @param newAnimationGroup The animation group to add
  89591. */
  89592. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  89593. /**
  89594. * Adds the given multi-material to this scene
  89595. * @param newMultiMaterial The multi-material to add
  89596. */
  89597. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  89598. /**
  89599. * Adds the given material to this scene
  89600. * @param newMaterial The material to add
  89601. */
  89602. addMaterial(newMaterial: Material): void;
  89603. /**
  89604. * Adds the given morph target to this scene
  89605. * @param newMorphTargetManager The morph target to add
  89606. */
  89607. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  89608. /**
  89609. * Adds the given geometry to this scene
  89610. * @param newGeometry The geometry to add
  89611. */
  89612. addGeometry(newGeometry: Geometry): void;
  89613. /**
  89614. * Adds the given action manager to this scene
  89615. * @param newActionManager The action manager to add
  89616. */
  89617. addActionManager(newActionManager: AbstractActionManager): void;
  89618. /**
  89619. * Adds the given texture to this scene.
  89620. * @param newTexture The texture to add
  89621. */
  89622. addTexture(newTexture: BaseTexture): void;
  89623. /**
  89624. * Switch active camera
  89625. * @param newCamera defines the new active camera
  89626. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  89627. */
  89628. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  89629. /**
  89630. * sets the active camera of the scene using its ID
  89631. * @param id defines the camera's ID
  89632. * @return the new active camera or null if none found.
  89633. */
  89634. setActiveCameraByID(id: string): Nullable<Camera>;
  89635. /**
  89636. * sets the active camera of the scene using its name
  89637. * @param name defines the camera's name
  89638. * @returns the new active camera or null if none found.
  89639. */
  89640. setActiveCameraByName(name: string): Nullable<Camera>;
  89641. /**
  89642. * get an animation group using its name
  89643. * @param name defines the material's name
  89644. * @return the animation group or null if none found.
  89645. */
  89646. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  89647. /**
  89648. * get a material using its id
  89649. * @param id defines the material's ID
  89650. * @return the material or null if none found.
  89651. */
  89652. getMaterialByID(id: string): Nullable<Material>;
  89653. /**
  89654. * Gets a material using its name
  89655. * @param name defines the material's name
  89656. * @return the material or null if none found.
  89657. */
  89658. getMaterialByName(name: string): Nullable<Material>;
  89659. /**
  89660. * Gets a camera using its id
  89661. * @param id defines the id to look for
  89662. * @returns the camera or null if not found
  89663. */
  89664. getCameraByID(id: string): Nullable<Camera>;
  89665. /**
  89666. * Gets a camera using its unique id
  89667. * @param uniqueId defines the unique id to look for
  89668. * @returns the camera or null if not found
  89669. */
  89670. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  89671. /**
  89672. * Gets a camera using its name
  89673. * @param name defines the camera's name
  89674. * @return the camera or null if none found.
  89675. */
  89676. getCameraByName(name: string): Nullable<Camera>;
  89677. /**
  89678. * Gets a bone using its id
  89679. * @param id defines the bone's id
  89680. * @return the bone or null if not found
  89681. */
  89682. getBoneByID(id: string): Nullable<Bone>;
  89683. /**
  89684. * Gets a bone using its id
  89685. * @param name defines the bone's name
  89686. * @return the bone or null if not found
  89687. */
  89688. getBoneByName(name: string): Nullable<Bone>;
  89689. /**
  89690. * Gets a light node using its name
  89691. * @param name defines the the light's name
  89692. * @return the light or null if none found.
  89693. */
  89694. getLightByName(name: string): Nullable<Light>;
  89695. /**
  89696. * Gets a light node using its id
  89697. * @param id defines the light's id
  89698. * @return the light or null if none found.
  89699. */
  89700. getLightByID(id: string): Nullable<Light>;
  89701. /**
  89702. * Gets a light node using its scene-generated unique ID
  89703. * @param uniqueId defines the light's unique id
  89704. * @return the light or null if none found.
  89705. */
  89706. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  89707. /**
  89708. * Gets a particle system by id
  89709. * @param id defines the particle system id
  89710. * @return the corresponding system or null if none found
  89711. */
  89712. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  89713. /**
  89714. * Gets a geometry using its ID
  89715. * @param id defines the geometry's id
  89716. * @return the geometry or null if none found.
  89717. */
  89718. getGeometryByID(id: string): Nullable<Geometry>;
  89719. private _getGeometryByUniqueID;
  89720. /**
  89721. * Add a new geometry to this scene
  89722. * @param geometry defines the geometry to be added to the scene.
  89723. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  89724. * @return a boolean defining if the geometry was added or not
  89725. */
  89726. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  89727. /**
  89728. * Removes an existing geometry
  89729. * @param geometry defines the geometry to be removed from the scene
  89730. * @return a boolean defining if the geometry was removed or not
  89731. */
  89732. removeGeometry(geometry: Geometry): boolean;
  89733. /**
  89734. * Gets the list of geometries attached to the scene
  89735. * @returns an array of Geometry
  89736. */
  89737. getGeometries(): Geometry[];
  89738. /**
  89739. * Gets the first added mesh found of a given ID
  89740. * @param id defines the id to search for
  89741. * @return the mesh found or null if not found at all
  89742. */
  89743. getMeshByID(id: string): Nullable<AbstractMesh>;
  89744. /**
  89745. * Gets a list of meshes using their id
  89746. * @param id defines the id to search for
  89747. * @returns a list of meshes
  89748. */
  89749. getMeshesByID(id: string): Array<AbstractMesh>;
  89750. /**
  89751. * Gets the first added transform node found of a given ID
  89752. * @param id defines the id to search for
  89753. * @return the found transform node or null if not found at all.
  89754. */
  89755. getTransformNodeByID(id: string): Nullable<TransformNode>;
  89756. /**
  89757. * Gets a list of transform nodes using their id
  89758. * @param id defines the id to search for
  89759. * @returns a list of transform nodes
  89760. */
  89761. getTransformNodesByID(id: string): Array<TransformNode>;
  89762. /**
  89763. * Gets a mesh with its auto-generated unique id
  89764. * @param uniqueId defines the unique id to search for
  89765. * @return the found mesh or null if not found at all.
  89766. */
  89767. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  89768. /**
  89769. * Gets a the last added mesh using a given id
  89770. * @param id defines the id to search for
  89771. * @return the found mesh or null if not found at all.
  89772. */
  89773. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  89774. /**
  89775. * Gets a the last added node (Mesh, Camera, Light) using a given id
  89776. * @param id defines the id to search for
  89777. * @return the found node or null if not found at all
  89778. */
  89779. getLastEntryByID(id: string): Nullable<Node>;
  89780. /**
  89781. * Gets a node (Mesh, Camera, Light) using a given id
  89782. * @param id defines the id to search for
  89783. * @return the found node or null if not found at all
  89784. */
  89785. getNodeByID(id: string): Nullable<Node>;
  89786. /**
  89787. * Gets a node (Mesh, Camera, Light) using a given name
  89788. * @param name defines the name to search for
  89789. * @return the found node or null if not found at all.
  89790. */
  89791. getNodeByName(name: string): Nullable<Node>;
  89792. /**
  89793. * Gets a mesh using a given name
  89794. * @param name defines the name to search for
  89795. * @return the found mesh or null if not found at all.
  89796. */
  89797. getMeshByName(name: string): Nullable<AbstractMesh>;
  89798. /**
  89799. * Gets a transform node using a given name
  89800. * @param name defines the name to search for
  89801. * @return the found transform node or null if not found at all.
  89802. */
  89803. getTransformNodeByName(name: string): Nullable<TransformNode>;
  89804. /**
  89805. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  89806. * @param id defines the id to search for
  89807. * @return the found skeleton or null if not found at all.
  89808. */
  89809. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  89810. /**
  89811. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  89812. * @param id defines the id to search for
  89813. * @return the found skeleton or null if not found at all.
  89814. */
  89815. getSkeletonById(id: string): Nullable<Skeleton>;
  89816. /**
  89817. * Gets a skeleton using a given name
  89818. * @param name defines the name to search for
  89819. * @return the found skeleton or null if not found at all.
  89820. */
  89821. getSkeletonByName(name: string): Nullable<Skeleton>;
  89822. /**
  89823. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  89824. * @param id defines the id to search for
  89825. * @return the found morph target manager or null if not found at all.
  89826. */
  89827. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  89828. /**
  89829. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  89830. * @param id defines the id to search for
  89831. * @return the found morph target or null if not found at all.
  89832. */
  89833. getMorphTargetById(id: string): Nullable<MorphTarget>;
  89834. /**
  89835. * Gets a boolean indicating if the given mesh is active
  89836. * @param mesh defines the mesh to look for
  89837. * @returns true if the mesh is in the active list
  89838. */
  89839. isActiveMesh(mesh: AbstractMesh): boolean;
  89840. /**
  89841. * Return a unique id as a string which can serve as an identifier for the scene
  89842. */
  89843. readonly uid: string;
  89844. /**
  89845. * Add an externaly attached data from its key.
  89846. * This method call will fail and return false, if such key already exists.
  89847. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  89848. * @param key the unique key that identifies the data
  89849. * @param data the data object to associate to the key for this Engine instance
  89850. * @return true if no such key were already present and the data was added successfully, false otherwise
  89851. */
  89852. addExternalData<T>(key: string, data: T): boolean;
  89853. /**
  89854. * Get an externaly attached data from its key
  89855. * @param key the unique key that identifies the data
  89856. * @return the associated data, if present (can be null), or undefined if not present
  89857. */
  89858. getExternalData<T>(key: string): Nullable<T>;
  89859. /**
  89860. * Get an externaly attached data from its key, create it using a factory if it's not already present
  89861. * @param key the unique key that identifies the data
  89862. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  89863. * @return the associated data, can be null if the factory returned null.
  89864. */
  89865. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  89866. /**
  89867. * Remove an externaly attached data from the Engine instance
  89868. * @param key the unique key that identifies the data
  89869. * @return true if the data was successfully removed, false if it doesn't exist
  89870. */
  89871. removeExternalData(key: string): boolean;
  89872. private _evaluateSubMesh;
  89873. /**
  89874. * Clear the processed materials smart array preventing retention point in material dispose.
  89875. */
  89876. freeProcessedMaterials(): void;
  89877. private _preventFreeActiveMeshesAndRenderingGroups;
  89878. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  89879. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  89880. * when disposing several meshes in a row or a hierarchy of meshes.
  89881. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  89882. */
  89883. blockfreeActiveMeshesAndRenderingGroups: boolean;
  89884. /**
  89885. * Clear the active meshes smart array preventing retention point in mesh dispose.
  89886. */
  89887. freeActiveMeshes(): void;
  89888. /**
  89889. * Clear the info related to rendering groups preventing retention points during dispose.
  89890. */
  89891. freeRenderingGroups(): void;
  89892. /** @hidden */
  89893. _isInIntermediateRendering(): boolean;
  89894. /**
  89895. * Lambda returning the list of potentially active meshes.
  89896. */
  89897. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  89898. /**
  89899. * Lambda returning the list of potentially active sub meshes.
  89900. */
  89901. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  89902. /**
  89903. * Lambda returning the list of potentially intersecting sub meshes.
  89904. */
  89905. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  89906. /**
  89907. * Lambda returning the list of potentially colliding sub meshes.
  89908. */
  89909. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  89910. private _activeMeshesFrozen;
  89911. /**
  89912. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  89913. * @returns the current scene
  89914. */
  89915. freezeActiveMeshes(): Scene;
  89916. /**
  89917. * Use this function to restart evaluating active meshes on every frame
  89918. * @returns the current scene
  89919. */
  89920. unfreezeActiveMeshes(): Scene;
  89921. private _evaluateActiveMeshes;
  89922. private _activeMesh;
  89923. /**
  89924. * Update the transform matrix to update from the current active camera
  89925. * @param force defines a boolean used to force the update even if cache is up to date
  89926. */
  89927. updateTransformMatrix(force?: boolean): void;
  89928. /**
  89929. * 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)
  89930. * @param alternateCamera defines the camera to use
  89931. */
  89932. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  89933. /** @hidden */
  89934. _allowPostProcessClearColor: boolean;
  89935. private _renderForCamera;
  89936. private _processSubCameras;
  89937. private _checkIntersections;
  89938. /** @hidden */
  89939. _advancePhysicsEngineStep(step: number): void;
  89940. /**
  89941. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  89942. */
  89943. getDeterministicFrameTime: () => number;
  89944. /** @hidden */
  89945. _animate(): void;
  89946. /**
  89947. * Render the scene
  89948. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  89949. */
  89950. render(updateCameras?: boolean): void;
  89951. /**
  89952. * Freeze all materials
  89953. * A frozen material will not be updatable but should be faster to render
  89954. */
  89955. freezeMaterials(): void;
  89956. /**
  89957. * Unfreeze all materials
  89958. * A frozen material will not be updatable but should be faster to render
  89959. */
  89960. unfreezeMaterials(): void;
  89961. /**
  89962. * Releases all held ressources
  89963. */
  89964. dispose(): void;
  89965. /**
  89966. * Gets if the scene is already disposed
  89967. */
  89968. readonly isDisposed: boolean;
  89969. /**
  89970. * Call this function to reduce memory footprint of the scene.
  89971. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  89972. */
  89973. clearCachedVertexData(): void;
  89974. /**
  89975. * This function will remove the local cached buffer data from texture.
  89976. * It will save memory but will prevent the texture from being rebuilt
  89977. */
  89978. cleanCachedTextureBuffer(): void;
  89979. /**
  89980. * Get the world extend vectors with an optional filter
  89981. *
  89982. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  89983. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  89984. */
  89985. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  89986. min: Vector3;
  89987. max: Vector3;
  89988. };
  89989. /**
  89990. * Creates a ray that can be used to pick in the scene
  89991. * @param x defines the x coordinate of the origin (on-screen)
  89992. * @param y defines the y coordinate of the origin (on-screen)
  89993. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  89994. * @param camera defines the camera to use for the picking
  89995. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  89996. * @returns a Ray
  89997. */
  89998. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  89999. /**
  90000. * Creates a ray that can be used to pick in the scene
  90001. * @param x defines the x coordinate of the origin (on-screen)
  90002. * @param y defines the y coordinate of the origin (on-screen)
  90003. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90004. * @param result defines the ray where to store the picking ray
  90005. * @param camera defines the camera to use for the picking
  90006. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90007. * @returns the current scene
  90008. */
  90009. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  90010. /**
  90011. * Creates a ray that can be used to pick in the scene
  90012. * @param x defines the x coordinate of the origin (on-screen)
  90013. * @param y defines the y coordinate of the origin (on-screen)
  90014. * @param camera defines the camera to use for the picking
  90015. * @returns a Ray
  90016. */
  90017. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  90018. /**
  90019. * Creates a ray that can be used to pick in the scene
  90020. * @param x defines the x coordinate of the origin (on-screen)
  90021. * @param y defines the y coordinate of the origin (on-screen)
  90022. * @param result defines the ray where to store the picking ray
  90023. * @param camera defines the camera to use for the picking
  90024. * @returns the current scene
  90025. */
  90026. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  90027. /** Launch a ray to try to pick a mesh in the scene
  90028. * @param x position on screen
  90029. * @param y position on screen
  90030. * @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
  90031. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  90032. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90033. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90034. * @returns a PickingInfo
  90035. */
  90036. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  90037. /** Use the given ray to pick a mesh in the scene
  90038. * @param ray The ray to use to pick meshes
  90039. * @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
  90040. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  90041. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90042. * @returns a PickingInfo
  90043. */
  90044. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90045. /**
  90046. * Launch a ray to try to pick a mesh in the scene
  90047. * @param x X position on screen
  90048. * @param y Y position on screen
  90049. * @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
  90050. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90051. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90052. * @returns an array of PickingInfo
  90053. */
  90054. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90055. /**
  90056. * Launch a ray to try to pick a mesh in the scene
  90057. * @param ray Ray to use
  90058. * @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
  90059. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90060. * @returns an array of PickingInfo
  90061. */
  90062. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90063. /**
  90064. * Force the value of meshUnderPointer
  90065. * @param mesh defines the mesh to use
  90066. */
  90067. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90068. /**
  90069. * Gets the mesh under the pointer
  90070. * @returns a Mesh or null if no mesh is under the pointer
  90071. */
  90072. getPointerOverMesh(): Nullable<AbstractMesh>;
  90073. /** @hidden */
  90074. _rebuildGeometries(): void;
  90075. /** @hidden */
  90076. _rebuildTextures(): void;
  90077. private _getByTags;
  90078. /**
  90079. * Get a list of meshes by tags
  90080. * @param tagsQuery defines the tags query to use
  90081. * @param forEach defines a predicate used to filter results
  90082. * @returns an array of Mesh
  90083. */
  90084. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90085. /**
  90086. * Get a list of cameras by tags
  90087. * @param tagsQuery defines the tags query to use
  90088. * @param forEach defines a predicate used to filter results
  90089. * @returns an array of Camera
  90090. */
  90091. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90092. /**
  90093. * Get a list of lights by tags
  90094. * @param tagsQuery defines the tags query to use
  90095. * @param forEach defines a predicate used to filter results
  90096. * @returns an array of Light
  90097. */
  90098. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90099. /**
  90100. * Get a list of materials by tags
  90101. * @param tagsQuery defines the tags query to use
  90102. * @param forEach defines a predicate used to filter results
  90103. * @returns an array of Material
  90104. */
  90105. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90106. /**
  90107. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90108. * This allowed control for front to back rendering or reversly depending of the special needs.
  90109. *
  90110. * @param renderingGroupId The rendering group id corresponding to its index
  90111. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90112. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90113. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90114. */
  90115. 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;
  90116. /**
  90117. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90118. *
  90119. * @param renderingGroupId The rendering group id corresponding to its index
  90120. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90121. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90122. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90123. */
  90124. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90125. /**
  90126. * Gets the current auto clear configuration for one rendering group of the rendering
  90127. * manager.
  90128. * @param index the rendering group index to get the information for
  90129. * @returns The auto clear setup for the requested rendering group
  90130. */
  90131. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90132. private _blockMaterialDirtyMechanism;
  90133. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90134. blockMaterialDirtyMechanism: boolean;
  90135. /**
  90136. * Will flag all materials as dirty to trigger new shader compilation
  90137. * @param flag defines the flag used to specify which material part must be marked as dirty
  90138. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90139. */
  90140. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90141. /** @hidden */
  90142. _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;
  90143. /** @hidden */
  90144. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90145. }
  90146. }
  90147. declare module BABYLON {
  90148. /**
  90149. * Set of assets to keep when moving a scene into an asset container.
  90150. */
  90151. export class KeepAssets extends AbstractScene {
  90152. }
  90153. /**
  90154. * Container with a set of assets that can be added or removed from a scene.
  90155. */
  90156. export class AssetContainer extends AbstractScene {
  90157. /**
  90158. * The scene the AssetContainer belongs to.
  90159. */
  90160. scene: Scene;
  90161. /**
  90162. * Instantiates an AssetContainer.
  90163. * @param scene The scene the AssetContainer belongs to.
  90164. */
  90165. constructor(scene: Scene);
  90166. /**
  90167. * Adds all the assets from the container to the scene.
  90168. */
  90169. addAllToScene(): void;
  90170. /**
  90171. * Removes all the assets in the container from the scene
  90172. */
  90173. removeAllFromScene(): void;
  90174. /**
  90175. * Disposes all the assets in the container
  90176. */
  90177. dispose(): void;
  90178. private _moveAssets;
  90179. /**
  90180. * Removes all the assets contained in the scene and adds them to the container.
  90181. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90182. */
  90183. moveAllFromScene(keepAssets?: KeepAssets): void;
  90184. /**
  90185. * 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.
  90186. * @returns the root mesh
  90187. */
  90188. createRootMesh(): Mesh;
  90189. }
  90190. }
  90191. declare module BABYLON {
  90192. /**
  90193. * Defines how the parser contract is defined.
  90194. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90195. */
  90196. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90197. /**
  90198. * Defines how the individual parser contract is defined.
  90199. * These parser can parse an individual asset
  90200. */
  90201. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90202. /**
  90203. * Base class of the scene acting as a container for the different elements composing a scene.
  90204. * This class is dynamically extended by the different components of the scene increasing
  90205. * flexibility and reducing coupling
  90206. */
  90207. export abstract class AbstractScene {
  90208. /**
  90209. * Stores the list of available parsers in the application.
  90210. */
  90211. private static _BabylonFileParsers;
  90212. /**
  90213. * Stores the list of available individual parsers in the application.
  90214. */
  90215. private static _IndividualBabylonFileParsers;
  90216. /**
  90217. * Adds a parser in the list of available ones
  90218. * @param name Defines the name of the parser
  90219. * @param parser Defines the parser to add
  90220. */
  90221. static AddParser(name: string, parser: BabylonFileParser): void;
  90222. /**
  90223. * Gets a general parser from the list of avaialble ones
  90224. * @param name Defines the name of the parser
  90225. * @returns the requested parser or null
  90226. */
  90227. static GetParser(name: string): Nullable<BabylonFileParser>;
  90228. /**
  90229. * Adds n individual parser in the list of available ones
  90230. * @param name Defines the name of the parser
  90231. * @param parser Defines the parser to add
  90232. */
  90233. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90234. /**
  90235. * Gets an individual parser from the list of avaialble ones
  90236. * @param name Defines the name of the parser
  90237. * @returns the requested parser or null
  90238. */
  90239. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90240. /**
  90241. * Parser json data and populate both a scene and its associated container object
  90242. * @param jsonData Defines the data to parse
  90243. * @param scene Defines the scene to parse the data for
  90244. * @param container Defines the container attached to the parsing sequence
  90245. * @param rootUrl Defines the root url of the data
  90246. */
  90247. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90248. /**
  90249. * Gets the list of root nodes (ie. nodes with no parent)
  90250. */
  90251. rootNodes: Node[];
  90252. /** All of the cameras added to this scene
  90253. * @see http://doc.babylonjs.com/babylon101/cameras
  90254. */
  90255. cameras: Camera[];
  90256. /**
  90257. * All of the lights added to this scene
  90258. * @see http://doc.babylonjs.com/babylon101/lights
  90259. */
  90260. lights: Light[];
  90261. /**
  90262. * All of the (abstract) meshes added to this scene
  90263. */
  90264. meshes: AbstractMesh[];
  90265. /**
  90266. * The list of skeletons added to the scene
  90267. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90268. */
  90269. skeletons: Skeleton[];
  90270. /**
  90271. * All of the particle systems added to this scene
  90272. * @see http://doc.babylonjs.com/babylon101/particles
  90273. */
  90274. particleSystems: IParticleSystem[];
  90275. /**
  90276. * Gets a list of Animations associated with the scene
  90277. */
  90278. animations: Animation[];
  90279. /**
  90280. * All of the animation groups added to this scene
  90281. * @see http://doc.babylonjs.com/how_to/group
  90282. */
  90283. animationGroups: AnimationGroup[];
  90284. /**
  90285. * All of the multi-materials added to this scene
  90286. * @see http://doc.babylonjs.com/how_to/multi_materials
  90287. */
  90288. multiMaterials: MultiMaterial[];
  90289. /**
  90290. * All of the materials added to this scene
  90291. * In the context of a Scene, it is not supposed to be modified manually.
  90292. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90293. * Note also that the order of the Material wihin the array is not significant and might change.
  90294. * @see http://doc.babylonjs.com/babylon101/materials
  90295. */
  90296. materials: Material[];
  90297. /**
  90298. * The list of morph target managers added to the scene
  90299. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90300. */
  90301. morphTargetManagers: MorphTargetManager[];
  90302. /**
  90303. * The list of geometries used in the scene.
  90304. */
  90305. geometries: Geometry[];
  90306. /**
  90307. * All of the tranform nodes added to this scene
  90308. * In the context of a Scene, it is not supposed to be modified manually.
  90309. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90310. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90311. * @see http://doc.babylonjs.com/how_to/transformnode
  90312. */
  90313. transformNodes: TransformNode[];
  90314. /**
  90315. * ActionManagers available on the scene.
  90316. */
  90317. actionManagers: AbstractActionManager[];
  90318. /**
  90319. * Textures to keep.
  90320. */
  90321. textures: BaseTexture[];
  90322. }
  90323. }
  90324. declare module BABYLON {
  90325. /**
  90326. * Defines a sound that can be played in the application.
  90327. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90328. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90329. */
  90330. export class Sound {
  90331. /**
  90332. * The name of the sound in the scene.
  90333. */
  90334. name: string;
  90335. /**
  90336. * Does the sound autoplay once loaded.
  90337. */
  90338. autoplay: boolean;
  90339. /**
  90340. * Does the sound loop after it finishes playing once.
  90341. */
  90342. loop: boolean;
  90343. /**
  90344. * Does the sound use a custom attenuation curve to simulate the falloff
  90345. * happening when the source gets further away from the camera.
  90346. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90347. */
  90348. useCustomAttenuation: boolean;
  90349. /**
  90350. * The sound track id this sound belongs to.
  90351. */
  90352. soundTrackId: number;
  90353. /**
  90354. * Is this sound currently played.
  90355. */
  90356. isPlaying: boolean;
  90357. /**
  90358. * Is this sound currently paused.
  90359. */
  90360. isPaused: boolean;
  90361. /**
  90362. * Does this sound enables spatial sound.
  90363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90364. */
  90365. spatialSound: boolean;
  90366. /**
  90367. * Define the reference distance the sound should be heard perfectly.
  90368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90369. */
  90370. refDistance: number;
  90371. /**
  90372. * Define the roll off factor of spatial sounds.
  90373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90374. */
  90375. rolloffFactor: number;
  90376. /**
  90377. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  90378. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90379. */
  90380. maxDistance: number;
  90381. /**
  90382. * Define the distance attenuation model the sound will follow.
  90383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90384. */
  90385. distanceModel: string;
  90386. /**
  90387. * @hidden
  90388. * Back Compat
  90389. **/
  90390. onended: () => any;
  90391. /**
  90392. * Observable event when the current playing sound finishes.
  90393. */
  90394. onEndedObservable: Observable<Sound>;
  90395. private _panningModel;
  90396. private _playbackRate;
  90397. private _streaming;
  90398. private _startTime;
  90399. private _startOffset;
  90400. private _position;
  90401. /** @hidden */
  90402. _positionInEmitterSpace: boolean;
  90403. private _localDirection;
  90404. private _volume;
  90405. private _isReadyToPlay;
  90406. private _isDirectional;
  90407. private _readyToPlayCallback;
  90408. private _audioBuffer;
  90409. private _soundSource;
  90410. private _streamingSource;
  90411. private _soundPanner;
  90412. private _soundGain;
  90413. private _inputAudioNode;
  90414. private _outputAudioNode;
  90415. private _coneInnerAngle;
  90416. private _coneOuterAngle;
  90417. private _coneOuterGain;
  90418. private _scene;
  90419. private _connectedTransformNode;
  90420. private _customAttenuationFunction;
  90421. private _registerFunc;
  90422. private _isOutputConnected;
  90423. private _htmlAudioElement;
  90424. private _urlType;
  90425. /** @hidden */
  90426. static _SceneComponentInitialization: (scene: Scene) => void;
  90427. /**
  90428. * Create a sound and attach it to a scene
  90429. * @param name Name of your sound
  90430. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  90431. * @param scene defines the scene the sound belongs to
  90432. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  90433. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  90434. */
  90435. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  90436. /**
  90437. * Release the sound and its associated resources
  90438. */
  90439. dispose(): void;
  90440. /**
  90441. * Gets if the sounds is ready to be played or not.
  90442. * @returns true if ready, otherwise false
  90443. */
  90444. isReady(): boolean;
  90445. private _soundLoaded;
  90446. /**
  90447. * Sets the data of the sound from an audiobuffer
  90448. * @param audioBuffer The audioBuffer containing the data
  90449. */
  90450. setAudioBuffer(audioBuffer: AudioBuffer): void;
  90451. /**
  90452. * Updates the current sounds options such as maxdistance, loop...
  90453. * @param options A JSON object containing values named as the object properties
  90454. */
  90455. updateOptions(options: any): void;
  90456. private _createSpatialParameters;
  90457. private _updateSpatialParameters;
  90458. /**
  90459. * Switch the panning model to HRTF:
  90460. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90462. */
  90463. switchPanningModelToHRTF(): void;
  90464. /**
  90465. * Switch the panning model to Equal Power:
  90466. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90468. */
  90469. switchPanningModelToEqualPower(): void;
  90470. private _switchPanningModel;
  90471. /**
  90472. * Connect this sound to a sound track audio node like gain...
  90473. * @param soundTrackAudioNode the sound track audio node to connect to
  90474. */
  90475. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  90476. /**
  90477. * Transform this sound into a directional source
  90478. * @param coneInnerAngle Size of the inner cone in degree
  90479. * @param coneOuterAngle Size of the outer cone in degree
  90480. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  90481. */
  90482. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  90483. /**
  90484. * Gets or sets the inner angle for the directional cone.
  90485. */
  90486. /**
  90487. * Gets or sets the inner angle for the directional cone.
  90488. */
  90489. directionalConeInnerAngle: number;
  90490. /**
  90491. * Gets or sets the outer angle for the directional cone.
  90492. */
  90493. /**
  90494. * Gets or sets the outer angle for the directional cone.
  90495. */
  90496. directionalConeOuterAngle: number;
  90497. /**
  90498. * Sets the position of the emitter if spatial sound is enabled
  90499. * @param newPosition Defines the new posisiton
  90500. */
  90501. setPosition(newPosition: Vector3): void;
  90502. /**
  90503. * Sets the local direction of the emitter if spatial sound is enabled
  90504. * @param newLocalDirection Defines the new local direction
  90505. */
  90506. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  90507. private _updateDirection;
  90508. /** @hidden */
  90509. updateDistanceFromListener(): void;
  90510. /**
  90511. * Sets a new custom attenuation function for the sound.
  90512. * @param callback Defines the function used for the attenuation
  90513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90514. */
  90515. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  90516. /**
  90517. * Play the sound
  90518. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  90519. * @param offset (optional) Start the sound setting it at a specific time
  90520. */
  90521. play(time?: number, offset?: number): void;
  90522. private _onended;
  90523. /**
  90524. * Stop the sound
  90525. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  90526. */
  90527. stop(time?: number): void;
  90528. /**
  90529. * Put the sound in pause
  90530. */
  90531. pause(): void;
  90532. /**
  90533. * Sets a dedicated volume for this sounds
  90534. * @param newVolume Define the new volume of the sound
  90535. * @param time Define in how long the sound should be at this value
  90536. */
  90537. setVolume(newVolume: number, time?: number): void;
  90538. /**
  90539. * Set the sound play back rate
  90540. * @param newPlaybackRate Define the playback rate the sound should be played at
  90541. */
  90542. setPlaybackRate(newPlaybackRate: number): void;
  90543. /**
  90544. * Gets the volume of the sound.
  90545. * @returns the volume of the sound
  90546. */
  90547. getVolume(): number;
  90548. /**
  90549. * Attach the sound to a dedicated mesh
  90550. * @param transformNode The transform node to connect the sound with
  90551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90552. */
  90553. attachToMesh(transformNode: TransformNode): void;
  90554. /**
  90555. * Detach the sound from the previously attached mesh
  90556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90557. */
  90558. detachFromMesh(): void;
  90559. private _onRegisterAfterWorldMatrixUpdate;
  90560. /**
  90561. * Clone the current sound in the scene.
  90562. * @returns the new sound clone
  90563. */
  90564. clone(): Nullable<Sound>;
  90565. /**
  90566. * Gets the current underlying audio buffer containing the data
  90567. * @returns the audio buffer
  90568. */
  90569. getAudioBuffer(): Nullable<AudioBuffer>;
  90570. /**
  90571. * Serializes the Sound in a JSON representation
  90572. * @returns the JSON representation of the sound
  90573. */
  90574. serialize(): any;
  90575. /**
  90576. * Parse a JSON representation of a sound to innstantiate in a given scene
  90577. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  90578. * @param scene Define the scene the new parsed sound should be created in
  90579. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  90580. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  90581. * @returns the newly parsed sound
  90582. */
  90583. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  90584. }
  90585. }
  90586. declare module BABYLON {
  90587. /**
  90588. * This defines an action helpful to play a defined sound on a triggered action.
  90589. */
  90590. export class PlaySoundAction extends Action {
  90591. private _sound;
  90592. /**
  90593. * Instantiate the action
  90594. * @param triggerOptions defines the trigger options
  90595. * @param sound defines the sound to play
  90596. * @param condition defines the trigger related conditions
  90597. */
  90598. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90599. /** @hidden */
  90600. _prepare(): void;
  90601. /**
  90602. * Execute the action and play the sound.
  90603. */
  90604. execute(): void;
  90605. /**
  90606. * Serializes the actions and its related information.
  90607. * @param parent defines the object to serialize in
  90608. * @returns the serialized object
  90609. */
  90610. serialize(parent: any): any;
  90611. }
  90612. /**
  90613. * This defines an action helpful to stop a defined sound on a triggered action.
  90614. */
  90615. export class StopSoundAction extends Action {
  90616. private _sound;
  90617. /**
  90618. * Instantiate the action
  90619. * @param triggerOptions defines the trigger options
  90620. * @param sound defines the sound to stop
  90621. * @param condition defines the trigger related conditions
  90622. */
  90623. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90624. /** @hidden */
  90625. _prepare(): void;
  90626. /**
  90627. * Execute the action and stop the sound.
  90628. */
  90629. execute(): void;
  90630. /**
  90631. * Serializes the actions and its related information.
  90632. * @param parent defines the object to serialize in
  90633. * @returns the serialized object
  90634. */
  90635. serialize(parent: any): any;
  90636. }
  90637. }
  90638. declare module BABYLON {
  90639. /**
  90640. * This defines an action responsible to change the value of a property
  90641. * by interpolating between its current value and the newly set one once triggered.
  90642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90643. */
  90644. export class InterpolateValueAction extends Action {
  90645. /**
  90646. * Defines the path of the property where the value should be interpolated
  90647. */
  90648. propertyPath: string;
  90649. /**
  90650. * Defines the target value at the end of the interpolation.
  90651. */
  90652. value: any;
  90653. /**
  90654. * Defines the time it will take for the property to interpolate to the value.
  90655. */
  90656. duration: number;
  90657. /**
  90658. * Defines if the other scene animations should be stopped when the action has been triggered
  90659. */
  90660. stopOtherAnimations?: boolean;
  90661. /**
  90662. * Defines a callback raised once the interpolation animation has been done.
  90663. */
  90664. onInterpolationDone?: () => void;
  90665. /**
  90666. * Observable triggered once the interpolation animation has been done.
  90667. */
  90668. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  90669. private _target;
  90670. private _effectiveTarget;
  90671. private _property;
  90672. /**
  90673. * Instantiate the action
  90674. * @param triggerOptions defines the trigger options
  90675. * @param target defines the object containing the value to interpolate
  90676. * @param propertyPath defines the path to the property in the target object
  90677. * @param value defines the target value at the end of the interpolation
  90678. * @param duration deines the time it will take for the property to interpolate to the value.
  90679. * @param condition defines the trigger related conditions
  90680. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  90681. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  90682. */
  90683. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  90684. /** @hidden */
  90685. _prepare(): void;
  90686. /**
  90687. * Execute the action starts the value interpolation.
  90688. */
  90689. execute(): void;
  90690. /**
  90691. * Serializes the actions and its related information.
  90692. * @param parent defines the object to serialize in
  90693. * @returns the serialized object
  90694. */
  90695. serialize(parent: any): any;
  90696. }
  90697. }
  90698. declare module BABYLON {
  90699. /**
  90700. * Options allowed during the creation of a sound track.
  90701. */
  90702. export interface ISoundTrackOptions {
  90703. /**
  90704. * The volume the sound track should take during creation
  90705. */
  90706. volume?: number;
  90707. /**
  90708. * Define if the sound track is the main sound track of the scene
  90709. */
  90710. mainTrack?: boolean;
  90711. }
  90712. /**
  90713. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  90714. * It will be also used in a future release to apply effects on a specific track.
  90715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90716. */
  90717. export class SoundTrack {
  90718. /**
  90719. * The unique identifier of the sound track in the scene.
  90720. */
  90721. id: number;
  90722. /**
  90723. * The list of sounds included in the sound track.
  90724. */
  90725. soundCollection: Array<Sound>;
  90726. private _outputAudioNode;
  90727. private _scene;
  90728. private _isMainTrack;
  90729. private _connectedAnalyser;
  90730. private _options;
  90731. private _isInitialized;
  90732. /**
  90733. * Creates a new sound track.
  90734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90735. * @param scene Define the scene the sound track belongs to
  90736. * @param options
  90737. */
  90738. constructor(scene: Scene, options?: ISoundTrackOptions);
  90739. private _initializeSoundTrackAudioGraph;
  90740. /**
  90741. * Release the sound track and its associated resources
  90742. */
  90743. dispose(): void;
  90744. /**
  90745. * Adds a sound to this sound track
  90746. * @param sound define the cound to add
  90747. * @ignoreNaming
  90748. */
  90749. AddSound(sound: Sound): void;
  90750. /**
  90751. * Removes a sound to this sound track
  90752. * @param sound define the cound to remove
  90753. * @ignoreNaming
  90754. */
  90755. RemoveSound(sound: Sound): void;
  90756. /**
  90757. * Set a global volume for the full sound track.
  90758. * @param newVolume Define the new volume of the sound track
  90759. */
  90760. setVolume(newVolume: number): void;
  90761. /**
  90762. * Switch the panning model to HRTF:
  90763. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90765. */
  90766. switchPanningModelToHRTF(): void;
  90767. /**
  90768. * Switch the panning model to Equal Power:
  90769. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90771. */
  90772. switchPanningModelToEqualPower(): void;
  90773. /**
  90774. * Connect the sound track to an audio analyser allowing some amazing
  90775. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90777. * @param analyser The analyser to connect to the engine
  90778. */
  90779. connectToAnalyser(analyser: Analyser): void;
  90780. }
  90781. }
  90782. declare module BABYLON {
  90783. interface AbstractScene {
  90784. /**
  90785. * The list of sounds used in the scene.
  90786. */
  90787. sounds: Nullable<Array<Sound>>;
  90788. }
  90789. interface Scene {
  90790. /**
  90791. * @hidden
  90792. * Backing field
  90793. */
  90794. _mainSoundTrack: SoundTrack;
  90795. /**
  90796. * The main sound track played by the scene.
  90797. * It cotains your primary collection of sounds.
  90798. */
  90799. mainSoundTrack: SoundTrack;
  90800. /**
  90801. * The list of sound tracks added to the scene
  90802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90803. */
  90804. soundTracks: Nullable<Array<SoundTrack>>;
  90805. /**
  90806. * Gets a sound using a given name
  90807. * @param name defines the name to search for
  90808. * @return the found sound or null if not found at all.
  90809. */
  90810. getSoundByName(name: string): Nullable<Sound>;
  90811. /**
  90812. * Gets or sets if audio support is enabled
  90813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90814. */
  90815. audioEnabled: boolean;
  90816. /**
  90817. * Gets or sets if audio will be output to headphones
  90818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90819. */
  90820. headphone: boolean;
  90821. }
  90822. /**
  90823. * Defines the sound scene component responsible to manage any sounds
  90824. * in a given scene.
  90825. */
  90826. export class AudioSceneComponent implements ISceneSerializableComponent {
  90827. /**
  90828. * The component name helpfull to identify the component in the list of scene components.
  90829. */
  90830. readonly name: string;
  90831. /**
  90832. * The scene the component belongs to.
  90833. */
  90834. scene: Scene;
  90835. private _audioEnabled;
  90836. /**
  90837. * Gets whether audio is enabled or not.
  90838. * Please use related enable/disable method to switch state.
  90839. */
  90840. readonly audioEnabled: boolean;
  90841. private _headphone;
  90842. /**
  90843. * Gets whether audio is outputing to headphone or not.
  90844. * Please use the according Switch methods to change output.
  90845. */
  90846. readonly headphone: boolean;
  90847. /**
  90848. * Creates a new instance of the component for the given scene
  90849. * @param scene Defines the scene to register the component in
  90850. */
  90851. constructor(scene: Scene);
  90852. /**
  90853. * Registers the component in a given scene
  90854. */
  90855. register(): void;
  90856. /**
  90857. * Rebuilds the elements related to this component in case of
  90858. * context lost for instance.
  90859. */
  90860. rebuild(): void;
  90861. /**
  90862. * Serializes the component data to the specified json object
  90863. * @param serializationObject The object to serialize to
  90864. */
  90865. serialize(serializationObject: any): void;
  90866. /**
  90867. * Adds all the element from the container to the scene
  90868. * @param container the container holding the elements
  90869. */
  90870. addFromContainer(container: AbstractScene): void;
  90871. /**
  90872. * Removes all the elements in the container from the scene
  90873. * @param container contains the elements to remove
  90874. */
  90875. removeFromContainer(container: AbstractScene): void;
  90876. /**
  90877. * Disposes the component and the associated ressources.
  90878. */
  90879. dispose(): void;
  90880. /**
  90881. * Disables audio in the associated scene.
  90882. */
  90883. disableAudio(): void;
  90884. /**
  90885. * Enables audio in the associated scene.
  90886. */
  90887. enableAudio(): void;
  90888. /**
  90889. * Switch audio to headphone output.
  90890. */
  90891. switchAudioModeForHeadphones(): void;
  90892. /**
  90893. * Switch audio to normal speakers.
  90894. */
  90895. switchAudioModeForNormalSpeakers(): void;
  90896. private _afterRender;
  90897. }
  90898. }
  90899. declare module BABYLON {
  90900. /**
  90901. * Wraps one or more Sound objects and selects one with random weight for playback.
  90902. */
  90903. export class WeightedSound {
  90904. /** When true a Sound will be selected and played when the current playing Sound completes. */
  90905. loop: boolean;
  90906. private _coneInnerAngle;
  90907. private _coneOuterAngle;
  90908. private _volume;
  90909. /** A Sound is currently playing. */
  90910. isPlaying: boolean;
  90911. /** A Sound is currently paused. */
  90912. isPaused: boolean;
  90913. private _sounds;
  90914. private _weights;
  90915. private _currentIndex?;
  90916. /**
  90917. * Creates a new WeightedSound from the list of sounds given.
  90918. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  90919. * @param sounds Array of Sounds that will be selected from.
  90920. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  90921. */
  90922. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  90923. /**
  90924. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  90925. */
  90926. /**
  90927. * The size of cone in degress for a directional sound in which there will be no attenuation.
  90928. */
  90929. directionalConeInnerAngle: number;
  90930. /**
  90931. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90932. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90933. */
  90934. /**
  90935. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90936. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90937. */
  90938. directionalConeOuterAngle: number;
  90939. /**
  90940. * Playback volume.
  90941. */
  90942. /**
  90943. * Playback volume.
  90944. */
  90945. volume: number;
  90946. private _onended;
  90947. /**
  90948. * Suspend playback
  90949. */
  90950. pause(): void;
  90951. /**
  90952. * Stop playback
  90953. */
  90954. stop(): void;
  90955. /**
  90956. * Start playback.
  90957. * @param startOffset Position the clip head at a specific time in seconds.
  90958. */
  90959. play(startOffset?: number): void;
  90960. }
  90961. }
  90962. declare module BABYLON {
  90963. /**
  90964. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  90965. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90966. */
  90967. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  90968. /**
  90969. * Gets the name of the behavior.
  90970. */
  90971. readonly name: string;
  90972. /**
  90973. * The easing function used by animations
  90974. */
  90975. static EasingFunction: BackEase;
  90976. /**
  90977. * The easing mode used by animations
  90978. */
  90979. static EasingMode: number;
  90980. /**
  90981. * The duration of the animation, in milliseconds
  90982. */
  90983. transitionDuration: number;
  90984. /**
  90985. * Length of the distance animated by the transition when lower radius is reached
  90986. */
  90987. lowerRadiusTransitionRange: number;
  90988. /**
  90989. * Length of the distance animated by the transition when upper radius is reached
  90990. */
  90991. upperRadiusTransitionRange: number;
  90992. private _autoTransitionRange;
  90993. /**
  90994. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  90995. */
  90996. /**
  90997. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  90998. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  90999. */
  91000. autoTransitionRange: boolean;
  91001. private _attachedCamera;
  91002. private _onAfterCheckInputsObserver;
  91003. private _onMeshTargetChangedObserver;
  91004. /**
  91005. * Initializes the behavior.
  91006. */
  91007. init(): void;
  91008. /**
  91009. * Attaches the behavior to its arc rotate camera.
  91010. * @param camera Defines the camera to attach the behavior to
  91011. */
  91012. attach(camera: ArcRotateCamera): void;
  91013. /**
  91014. * Detaches the behavior from its current arc rotate camera.
  91015. */
  91016. detach(): void;
  91017. private _radiusIsAnimating;
  91018. private _radiusBounceTransition;
  91019. private _animatables;
  91020. private _cachedWheelPrecision;
  91021. /**
  91022. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  91023. * @param radiusLimit The limit to check against.
  91024. * @return Bool to indicate if at limit.
  91025. */
  91026. private _isRadiusAtLimit;
  91027. /**
  91028. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  91029. * @param radiusDelta The delta by which to animate to. Can be negative.
  91030. */
  91031. private _applyBoundRadiusAnimation;
  91032. /**
  91033. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  91034. */
  91035. protected _clearAnimationLocks(): void;
  91036. /**
  91037. * Stops and removes all animations that have been applied to the camera
  91038. */
  91039. stopAllAnimations(): void;
  91040. }
  91041. }
  91042. declare module BABYLON {
  91043. /**
  91044. * 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.
  91045. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91046. */
  91047. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  91048. /**
  91049. * Gets the name of the behavior.
  91050. */
  91051. readonly name: string;
  91052. private _mode;
  91053. private _radiusScale;
  91054. private _positionScale;
  91055. private _defaultElevation;
  91056. private _elevationReturnTime;
  91057. private _elevationReturnWaitTime;
  91058. private _zoomStopsAnimation;
  91059. private _framingTime;
  91060. /**
  91061. * The easing function used by animations
  91062. */
  91063. static EasingFunction: ExponentialEase;
  91064. /**
  91065. * The easing mode used by animations
  91066. */
  91067. static EasingMode: number;
  91068. /**
  91069. * Sets the current mode used by the behavior
  91070. */
  91071. /**
  91072. * Gets current mode used by the behavior.
  91073. */
  91074. mode: number;
  91075. /**
  91076. * Sets the scale applied to the radius (1 by default)
  91077. */
  91078. /**
  91079. * Gets the scale applied to the radius
  91080. */
  91081. radiusScale: number;
  91082. /**
  91083. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91084. */
  91085. /**
  91086. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91087. */
  91088. positionScale: number;
  91089. /**
  91090. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91091. * behaviour is triggered, in radians.
  91092. */
  91093. /**
  91094. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91095. * behaviour is triggered, in radians.
  91096. */
  91097. defaultElevation: number;
  91098. /**
  91099. * Sets the time (in milliseconds) taken to return to the default beta position.
  91100. * Negative value indicates camera should not return to default.
  91101. */
  91102. /**
  91103. * Gets the time (in milliseconds) taken to return to the default beta position.
  91104. * Negative value indicates camera should not return to default.
  91105. */
  91106. elevationReturnTime: number;
  91107. /**
  91108. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91109. */
  91110. /**
  91111. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91112. */
  91113. elevationReturnWaitTime: number;
  91114. /**
  91115. * Sets the flag that indicates if user zooming should stop animation.
  91116. */
  91117. /**
  91118. * Gets the flag that indicates if user zooming should stop animation.
  91119. */
  91120. zoomStopsAnimation: boolean;
  91121. /**
  91122. * Sets the transition time when framing the mesh, in milliseconds
  91123. */
  91124. /**
  91125. * Gets the transition time when framing the mesh, in milliseconds
  91126. */
  91127. framingTime: number;
  91128. /**
  91129. * Define if the behavior should automatically change the configured
  91130. * camera limits and sensibilities.
  91131. */
  91132. autoCorrectCameraLimitsAndSensibility: boolean;
  91133. private _onPrePointerObservableObserver;
  91134. private _onAfterCheckInputsObserver;
  91135. private _onMeshTargetChangedObserver;
  91136. private _attachedCamera;
  91137. private _isPointerDown;
  91138. private _lastInteractionTime;
  91139. /**
  91140. * Initializes the behavior.
  91141. */
  91142. init(): void;
  91143. /**
  91144. * Attaches the behavior to its arc rotate camera.
  91145. * @param camera Defines the camera to attach the behavior to
  91146. */
  91147. attach(camera: ArcRotateCamera): void;
  91148. /**
  91149. * Detaches the behavior from its current arc rotate camera.
  91150. */
  91151. detach(): void;
  91152. private _animatables;
  91153. private _betaIsAnimating;
  91154. private _betaTransition;
  91155. private _radiusTransition;
  91156. private _vectorTransition;
  91157. /**
  91158. * Targets the given mesh and updates zoom level accordingly.
  91159. * @param mesh The mesh to target.
  91160. * @param radius Optional. If a cached radius position already exists, overrides default.
  91161. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91162. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91163. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91164. */
  91165. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91166. /**
  91167. * Targets the given mesh with its children and updates zoom level accordingly.
  91168. * @param mesh The mesh to target.
  91169. * @param radius Optional. If a cached radius position already exists, overrides default.
  91170. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91171. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91172. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91173. */
  91174. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91175. /**
  91176. * Targets the given meshes with their children and updates zoom level accordingly.
  91177. * @param meshes The mesh to target.
  91178. * @param radius Optional. If a cached radius position already exists, overrides default.
  91179. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91180. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91181. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91182. */
  91183. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91184. /**
  91185. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91186. * @param minimumWorld Determines the smaller position of the bounding box extend
  91187. * @param maximumWorld Determines the bigger position of the bounding box extend
  91188. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91189. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91190. */
  91191. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91192. /**
  91193. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91194. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91195. * frustum width.
  91196. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91197. * to fully enclose the mesh in the viewing frustum.
  91198. */
  91199. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91200. /**
  91201. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91202. * is automatically returned to its default position (expected to be above ground plane).
  91203. */
  91204. private _maintainCameraAboveGround;
  91205. /**
  91206. * Returns the frustum slope based on the canvas ratio and camera FOV
  91207. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91208. */
  91209. private _getFrustumSlope;
  91210. /**
  91211. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91212. */
  91213. private _clearAnimationLocks;
  91214. /**
  91215. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91216. */
  91217. private _applyUserInteraction;
  91218. /**
  91219. * Stops and removes all animations that have been applied to the camera
  91220. */
  91221. stopAllAnimations(): void;
  91222. /**
  91223. * Gets a value indicating if the user is moving the camera
  91224. */
  91225. readonly isUserIsMoving: boolean;
  91226. /**
  91227. * The camera can move all the way towards the mesh.
  91228. */
  91229. static IgnoreBoundsSizeMode: number;
  91230. /**
  91231. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91232. */
  91233. static FitFrustumSidesMode: number;
  91234. }
  91235. }
  91236. declare module BABYLON {
  91237. /**
  91238. * Base class for Camera Pointer Inputs.
  91239. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91240. * for example usage.
  91241. */
  91242. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91243. /**
  91244. * Defines the camera the input is attached to.
  91245. */
  91246. abstract camera: Camera;
  91247. /**
  91248. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91249. */
  91250. protected _altKey: boolean;
  91251. protected _ctrlKey: boolean;
  91252. protected _metaKey: boolean;
  91253. protected _shiftKey: boolean;
  91254. /**
  91255. * Which mouse buttons were pressed at time of last mouse event.
  91256. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91257. */
  91258. protected _buttonsPressed: number;
  91259. /**
  91260. * Defines the buttons associated with the input to handle camera move.
  91261. */
  91262. buttons: number[];
  91263. /**
  91264. * Attach the input controls to a specific dom element to get the input from.
  91265. * @param element Defines the element the controls should be listened from
  91266. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91267. */
  91268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91269. /**
  91270. * Detach the current controls from the specified dom element.
  91271. * @param element Defines the element to stop listening the inputs from
  91272. */
  91273. detachControl(element: Nullable<HTMLElement>): void;
  91274. /**
  91275. * Gets the class name of the current input.
  91276. * @returns the class name
  91277. */
  91278. getClassName(): string;
  91279. /**
  91280. * Get the friendly name associated with the input class.
  91281. * @returns the input friendly name
  91282. */
  91283. getSimpleName(): string;
  91284. /**
  91285. * Called on pointer POINTERDOUBLETAP event.
  91286. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91287. */
  91288. protected onDoubleTap(type: string): void;
  91289. /**
  91290. * Called on pointer POINTERMOVE event if only a single touch is active.
  91291. * Override this method to provide functionality.
  91292. */
  91293. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91294. /**
  91295. * Called on pointer POINTERMOVE event if multiple touches are active.
  91296. * Override this method to provide functionality.
  91297. */
  91298. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91299. /**
  91300. * Called on JS contextmenu event.
  91301. * Override this method to provide functionality.
  91302. */
  91303. protected onContextMenu(evt: PointerEvent): void;
  91304. /**
  91305. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91306. * press.
  91307. * Override this method to provide functionality.
  91308. */
  91309. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91310. /**
  91311. * Called each time a new POINTERUP event occurs. Ie, for each button
  91312. * release.
  91313. * Override this method to provide functionality.
  91314. */
  91315. protected onButtonUp(evt: PointerEvent): void;
  91316. /**
  91317. * Called when window becomes inactive.
  91318. * Override this method to provide functionality.
  91319. */
  91320. protected onLostFocus(): void;
  91321. private _pointerInput;
  91322. private _observer;
  91323. private _onLostFocus;
  91324. }
  91325. }
  91326. declare module BABYLON {
  91327. /**
  91328. * Manage the pointers inputs to control an arc rotate camera.
  91329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91330. */
  91331. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91332. /**
  91333. * Defines the camera the input is attached to.
  91334. */
  91335. camera: ArcRotateCamera;
  91336. /**
  91337. * Gets the class name of the current input.
  91338. * @returns the class name
  91339. */
  91340. getClassName(): string;
  91341. /**
  91342. * Defines the buttons associated with the input to handle camera move.
  91343. */
  91344. buttons: number[];
  91345. /**
  91346. * Defines the pointer angular sensibility along the X axis or how fast is
  91347. * the camera rotating.
  91348. */
  91349. angularSensibilityX: number;
  91350. /**
  91351. * Defines the pointer angular sensibility along the Y axis or how fast is
  91352. * the camera rotating.
  91353. */
  91354. angularSensibilityY: number;
  91355. /**
  91356. * Defines the pointer pinch precision or how fast is the camera zooming.
  91357. */
  91358. pinchPrecision: number;
  91359. /**
  91360. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  91361. * from 0.
  91362. * It defines the percentage of current camera.radius to use as delta when
  91363. * pinch zoom is used.
  91364. */
  91365. pinchDeltaPercentage: number;
  91366. /**
  91367. * Defines the pointer panning sensibility or how fast is the camera moving.
  91368. */
  91369. panningSensibility: number;
  91370. /**
  91371. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  91372. */
  91373. multiTouchPanning: boolean;
  91374. /**
  91375. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  91376. * zoom (pinch) through multitouch.
  91377. */
  91378. multiTouchPanAndZoom: boolean;
  91379. /**
  91380. * Revers pinch action direction.
  91381. */
  91382. pinchInwards: boolean;
  91383. private _isPanClick;
  91384. private _twoFingerActivityCount;
  91385. private _isPinching;
  91386. /**
  91387. * Called on pointer POINTERMOVE event if only a single touch is active.
  91388. */
  91389. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91390. /**
  91391. * Called on pointer POINTERDOUBLETAP event.
  91392. */
  91393. protected onDoubleTap(type: string): void;
  91394. /**
  91395. * Called on pointer POINTERMOVE event if multiple touches are active.
  91396. */
  91397. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91398. /**
  91399. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91400. * press.
  91401. */
  91402. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91403. /**
  91404. * Called each time a new POINTERUP event occurs. Ie, for each button
  91405. * release.
  91406. */
  91407. protected onButtonUp(evt: PointerEvent): void;
  91408. /**
  91409. * Called when window becomes inactive.
  91410. */
  91411. protected onLostFocus(): void;
  91412. }
  91413. }
  91414. declare module BABYLON {
  91415. /**
  91416. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  91417. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91418. */
  91419. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  91420. /**
  91421. * Defines the camera the input is attached to.
  91422. */
  91423. camera: ArcRotateCamera;
  91424. /**
  91425. * Defines the list of key codes associated with the up action (increase alpha)
  91426. */
  91427. keysUp: number[];
  91428. /**
  91429. * Defines the list of key codes associated with the down action (decrease alpha)
  91430. */
  91431. keysDown: number[];
  91432. /**
  91433. * Defines the list of key codes associated with the left action (increase beta)
  91434. */
  91435. keysLeft: number[];
  91436. /**
  91437. * Defines the list of key codes associated with the right action (decrease beta)
  91438. */
  91439. keysRight: number[];
  91440. /**
  91441. * Defines the list of key codes associated with the reset action.
  91442. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  91443. */
  91444. keysReset: number[];
  91445. /**
  91446. * Defines the panning sensibility of the inputs.
  91447. * (How fast is the camera paning)
  91448. */
  91449. panningSensibility: number;
  91450. /**
  91451. * Defines the zooming sensibility of the inputs.
  91452. * (How fast is the camera zooming)
  91453. */
  91454. zoomingSensibility: number;
  91455. /**
  91456. * Defines wether maintaining the alt key down switch the movement mode from
  91457. * orientation to zoom.
  91458. */
  91459. useAltToZoom: boolean;
  91460. /**
  91461. * Rotation speed of the camera
  91462. */
  91463. angularSpeed: number;
  91464. private _keys;
  91465. private _ctrlPressed;
  91466. private _altPressed;
  91467. private _onCanvasBlurObserver;
  91468. private _onKeyboardObserver;
  91469. private _engine;
  91470. private _scene;
  91471. /**
  91472. * Attach the input controls to a specific dom element to get the input from.
  91473. * @param element Defines the element the controls should be listened from
  91474. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91475. */
  91476. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91477. /**
  91478. * Detach the current controls from the specified dom element.
  91479. * @param element Defines the element to stop listening the inputs from
  91480. */
  91481. detachControl(element: Nullable<HTMLElement>): void;
  91482. /**
  91483. * Update the current camera state depending on the inputs that have been used this frame.
  91484. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91485. */
  91486. checkInputs(): void;
  91487. /**
  91488. * Gets the class name of the current intput.
  91489. * @returns the class name
  91490. */
  91491. getClassName(): string;
  91492. /**
  91493. * Get the friendly name associated with the input class.
  91494. * @returns the input friendly name
  91495. */
  91496. getSimpleName(): string;
  91497. }
  91498. }
  91499. declare module BABYLON {
  91500. /**
  91501. * Manage the mouse wheel inputs to control an arc rotate camera.
  91502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91503. */
  91504. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  91505. /**
  91506. * Defines the camera the input is attached to.
  91507. */
  91508. camera: ArcRotateCamera;
  91509. /**
  91510. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91511. */
  91512. wheelPrecision: number;
  91513. /**
  91514. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  91515. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  91516. */
  91517. wheelDeltaPercentage: number;
  91518. private _wheel;
  91519. private _observer;
  91520. /**
  91521. * Attach the input controls to a specific dom element to get the input from.
  91522. * @param element Defines the element the controls should be listened from
  91523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91524. */
  91525. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91526. /**
  91527. * Detach the current controls from the specified dom element.
  91528. * @param element Defines the element to stop listening the inputs from
  91529. */
  91530. detachControl(element: Nullable<HTMLElement>): void;
  91531. /**
  91532. * Gets the class name of the current intput.
  91533. * @returns the class name
  91534. */
  91535. getClassName(): string;
  91536. /**
  91537. * Get the friendly name associated with the input class.
  91538. * @returns the input friendly name
  91539. */
  91540. getSimpleName(): string;
  91541. }
  91542. }
  91543. declare module BABYLON {
  91544. /**
  91545. * Default Inputs manager for the ArcRotateCamera.
  91546. * It groups all the default supported inputs for ease of use.
  91547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91548. */
  91549. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  91550. /**
  91551. * Instantiates a new ArcRotateCameraInputsManager.
  91552. * @param camera Defines the camera the inputs belong to
  91553. */
  91554. constructor(camera: ArcRotateCamera);
  91555. /**
  91556. * Add mouse wheel input support to the input manager.
  91557. * @returns the current input manager
  91558. */
  91559. addMouseWheel(): ArcRotateCameraInputsManager;
  91560. /**
  91561. * Add pointers input support to the input manager.
  91562. * @returns the current input manager
  91563. */
  91564. addPointers(): ArcRotateCameraInputsManager;
  91565. /**
  91566. * Add keyboard input support to the input manager.
  91567. * @returns the current input manager
  91568. */
  91569. addKeyboard(): ArcRotateCameraInputsManager;
  91570. }
  91571. }
  91572. declare module BABYLON {
  91573. /**
  91574. * This represents an orbital type of camera.
  91575. *
  91576. * 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.
  91577. * 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.
  91578. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  91579. */
  91580. export class ArcRotateCamera extends TargetCamera {
  91581. /**
  91582. * Defines the rotation angle of the camera along the longitudinal axis.
  91583. */
  91584. alpha: number;
  91585. /**
  91586. * Defines the rotation angle of the camera along the latitudinal axis.
  91587. */
  91588. beta: number;
  91589. /**
  91590. * Defines the radius of the camera from it s target point.
  91591. */
  91592. radius: number;
  91593. protected _target: Vector3;
  91594. protected _targetHost: Nullable<AbstractMesh>;
  91595. /**
  91596. * Defines the target point of the camera.
  91597. * The camera looks towards it form the radius distance.
  91598. */
  91599. target: Vector3;
  91600. /**
  91601. * Define the current local position of the camera in the scene
  91602. */
  91603. position: Vector3;
  91604. /**
  91605. * Current inertia value on the longitudinal axis.
  91606. * The bigger this number the longer it will take for the camera to stop.
  91607. */
  91608. inertialAlphaOffset: number;
  91609. /**
  91610. * Current inertia value on the latitudinal axis.
  91611. * The bigger this number the longer it will take for the camera to stop.
  91612. */
  91613. inertialBetaOffset: number;
  91614. /**
  91615. * Current inertia value on the radius axis.
  91616. * The bigger this number the longer it will take for the camera to stop.
  91617. */
  91618. inertialRadiusOffset: number;
  91619. /**
  91620. * Minimum allowed angle on the longitudinal axis.
  91621. * This can help limiting how the Camera is able to move in the scene.
  91622. */
  91623. lowerAlphaLimit: Nullable<number>;
  91624. /**
  91625. * Maximum allowed angle on the longitudinal axis.
  91626. * This can help limiting how the Camera is able to move in the scene.
  91627. */
  91628. upperAlphaLimit: Nullable<number>;
  91629. /**
  91630. * Minimum allowed angle on the latitudinal axis.
  91631. * This can help limiting how the Camera is able to move in the scene.
  91632. */
  91633. lowerBetaLimit: number;
  91634. /**
  91635. * Maximum allowed angle on the latitudinal axis.
  91636. * This can help limiting how the Camera is able to move in the scene.
  91637. */
  91638. upperBetaLimit: number;
  91639. /**
  91640. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  91641. * This can help limiting how the Camera is able to move in the scene.
  91642. */
  91643. lowerRadiusLimit: Nullable<number>;
  91644. /**
  91645. * Maximum allowed distance of the camera to the target (The camera can not get further).
  91646. * This can help limiting how the Camera is able to move in the scene.
  91647. */
  91648. upperRadiusLimit: Nullable<number>;
  91649. /**
  91650. * Defines the current inertia value used during panning of the camera along the X axis.
  91651. */
  91652. inertialPanningX: number;
  91653. /**
  91654. * Defines the current inertia value used during panning of the camera along the Y axis.
  91655. */
  91656. inertialPanningY: number;
  91657. /**
  91658. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  91659. * Basically if your fingers moves away from more than this distance you will be considered
  91660. * in pinch mode.
  91661. */
  91662. pinchToPanMaxDistance: number;
  91663. /**
  91664. * Defines the maximum distance the camera can pan.
  91665. * This could help keeping the cammera always in your scene.
  91666. */
  91667. panningDistanceLimit: Nullable<number>;
  91668. /**
  91669. * Defines the target of the camera before paning.
  91670. */
  91671. panningOriginTarget: Vector3;
  91672. /**
  91673. * Defines the value of the inertia used during panning.
  91674. * 0 would mean stop inertia and one would mean no decelleration at all.
  91675. */
  91676. panningInertia: number;
  91677. /**
  91678. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  91679. */
  91680. angularSensibilityX: number;
  91681. /**
  91682. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  91683. */
  91684. angularSensibilityY: number;
  91685. /**
  91686. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  91687. */
  91688. pinchPrecision: number;
  91689. /**
  91690. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  91691. * It will be used instead of pinchDeltaPrecision if different from 0.
  91692. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91693. */
  91694. pinchDeltaPercentage: number;
  91695. /**
  91696. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  91697. */
  91698. panningSensibility: number;
  91699. /**
  91700. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  91701. */
  91702. keysUp: number[];
  91703. /**
  91704. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  91705. */
  91706. keysDown: number[];
  91707. /**
  91708. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  91709. */
  91710. keysLeft: number[];
  91711. /**
  91712. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  91713. */
  91714. keysRight: number[];
  91715. /**
  91716. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91717. */
  91718. wheelPrecision: number;
  91719. /**
  91720. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  91721. * It will be used instead of pinchDeltaPrecision if different from 0.
  91722. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91723. */
  91724. wheelDeltaPercentage: number;
  91725. /**
  91726. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  91727. */
  91728. zoomOnFactor: number;
  91729. /**
  91730. * Defines a screen offset for the camera position.
  91731. */
  91732. targetScreenOffset: Vector2;
  91733. /**
  91734. * Allows the camera to be completely reversed.
  91735. * If false the camera can not arrive upside down.
  91736. */
  91737. allowUpsideDown: boolean;
  91738. /**
  91739. * Define if double tap/click is used to restore the previously saved state of the camera.
  91740. */
  91741. useInputToRestoreState: boolean;
  91742. /** @hidden */
  91743. _viewMatrix: Matrix;
  91744. /** @hidden */
  91745. _useCtrlForPanning: boolean;
  91746. /** @hidden */
  91747. _panningMouseButton: number;
  91748. /**
  91749. * Defines the input associated to the camera.
  91750. */
  91751. inputs: ArcRotateCameraInputsManager;
  91752. /** @hidden */
  91753. _reset: () => void;
  91754. /**
  91755. * Defines the allowed panning axis.
  91756. */
  91757. panningAxis: Vector3;
  91758. protected _localDirection: Vector3;
  91759. protected _transformedDirection: Vector3;
  91760. private _bouncingBehavior;
  91761. /**
  91762. * Gets the bouncing behavior of the camera if it has been enabled.
  91763. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91764. */
  91765. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  91766. /**
  91767. * Defines if the bouncing behavior of the camera is enabled on the camera.
  91768. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91769. */
  91770. useBouncingBehavior: boolean;
  91771. private _framingBehavior;
  91772. /**
  91773. * Gets the framing behavior of the camera if it has been enabled.
  91774. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91775. */
  91776. readonly framingBehavior: Nullable<FramingBehavior>;
  91777. /**
  91778. * Defines if the framing behavior of the camera is enabled on the camera.
  91779. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91780. */
  91781. useFramingBehavior: boolean;
  91782. private _autoRotationBehavior;
  91783. /**
  91784. * Gets the auto rotation behavior of the camera if it has been enabled.
  91785. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91786. */
  91787. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  91788. /**
  91789. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  91790. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91791. */
  91792. useAutoRotationBehavior: boolean;
  91793. /**
  91794. * Observable triggered when the mesh target has been changed on the camera.
  91795. */
  91796. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  91797. /**
  91798. * Event raised when the camera is colliding with a mesh.
  91799. */
  91800. onCollide: (collidedMesh: AbstractMesh) => void;
  91801. /**
  91802. * Defines whether the camera should check collision with the objects oh the scene.
  91803. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  91804. */
  91805. checkCollisions: boolean;
  91806. /**
  91807. * Defines the collision radius of the camera.
  91808. * This simulates a sphere around the camera.
  91809. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91810. */
  91811. collisionRadius: Vector3;
  91812. protected _collider: Collider;
  91813. protected _previousPosition: Vector3;
  91814. protected _collisionVelocity: Vector3;
  91815. protected _newPosition: Vector3;
  91816. protected _previousAlpha: number;
  91817. protected _previousBeta: number;
  91818. protected _previousRadius: number;
  91819. protected _collisionTriggered: boolean;
  91820. protected _targetBoundingCenter: Nullable<Vector3>;
  91821. private _computationVector;
  91822. private _tempAxisVector;
  91823. private _tempAxisRotationMatrix;
  91824. /**
  91825. * Instantiates a new ArcRotateCamera in a given scene
  91826. * @param name Defines the name of the camera
  91827. * @param alpha Defines the camera rotation along the logitudinal axis
  91828. * @param beta Defines the camera rotation along the latitudinal axis
  91829. * @param radius Defines the camera distance from its target
  91830. * @param target Defines the camera target
  91831. * @param scene Defines the scene the camera belongs to
  91832. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91833. */
  91834. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91835. /** @hidden */
  91836. _initCache(): void;
  91837. /** @hidden */
  91838. _updateCache(ignoreParentClass?: boolean): void;
  91839. protected _getTargetPosition(): Vector3;
  91840. private _storedAlpha;
  91841. private _storedBeta;
  91842. private _storedRadius;
  91843. private _storedTarget;
  91844. /**
  91845. * Stores the current state of the camera (alpha, beta, radius and target)
  91846. * @returns the camera itself
  91847. */
  91848. storeState(): Camera;
  91849. /**
  91850. * @hidden
  91851. * Restored camera state. You must call storeState() first
  91852. */
  91853. _restoreStateValues(): boolean;
  91854. /** @hidden */
  91855. _isSynchronizedViewMatrix(): boolean;
  91856. /**
  91857. * Attached controls to the current camera.
  91858. * @param element Defines the element the controls should be listened from
  91859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91860. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  91861. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  91862. */
  91863. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  91864. /**
  91865. * Detach the current controls from the camera.
  91866. * The camera will stop reacting to inputs.
  91867. * @param element Defines the element to stop listening the inputs from
  91868. */
  91869. detachControl(element: HTMLElement): void;
  91870. /** @hidden */
  91871. _checkInputs(): void;
  91872. protected _checkLimits(): void;
  91873. /**
  91874. * Rebuilds angles (alpha, beta) and radius from the give position and target
  91875. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  91876. */
  91877. rebuildAnglesAndRadius(updateView?: boolean): void;
  91878. /**
  91879. * Use a position to define the current camera related information like aplha, beta and radius
  91880. * @param position Defines the position to set the camera at
  91881. */
  91882. setPosition(position: Vector3): void;
  91883. /**
  91884. * Defines the target the camera should look at.
  91885. * This will automatically adapt alpha beta and radius to fit within the new target.
  91886. * @param target Defines the new target as a Vector or a mesh
  91887. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  91888. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  91889. */
  91890. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  91891. /** @hidden */
  91892. _getViewMatrix(): Matrix;
  91893. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  91894. /**
  91895. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  91896. * @param meshes Defines the mesh to zoom on
  91897. * @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)
  91898. */
  91899. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  91900. /**
  91901. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  91902. * The target will be changed but the radius
  91903. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  91904. * @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)
  91905. */
  91906. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  91907. min: Vector3;
  91908. max: Vector3;
  91909. distance: number;
  91910. }, doNotUpdateMaxZ?: boolean): void;
  91911. /**
  91912. * @override
  91913. * Override Camera.createRigCamera
  91914. */
  91915. createRigCamera(name: string, cameraIndex: number): Camera;
  91916. /**
  91917. * @hidden
  91918. * @override
  91919. * Override Camera._updateRigCameras
  91920. */
  91921. _updateRigCameras(): void;
  91922. /**
  91923. * Destroy the camera and release the current resources hold by it.
  91924. */
  91925. dispose(): void;
  91926. /**
  91927. * Gets the current object class name.
  91928. * @return the class name
  91929. */
  91930. getClassName(): string;
  91931. }
  91932. }
  91933. declare module BABYLON {
  91934. /**
  91935. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  91936. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91937. */
  91938. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  91939. /**
  91940. * Gets the name of the behavior.
  91941. */
  91942. readonly name: string;
  91943. private _zoomStopsAnimation;
  91944. private _idleRotationSpeed;
  91945. private _idleRotationWaitTime;
  91946. private _idleRotationSpinupTime;
  91947. /**
  91948. * Sets the flag that indicates if user zooming should stop animation.
  91949. */
  91950. /**
  91951. * Gets the flag that indicates if user zooming should stop animation.
  91952. */
  91953. zoomStopsAnimation: boolean;
  91954. /**
  91955. * Sets the default speed at which the camera rotates around the model.
  91956. */
  91957. /**
  91958. * Gets the default speed at which the camera rotates around the model.
  91959. */
  91960. idleRotationSpeed: number;
  91961. /**
  91962. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  91963. */
  91964. /**
  91965. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  91966. */
  91967. idleRotationWaitTime: number;
  91968. /**
  91969. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  91970. */
  91971. /**
  91972. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  91973. */
  91974. idleRotationSpinupTime: number;
  91975. /**
  91976. * Gets a value indicating if the camera is currently rotating because of this behavior
  91977. */
  91978. readonly rotationInProgress: boolean;
  91979. private _onPrePointerObservableObserver;
  91980. private _onAfterCheckInputsObserver;
  91981. private _attachedCamera;
  91982. private _isPointerDown;
  91983. private _lastFrameTime;
  91984. private _lastInteractionTime;
  91985. private _cameraRotationSpeed;
  91986. /**
  91987. * Initializes the behavior.
  91988. */
  91989. init(): void;
  91990. /**
  91991. * Attaches the behavior to its arc rotate camera.
  91992. * @param camera Defines the camera to attach the behavior to
  91993. */
  91994. attach(camera: ArcRotateCamera): void;
  91995. /**
  91996. * Detaches the behavior from its current arc rotate camera.
  91997. */
  91998. detach(): void;
  91999. /**
  92000. * Returns true if user is scrolling.
  92001. * @return true if user is scrolling.
  92002. */
  92003. private _userIsZooming;
  92004. private _lastFrameRadius;
  92005. private _shouldAnimationStopForInteraction;
  92006. /**
  92007. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92008. */
  92009. private _applyUserInteraction;
  92010. private _userIsMoving;
  92011. }
  92012. }
  92013. declare module BABYLON {
  92014. /**
  92015. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  92016. */
  92017. export class AttachToBoxBehavior implements Behavior<Mesh> {
  92018. private ui;
  92019. /**
  92020. * The name of the behavior
  92021. */
  92022. name: string;
  92023. /**
  92024. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  92025. */
  92026. distanceAwayFromFace: number;
  92027. /**
  92028. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  92029. */
  92030. distanceAwayFromBottomOfFace: number;
  92031. private _faceVectors;
  92032. private _target;
  92033. private _scene;
  92034. private _onRenderObserver;
  92035. private _tmpMatrix;
  92036. private _tmpVector;
  92037. /**
  92038. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  92039. * @param ui The transform node that should be attched to the mesh
  92040. */
  92041. constructor(ui: TransformNode);
  92042. /**
  92043. * Initializes the behavior
  92044. */
  92045. init(): void;
  92046. private _closestFace;
  92047. private _zeroVector;
  92048. private _lookAtTmpMatrix;
  92049. private _lookAtToRef;
  92050. /**
  92051. * Attaches the AttachToBoxBehavior to the passed in mesh
  92052. * @param target The mesh that the specified node will be attached to
  92053. */
  92054. attach(target: Mesh): void;
  92055. /**
  92056. * Detaches the behavior from the mesh
  92057. */
  92058. detach(): void;
  92059. }
  92060. }
  92061. declare module BABYLON {
  92062. /**
  92063. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92064. */
  92065. export class FadeInOutBehavior implements Behavior<Mesh> {
  92066. /**
  92067. * Time in milliseconds to delay before fading in (Default: 0)
  92068. */
  92069. delay: number;
  92070. /**
  92071. * Time in milliseconds for the mesh to fade in (Default: 300)
  92072. */
  92073. fadeInTime: number;
  92074. private _millisecondsPerFrame;
  92075. private _hovered;
  92076. private _hoverValue;
  92077. private _ownerNode;
  92078. /**
  92079. * Instatiates the FadeInOutBehavior
  92080. */
  92081. constructor();
  92082. /**
  92083. * The name of the behavior
  92084. */
  92085. readonly name: string;
  92086. /**
  92087. * Initializes the behavior
  92088. */
  92089. init(): void;
  92090. /**
  92091. * Attaches the fade behavior on the passed in mesh
  92092. * @param ownerNode The mesh that will be faded in/out once attached
  92093. */
  92094. attach(ownerNode: Mesh): void;
  92095. /**
  92096. * Detaches the behavior from the mesh
  92097. */
  92098. detach(): void;
  92099. /**
  92100. * Triggers the mesh to begin fading in or out
  92101. * @param value if the object should fade in or out (true to fade in)
  92102. */
  92103. fadeIn(value: boolean): void;
  92104. private _update;
  92105. private _setAllVisibility;
  92106. }
  92107. }
  92108. declare module BABYLON {
  92109. /**
  92110. * Class containing a set of static utilities functions for managing Pivots
  92111. * @hidden
  92112. */
  92113. export class PivotTools {
  92114. private static _PivotCached;
  92115. private static _OldPivotPoint;
  92116. private static _PivotTranslation;
  92117. private static _PivotTmpVector;
  92118. /** @hidden */
  92119. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92120. /** @hidden */
  92121. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92122. }
  92123. }
  92124. declare module BABYLON {
  92125. /**
  92126. * Class containing static functions to help procedurally build meshes
  92127. */
  92128. export class PlaneBuilder {
  92129. /**
  92130. * Creates a plane mesh
  92131. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92132. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92133. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92137. * @param name defines the name of the mesh
  92138. * @param options defines the options used to create the mesh
  92139. * @param scene defines the hosting scene
  92140. * @returns the plane mesh
  92141. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92142. */
  92143. static CreatePlane(name: string, options: {
  92144. size?: number;
  92145. width?: number;
  92146. height?: number;
  92147. sideOrientation?: number;
  92148. frontUVs?: Vector4;
  92149. backUVs?: Vector4;
  92150. updatable?: boolean;
  92151. sourcePlane?: Plane;
  92152. }, scene: Scene): Mesh;
  92153. }
  92154. }
  92155. declare module BABYLON {
  92156. /**
  92157. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92158. */
  92159. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92160. private static _AnyMouseID;
  92161. private _attachedNode;
  92162. private _dragPlane;
  92163. private _scene;
  92164. private _pointerObserver;
  92165. private _beforeRenderObserver;
  92166. private static _planeScene;
  92167. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92168. /**
  92169. * 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)
  92170. */
  92171. maxDragAngle: number;
  92172. /**
  92173. * @hidden
  92174. */
  92175. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92176. /**
  92177. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92178. */
  92179. currentDraggingPointerID: number;
  92180. /**
  92181. * The last position where the pointer hit the drag plane in world space
  92182. */
  92183. lastDragPosition: Vector3;
  92184. /**
  92185. * If the behavior is currently in a dragging state
  92186. */
  92187. dragging: boolean;
  92188. /**
  92189. * 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)
  92190. */
  92191. dragDeltaRatio: number;
  92192. /**
  92193. * If the drag plane orientation should be updated during the dragging (Default: true)
  92194. */
  92195. updateDragPlane: boolean;
  92196. private _debugMode;
  92197. private _moving;
  92198. /**
  92199. * Fires each time the attached mesh is dragged with the pointer
  92200. * * delta between last drag position and current drag position in world space
  92201. * * dragDistance along the drag axis
  92202. * * dragPlaneNormal normal of the current drag plane used during the drag
  92203. * * dragPlanePoint in world space where the drag intersects the drag plane
  92204. */
  92205. onDragObservable: Observable<{
  92206. delta: Vector3;
  92207. dragPlanePoint: Vector3;
  92208. dragPlaneNormal: Vector3;
  92209. dragDistance: number;
  92210. pointerId: number;
  92211. }>;
  92212. /**
  92213. * Fires each time a drag begins (eg. mouse down on mesh)
  92214. */
  92215. onDragStartObservable: Observable<{
  92216. dragPlanePoint: Vector3;
  92217. pointerId: number;
  92218. }>;
  92219. /**
  92220. * Fires each time a drag ends (eg. mouse release after drag)
  92221. */
  92222. onDragEndObservable: Observable<{
  92223. dragPlanePoint: Vector3;
  92224. pointerId: number;
  92225. }>;
  92226. /**
  92227. * If the attached mesh should be moved when dragged
  92228. */
  92229. moveAttached: boolean;
  92230. /**
  92231. * If the drag behavior will react to drag events (Default: true)
  92232. */
  92233. enabled: boolean;
  92234. /**
  92235. * If camera controls should be detached during the drag
  92236. */
  92237. detachCameraControls: boolean;
  92238. /**
  92239. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92240. */
  92241. useObjectOrienationForDragging: boolean;
  92242. private _options;
  92243. /**
  92244. * Creates a pointer drag behavior that can be attached to a mesh
  92245. * @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)
  92246. */
  92247. constructor(options?: {
  92248. dragAxis?: Vector3;
  92249. dragPlaneNormal?: Vector3;
  92250. });
  92251. /**
  92252. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92253. */
  92254. validateDrag: (targetPosition: Vector3) => boolean;
  92255. /**
  92256. * The name of the behavior
  92257. */
  92258. readonly name: string;
  92259. /**
  92260. * Initializes the behavior
  92261. */
  92262. init(): void;
  92263. private _tmpVector;
  92264. private _alternatePickedPoint;
  92265. private _worldDragAxis;
  92266. private _targetPosition;
  92267. private _attachedElement;
  92268. /**
  92269. * Attaches the drag behavior the passed in mesh
  92270. * @param ownerNode The mesh that will be dragged around once attached
  92271. */
  92272. attach(ownerNode: AbstractMesh): void;
  92273. /**
  92274. * Force relase the drag action by code.
  92275. */
  92276. releaseDrag(): void;
  92277. private _startDragRay;
  92278. private _lastPointerRay;
  92279. /**
  92280. * Simulates the start of a pointer drag event on the behavior
  92281. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92282. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92283. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92284. */
  92285. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92286. private _startDrag;
  92287. private _dragDelta;
  92288. private _moveDrag;
  92289. private _pickWithRayOnDragPlane;
  92290. private _pointA;
  92291. private _pointB;
  92292. private _pointC;
  92293. private _lineA;
  92294. private _lineB;
  92295. private _localAxis;
  92296. private _lookAt;
  92297. private _updateDragPlanePosition;
  92298. /**
  92299. * Detaches the behavior from the mesh
  92300. */
  92301. detach(): void;
  92302. }
  92303. }
  92304. declare module BABYLON {
  92305. /**
  92306. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92307. */
  92308. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92309. private _dragBehaviorA;
  92310. private _dragBehaviorB;
  92311. private _startDistance;
  92312. private _initialScale;
  92313. private _targetScale;
  92314. private _ownerNode;
  92315. private _sceneRenderObserver;
  92316. /**
  92317. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92318. */
  92319. constructor();
  92320. /**
  92321. * The name of the behavior
  92322. */
  92323. readonly name: string;
  92324. /**
  92325. * Initializes the behavior
  92326. */
  92327. init(): void;
  92328. private _getCurrentDistance;
  92329. /**
  92330. * Attaches the scale behavior the passed in mesh
  92331. * @param ownerNode The mesh that will be scaled around once attached
  92332. */
  92333. attach(ownerNode: Mesh): void;
  92334. /**
  92335. * Detaches the behavior from the mesh
  92336. */
  92337. detach(): void;
  92338. }
  92339. }
  92340. declare module BABYLON {
  92341. /**
  92342. * 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
  92343. */
  92344. export class SixDofDragBehavior implements Behavior<Mesh> {
  92345. private static _virtualScene;
  92346. private _ownerNode;
  92347. private _sceneRenderObserver;
  92348. private _scene;
  92349. private _targetPosition;
  92350. private _virtualOriginMesh;
  92351. private _virtualDragMesh;
  92352. private _pointerObserver;
  92353. private _moving;
  92354. private _startingOrientation;
  92355. /**
  92356. * 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)
  92357. */
  92358. private zDragFactor;
  92359. /**
  92360. * If the object should rotate to face the drag origin
  92361. */
  92362. rotateDraggedObject: boolean;
  92363. /**
  92364. * If the behavior is currently in a dragging state
  92365. */
  92366. dragging: boolean;
  92367. /**
  92368. * 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)
  92369. */
  92370. dragDeltaRatio: number;
  92371. /**
  92372. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92373. */
  92374. currentDraggingPointerID: number;
  92375. /**
  92376. * If camera controls should be detached during the drag
  92377. */
  92378. detachCameraControls: boolean;
  92379. /**
  92380. * Fires each time a drag starts
  92381. */
  92382. onDragStartObservable: Observable<{}>;
  92383. /**
  92384. * Fires each time a drag ends (eg. mouse release after drag)
  92385. */
  92386. onDragEndObservable: Observable<{}>;
  92387. /**
  92388. * 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
  92389. */
  92390. constructor();
  92391. /**
  92392. * The name of the behavior
  92393. */
  92394. readonly name: string;
  92395. /**
  92396. * Initializes the behavior
  92397. */
  92398. init(): void;
  92399. /**
  92400. * Attaches the scale behavior the passed in mesh
  92401. * @param ownerNode The mesh that will be scaled around once attached
  92402. */
  92403. attach(ownerNode: Mesh): void;
  92404. /**
  92405. * Detaches the behavior from the mesh
  92406. */
  92407. detach(): void;
  92408. }
  92409. }
  92410. declare module BABYLON {
  92411. /**
  92412. * Class used to apply inverse kinematics to bones
  92413. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  92414. */
  92415. export class BoneIKController {
  92416. private static _tmpVecs;
  92417. private static _tmpQuat;
  92418. private static _tmpMats;
  92419. /**
  92420. * Gets or sets the target mesh
  92421. */
  92422. targetMesh: AbstractMesh;
  92423. /** Gets or sets the mesh used as pole */
  92424. poleTargetMesh: AbstractMesh;
  92425. /**
  92426. * Gets or sets the bone used as pole
  92427. */
  92428. poleTargetBone: Nullable<Bone>;
  92429. /**
  92430. * Gets or sets the target position
  92431. */
  92432. targetPosition: Vector3;
  92433. /**
  92434. * Gets or sets the pole target position
  92435. */
  92436. poleTargetPosition: Vector3;
  92437. /**
  92438. * Gets or sets the pole target local offset
  92439. */
  92440. poleTargetLocalOffset: Vector3;
  92441. /**
  92442. * Gets or sets the pole angle
  92443. */
  92444. poleAngle: number;
  92445. /**
  92446. * Gets or sets the mesh associated with the controller
  92447. */
  92448. mesh: AbstractMesh;
  92449. /**
  92450. * 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)
  92451. */
  92452. slerpAmount: number;
  92453. private _bone1Quat;
  92454. private _bone1Mat;
  92455. private _bone2Ang;
  92456. private _bone1;
  92457. private _bone2;
  92458. private _bone1Length;
  92459. private _bone2Length;
  92460. private _maxAngle;
  92461. private _maxReach;
  92462. private _rightHandedSystem;
  92463. private _bendAxis;
  92464. private _slerping;
  92465. private _adjustRoll;
  92466. /**
  92467. * Gets or sets maximum allowed angle
  92468. */
  92469. maxAngle: number;
  92470. /**
  92471. * Creates a new BoneIKController
  92472. * @param mesh defines the mesh to control
  92473. * @param bone defines the bone to control
  92474. * @param options defines options to set up the controller
  92475. */
  92476. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  92477. targetMesh?: AbstractMesh;
  92478. poleTargetMesh?: AbstractMesh;
  92479. poleTargetBone?: Bone;
  92480. poleTargetLocalOffset?: Vector3;
  92481. poleAngle?: number;
  92482. bendAxis?: Vector3;
  92483. maxAngle?: number;
  92484. slerpAmount?: number;
  92485. });
  92486. private _setMaxAngle;
  92487. /**
  92488. * Force the controller to update the bones
  92489. */
  92490. update(): void;
  92491. }
  92492. }
  92493. declare module BABYLON {
  92494. /**
  92495. * Class used to make a bone look toward a point in space
  92496. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  92497. */
  92498. export class BoneLookController {
  92499. private static _tmpVecs;
  92500. private static _tmpQuat;
  92501. private static _tmpMats;
  92502. /**
  92503. * The target Vector3 that the bone will look at
  92504. */
  92505. target: Vector3;
  92506. /**
  92507. * The mesh that the bone is attached to
  92508. */
  92509. mesh: AbstractMesh;
  92510. /**
  92511. * The bone that will be looking to the target
  92512. */
  92513. bone: Bone;
  92514. /**
  92515. * The up axis of the coordinate system that is used when the bone is rotated
  92516. */
  92517. upAxis: Vector3;
  92518. /**
  92519. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  92520. */
  92521. upAxisSpace: Space;
  92522. /**
  92523. * Used to make an adjustment to the yaw of the bone
  92524. */
  92525. adjustYaw: number;
  92526. /**
  92527. * Used to make an adjustment to the pitch of the bone
  92528. */
  92529. adjustPitch: number;
  92530. /**
  92531. * Used to make an adjustment to the roll of the bone
  92532. */
  92533. adjustRoll: number;
  92534. /**
  92535. * 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)
  92536. */
  92537. slerpAmount: number;
  92538. private _minYaw;
  92539. private _maxYaw;
  92540. private _minPitch;
  92541. private _maxPitch;
  92542. private _minYawSin;
  92543. private _minYawCos;
  92544. private _maxYawSin;
  92545. private _maxYawCos;
  92546. private _midYawConstraint;
  92547. private _minPitchTan;
  92548. private _maxPitchTan;
  92549. private _boneQuat;
  92550. private _slerping;
  92551. private _transformYawPitch;
  92552. private _transformYawPitchInv;
  92553. private _firstFrameSkipped;
  92554. private _yawRange;
  92555. private _fowardAxis;
  92556. /**
  92557. * Gets or sets the minimum yaw angle that the bone can look to
  92558. */
  92559. minYaw: number;
  92560. /**
  92561. * Gets or sets the maximum yaw angle that the bone can look to
  92562. */
  92563. maxYaw: number;
  92564. /**
  92565. * Gets or sets the minimum pitch angle that the bone can look to
  92566. */
  92567. minPitch: number;
  92568. /**
  92569. * Gets or sets the maximum pitch angle that the bone can look to
  92570. */
  92571. maxPitch: number;
  92572. /**
  92573. * Create a BoneLookController
  92574. * @param mesh the mesh that the bone belongs to
  92575. * @param bone the bone that will be looking to the target
  92576. * @param target the target Vector3 to look at
  92577. * @param options optional settings:
  92578. * * maxYaw: the maximum angle the bone will yaw to
  92579. * * minYaw: the minimum angle the bone will yaw to
  92580. * * maxPitch: the maximum angle the bone will pitch to
  92581. * * minPitch: the minimum angle the bone will yaw to
  92582. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  92583. * * upAxis: the up axis of the coordinate system
  92584. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  92585. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  92586. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  92587. * * adjustYaw: used to make an adjustment to the yaw of the bone
  92588. * * adjustPitch: used to make an adjustment to the pitch of the bone
  92589. * * adjustRoll: used to make an adjustment to the roll of the bone
  92590. **/
  92591. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  92592. maxYaw?: number;
  92593. minYaw?: number;
  92594. maxPitch?: number;
  92595. minPitch?: number;
  92596. slerpAmount?: number;
  92597. upAxis?: Vector3;
  92598. upAxisSpace?: Space;
  92599. yawAxis?: Vector3;
  92600. pitchAxis?: Vector3;
  92601. adjustYaw?: number;
  92602. adjustPitch?: number;
  92603. adjustRoll?: number;
  92604. });
  92605. /**
  92606. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  92607. */
  92608. update(): void;
  92609. private _getAngleDiff;
  92610. private _getAngleBetween;
  92611. private _isAngleBetween;
  92612. }
  92613. }
  92614. declare module BABYLON {
  92615. /**
  92616. * Manage the gamepad inputs to control an arc rotate camera.
  92617. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92618. */
  92619. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  92620. /**
  92621. * Defines the camera the input is attached to.
  92622. */
  92623. camera: ArcRotateCamera;
  92624. /**
  92625. * Defines the gamepad the input is gathering event from.
  92626. */
  92627. gamepad: Nullable<Gamepad>;
  92628. /**
  92629. * Defines the gamepad rotation sensiblity.
  92630. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92631. */
  92632. gamepadRotationSensibility: number;
  92633. /**
  92634. * Defines the gamepad move sensiblity.
  92635. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92636. */
  92637. gamepadMoveSensibility: number;
  92638. private _onGamepadConnectedObserver;
  92639. private _onGamepadDisconnectedObserver;
  92640. /**
  92641. * Attach the input controls to a specific dom element to get the input from.
  92642. * @param element Defines the element the controls should be listened from
  92643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92644. */
  92645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92646. /**
  92647. * Detach the current controls from the specified dom element.
  92648. * @param element Defines the element to stop listening the inputs from
  92649. */
  92650. detachControl(element: Nullable<HTMLElement>): void;
  92651. /**
  92652. * Update the current camera state depending on the inputs that have been used this frame.
  92653. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92654. */
  92655. checkInputs(): void;
  92656. /**
  92657. * Gets the class name of the current intput.
  92658. * @returns the class name
  92659. */
  92660. getClassName(): string;
  92661. /**
  92662. * Get the friendly name associated with the input class.
  92663. * @returns the input friendly name
  92664. */
  92665. getSimpleName(): string;
  92666. }
  92667. }
  92668. declare module BABYLON {
  92669. interface ArcRotateCameraInputsManager {
  92670. /**
  92671. * Add orientation input support to the input manager.
  92672. * @returns the current input manager
  92673. */
  92674. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  92675. }
  92676. /**
  92677. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  92678. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92679. */
  92680. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  92681. /**
  92682. * Defines the camera the input is attached to.
  92683. */
  92684. camera: ArcRotateCamera;
  92685. /**
  92686. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  92687. */
  92688. alphaCorrection: number;
  92689. /**
  92690. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  92691. */
  92692. gammaCorrection: number;
  92693. private _alpha;
  92694. private _gamma;
  92695. private _dirty;
  92696. private _deviceOrientationHandler;
  92697. /**
  92698. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  92699. */
  92700. constructor();
  92701. /**
  92702. * Attach the input controls to a specific dom element to get the input from.
  92703. * @param element Defines the element the controls should be listened from
  92704. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92705. */
  92706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92707. /** @hidden */
  92708. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  92709. /**
  92710. * Update the current camera state depending on the inputs that have been used this frame.
  92711. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92712. */
  92713. checkInputs(): void;
  92714. /**
  92715. * Detach the current controls from the specified dom element.
  92716. * @param element Defines the element to stop listening the inputs from
  92717. */
  92718. detachControl(element: Nullable<HTMLElement>): void;
  92719. /**
  92720. * Gets the class name of the current intput.
  92721. * @returns the class name
  92722. */
  92723. getClassName(): string;
  92724. /**
  92725. * Get the friendly name associated with the input class.
  92726. * @returns the input friendly name
  92727. */
  92728. getSimpleName(): string;
  92729. }
  92730. }
  92731. declare module BABYLON {
  92732. /**
  92733. * Listen to mouse events to control the camera.
  92734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92735. */
  92736. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  92737. /**
  92738. * Defines the camera the input is attached to.
  92739. */
  92740. camera: FlyCamera;
  92741. /**
  92742. * Defines if touch is enabled. (Default is true.)
  92743. */
  92744. touchEnabled: boolean;
  92745. /**
  92746. * Defines the buttons associated with the input to handle camera rotation.
  92747. */
  92748. buttons: number[];
  92749. /**
  92750. * Assign buttons for Yaw control.
  92751. */
  92752. buttonsYaw: number[];
  92753. /**
  92754. * Assign buttons for Pitch control.
  92755. */
  92756. buttonsPitch: number[];
  92757. /**
  92758. * Assign buttons for Roll control.
  92759. */
  92760. buttonsRoll: number[];
  92761. /**
  92762. * Detect if any button is being pressed while mouse is moved.
  92763. * -1 = Mouse locked.
  92764. * 0 = Left button.
  92765. * 1 = Middle Button.
  92766. * 2 = Right Button.
  92767. */
  92768. activeButton: number;
  92769. /**
  92770. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  92771. * Higher values reduce its sensitivity.
  92772. */
  92773. angularSensibility: number;
  92774. private _mousemoveCallback;
  92775. private _observer;
  92776. private _rollObserver;
  92777. private previousPosition;
  92778. private noPreventDefault;
  92779. private element;
  92780. /**
  92781. * Listen to mouse events to control the camera.
  92782. * @param touchEnabled Define if touch is enabled. (Default is true.)
  92783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92784. */
  92785. constructor(touchEnabled?: boolean);
  92786. /**
  92787. * Attach the mouse control to the HTML DOM element.
  92788. * @param element Defines the element that listens to the input events.
  92789. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  92790. */
  92791. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92792. /**
  92793. * Detach the current controls from the specified dom element.
  92794. * @param element Defines the element to stop listening the inputs from
  92795. */
  92796. detachControl(element: Nullable<HTMLElement>): void;
  92797. /**
  92798. * Gets the class name of the current input.
  92799. * @returns the class name.
  92800. */
  92801. getClassName(): string;
  92802. /**
  92803. * Get the friendly name associated with the input class.
  92804. * @returns the input's friendly name.
  92805. */
  92806. getSimpleName(): string;
  92807. private _pointerInput;
  92808. private _onMouseMove;
  92809. /**
  92810. * Rotate camera by mouse offset.
  92811. */
  92812. private rotateCamera;
  92813. }
  92814. }
  92815. declare module BABYLON {
  92816. /**
  92817. * Default Inputs manager for the FlyCamera.
  92818. * It groups all the default supported inputs for ease of use.
  92819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92820. */
  92821. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  92822. /**
  92823. * Instantiates a new FlyCameraInputsManager.
  92824. * @param camera Defines the camera the inputs belong to.
  92825. */
  92826. constructor(camera: FlyCamera);
  92827. /**
  92828. * Add keyboard input support to the input manager.
  92829. * @returns the new FlyCameraKeyboardMoveInput().
  92830. */
  92831. addKeyboard(): FlyCameraInputsManager;
  92832. /**
  92833. * Add mouse input support to the input manager.
  92834. * @param touchEnabled Enable touch screen support.
  92835. * @returns the new FlyCameraMouseInput().
  92836. */
  92837. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  92838. }
  92839. }
  92840. declare module BABYLON {
  92841. /**
  92842. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92843. * such as in a 3D Space Shooter or a Flight Simulator.
  92844. */
  92845. export class FlyCamera extends TargetCamera {
  92846. /**
  92847. * Define the collision ellipsoid of the camera.
  92848. * This is helpful for simulating a camera body, like a player's body.
  92849. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92850. */
  92851. ellipsoid: Vector3;
  92852. /**
  92853. * Define an offset for the position of the ellipsoid around the camera.
  92854. * This can be helpful if the camera is attached away from the player's body center,
  92855. * such as at its head.
  92856. */
  92857. ellipsoidOffset: Vector3;
  92858. /**
  92859. * Enable or disable collisions of the camera with the rest of the scene objects.
  92860. */
  92861. checkCollisions: boolean;
  92862. /**
  92863. * Enable or disable gravity on the camera.
  92864. */
  92865. applyGravity: boolean;
  92866. /**
  92867. * Define the current direction the camera is moving to.
  92868. */
  92869. cameraDirection: Vector3;
  92870. /**
  92871. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  92872. * This overrides and empties cameraRotation.
  92873. */
  92874. rotationQuaternion: Quaternion;
  92875. /**
  92876. * Track Roll to maintain the wanted Rolling when looking around.
  92877. */
  92878. _trackRoll: number;
  92879. /**
  92880. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  92881. */
  92882. rollCorrect: number;
  92883. /**
  92884. * Mimic a banked turn, Rolling the camera when Yawing.
  92885. * It's recommended to use rollCorrect = 10 for faster banking correction.
  92886. */
  92887. bankedTurn: boolean;
  92888. /**
  92889. * Limit in radians for how much Roll banking will add. (Default: 90°)
  92890. */
  92891. bankedTurnLimit: number;
  92892. /**
  92893. * Value of 0 disables the banked Roll.
  92894. * Value of 1 is equal to the Yaw angle in radians.
  92895. */
  92896. bankedTurnMultiplier: number;
  92897. /**
  92898. * The inputs manager loads all the input sources, such as keyboard and mouse.
  92899. */
  92900. inputs: FlyCameraInputsManager;
  92901. /**
  92902. * Gets the input sensibility for mouse input.
  92903. * Higher values reduce sensitivity.
  92904. */
  92905. /**
  92906. * Sets the input sensibility for a mouse input.
  92907. * Higher values reduce sensitivity.
  92908. */
  92909. angularSensibility: number;
  92910. /**
  92911. * Get the keys for camera movement forward.
  92912. */
  92913. /**
  92914. * Set the keys for camera movement forward.
  92915. */
  92916. keysForward: number[];
  92917. /**
  92918. * Get the keys for camera movement backward.
  92919. */
  92920. keysBackward: number[];
  92921. /**
  92922. * Get the keys for camera movement up.
  92923. */
  92924. /**
  92925. * Set the keys for camera movement up.
  92926. */
  92927. keysUp: number[];
  92928. /**
  92929. * Get the keys for camera movement down.
  92930. */
  92931. /**
  92932. * Set the keys for camera movement down.
  92933. */
  92934. keysDown: number[];
  92935. /**
  92936. * Get the keys for camera movement left.
  92937. */
  92938. /**
  92939. * Set the keys for camera movement left.
  92940. */
  92941. keysLeft: number[];
  92942. /**
  92943. * Set the keys for camera movement right.
  92944. */
  92945. /**
  92946. * Set the keys for camera movement right.
  92947. */
  92948. keysRight: number[];
  92949. /**
  92950. * Event raised when the camera collides with a mesh in the scene.
  92951. */
  92952. onCollide: (collidedMesh: AbstractMesh) => void;
  92953. private _collider;
  92954. private _needMoveForGravity;
  92955. private _oldPosition;
  92956. private _diffPosition;
  92957. private _newPosition;
  92958. /** @hidden */
  92959. _localDirection: Vector3;
  92960. /** @hidden */
  92961. _transformedDirection: Vector3;
  92962. /**
  92963. * Instantiates a FlyCamera.
  92964. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92965. * such as in a 3D Space Shooter or a Flight Simulator.
  92966. * @param name Define the name of the camera in the scene.
  92967. * @param position Define the starting position of the camera in the scene.
  92968. * @param scene Define the scene the camera belongs to.
  92969. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  92970. */
  92971. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92972. /**
  92973. * Attach a control to the HTML DOM element.
  92974. * @param element Defines the element that listens to the input events.
  92975. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  92976. */
  92977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92978. /**
  92979. * Detach a control from the HTML DOM element.
  92980. * The camera will stop reacting to that input.
  92981. * @param element Defines the element that listens to the input events.
  92982. */
  92983. detachControl(element: HTMLElement): void;
  92984. private _collisionMask;
  92985. /**
  92986. * Get the mask that the camera ignores in collision events.
  92987. */
  92988. /**
  92989. * Set the mask that the camera ignores in collision events.
  92990. */
  92991. collisionMask: number;
  92992. /** @hidden */
  92993. _collideWithWorld(displacement: Vector3): void;
  92994. /** @hidden */
  92995. private _onCollisionPositionChange;
  92996. /** @hidden */
  92997. _checkInputs(): void;
  92998. /** @hidden */
  92999. _decideIfNeedsToMove(): boolean;
  93000. /** @hidden */
  93001. _updatePosition(): void;
  93002. /**
  93003. * Restore the Roll to its target value at the rate specified.
  93004. * @param rate - Higher means slower restoring.
  93005. * @hidden
  93006. */
  93007. restoreRoll(rate: number): void;
  93008. /**
  93009. * Destroy the camera and release the current resources held by it.
  93010. */
  93011. dispose(): void;
  93012. /**
  93013. * Get the current object class name.
  93014. * @returns the class name.
  93015. */
  93016. getClassName(): string;
  93017. }
  93018. }
  93019. declare module BABYLON {
  93020. /**
  93021. * Listen to keyboard events to control the camera.
  93022. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93023. */
  93024. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  93025. /**
  93026. * Defines the camera the input is attached to.
  93027. */
  93028. camera: FlyCamera;
  93029. /**
  93030. * The list of keyboard keys used to control the forward move of the camera.
  93031. */
  93032. keysForward: number[];
  93033. /**
  93034. * The list of keyboard keys used to control the backward move of the camera.
  93035. */
  93036. keysBackward: number[];
  93037. /**
  93038. * The list of keyboard keys used to control the forward move of the camera.
  93039. */
  93040. keysUp: number[];
  93041. /**
  93042. * The list of keyboard keys used to control the backward move of the camera.
  93043. */
  93044. keysDown: number[];
  93045. /**
  93046. * The list of keyboard keys used to control the right strafe move of the camera.
  93047. */
  93048. keysRight: number[];
  93049. /**
  93050. * The list of keyboard keys used to control the left strafe move of the camera.
  93051. */
  93052. keysLeft: number[];
  93053. private _keys;
  93054. private _onCanvasBlurObserver;
  93055. private _onKeyboardObserver;
  93056. private _engine;
  93057. private _scene;
  93058. /**
  93059. * Attach the input controls to a specific dom element to get the input from.
  93060. * @param element Defines the element the controls should be listened from
  93061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93062. */
  93063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93064. /**
  93065. * Detach the current controls from the specified dom element.
  93066. * @param element Defines the element to stop listening the inputs from
  93067. */
  93068. detachControl(element: Nullable<HTMLElement>): void;
  93069. /**
  93070. * Gets the class name of the current intput.
  93071. * @returns the class name
  93072. */
  93073. getClassName(): string;
  93074. /** @hidden */
  93075. _onLostFocus(e: FocusEvent): void;
  93076. /**
  93077. * Get the friendly name associated with the input class.
  93078. * @returns the input friendly name
  93079. */
  93080. getSimpleName(): string;
  93081. /**
  93082. * Update the current camera state depending on the inputs that have been used this frame.
  93083. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93084. */
  93085. checkInputs(): void;
  93086. }
  93087. }
  93088. declare module BABYLON {
  93089. /**
  93090. * Manage the mouse wheel inputs to control a follow camera.
  93091. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93092. */
  93093. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93094. /**
  93095. * Defines the camera the input is attached to.
  93096. */
  93097. camera: FollowCamera;
  93098. /**
  93099. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93100. */
  93101. axisControlRadius: boolean;
  93102. /**
  93103. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93104. */
  93105. axisControlHeight: boolean;
  93106. /**
  93107. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93108. */
  93109. axisControlRotation: boolean;
  93110. /**
  93111. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93112. * relation to mouseWheel events.
  93113. */
  93114. wheelPrecision: number;
  93115. /**
  93116. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93117. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93118. */
  93119. wheelDeltaPercentage: number;
  93120. private _wheel;
  93121. private _observer;
  93122. /**
  93123. * Attach the input controls to a specific dom element to get the input from.
  93124. * @param element Defines the element the controls should be listened from
  93125. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93126. */
  93127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93128. /**
  93129. * Detach the current controls from the specified dom element.
  93130. * @param element Defines the element to stop listening the inputs from
  93131. */
  93132. detachControl(element: Nullable<HTMLElement>): void;
  93133. /**
  93134. * Gets the class name of the current intput.
  93135. * @returns the class name
  93136. */
  93137. getClassName(): string;
  93138. /**
  93139. * Get the friendly name associated with the input class.
  93140. * @returns the input friendly name
  93141. */
  93142. getSimpleName(): string;
  93143. }
  93144. }
  93145. declare module BABYLON {
  93146. /**
  93147. * Manage the pointers inputs to control an follow camera.
  93148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93149. */
  93150. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93151. /**
  93152. * Defines the camera the input is attached to.
  93153. */
  93154. camera: FollowCamera;
  93155. /**
  93156. * Gets the class name of the current input.
  93157. * @returns the class name
  93158. */
  93159. getClassName(): string;
  93160. /**
  93161. * Defines the pointer angular sensibility along the X axis or how fast is
  93162. * the camera rotating.
  93163. * A negative number will reverse the axis direction.
  93164. */
  93165. angularSensibilityX: number;
  93166. /**
  93167. * Defines the pointer angular sensibility along the Y axis or how fast is
  93168. * the camera rotating.
  93169. * A negative number will reverse the axis direction.
  93170. */
  93171. angularSensibilityY: number;
  93172. /**
  93173. * Defines the pointer pinch precision or how fast is the camera zooming.
  93174. * A negative number will reverse the axis direction.
  93175. */
  93176. pinchPrecision: number;
  93177. /**
  93178. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93179. * from 0.
  93180. * It defines the percentage of current camera.radius to use as delta when
  93181. * pinch zoom is used.
  93182. */
  93183. pinchDeltaPercentage: number;
  93184. /**
  93185. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93186. */
  93187. axisXControlRadius: boolean;
  93188. /**
  93189. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93190. */
  93191. axisXControlHeight: boolean;
  93192. /**
  93193. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93194. */
  93195. axisXControlRotation: boolean;
  93196. /**
  93197. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93198. */
  93199. axisYControlRadius: boolean;
  93200. /**
  93201. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93202. */
  93203. axisYControlHeight: boolean;
  93204. /**
  93205. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93206. */
  93207. axisYControlRotation: boolean;
  93208. /**
  93209. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93210. */
  93211. axisPinchControlRadius: boolean;
  93212. /**
  93213. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93214. */
  93215. axisPinchControlHeight: boolean;
  93216. /**
  93217. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93218. */
  93219. axisPinchControlRotation: boolean;
  93220. /**
  93221. * Log error messages if basic misconfiguration has occurred.
  93222. */
  93223. warningEnable: boolean;
  93224. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93225. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93226. private _warningCounter;
  93227. private _warning;
  93228. }
  93229. }
  93230. declare module BABYLON {
  93231. /**
  93232. * Default Inputs manager for the FollowCamera.
  93233. * It groups all the default supported inputs for ease of use.
  93234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93235. */
  93236. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93237. /**
  93238. * Instantiates a new FollowCameraInputsManager.
  93239. * @param camera Defines the camera the inputs belong to
  93240. */
  93241. constructor(camera: FollowCamera);
  93242. /**
  93243. * Add keyboard input support to the input manager.
  93244. * @returns the current input manager
  93245. */
  93246. addKeyboard(): FollowCameraInputsManager;
  93247. /**
  93248. * Add mouse wheel input support to the input manager.
  93249. * @returns the current input manager
  93250. */
  93251. addMouseWheel(): FollowCameraInputsManager;
  93252. /**
  93253. * Add pointers input support to the input manager.
  93254. * @returns the current input manager
  93255. */
  93256. addPointers(): FollowCameraInputsManager;
  93257. /**
  93258. * Add orientation input support to the input manager.
  93259. * @returns the current input manager
  93260. */
  93261. addVRDeviceOrientation(): FollowCameraInputsManager;
  93262. }
  93263. }
  93264. declare module BABYLON {
  93265. /**
  93266. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93267. * an arc rotate version arcFollowCamera are available.
  93268. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93269. */
  93270. export class FollowCamera extends TargetCamera {
  93271. /**
  93272. * Distance the follow camera should follow an object at
  93273. */
  93274. radius: number;
  93275. /**
  93276. * Minimum allowed distance of the camera to the axis of rotation
  93277. * (The camera can not get closer).
  93278. * This can help limiting how the Camera is able to move in the scene.
  93279. */
  93280. lowerRadiusLimit: Nullable<number>;
  93281. /**
  93282. * Maximum allowed distance of the camera to the axis of rotation
  93283. * (The camera can not get further).
  93284. * This can help limiting how the Camera is able to move in the scene.
  93285. */
  93286. upperRadiusLimit: Nullable<number>;
  93287. /**
  93288. * Define a rotation offset between the camera and the object it follows
  93289. */
  93290. rotationOffset: number;
  93291. /**
  93292. * Minimum allowed angle to camera position relative to target object.
  93293. * This can help limiting how the Camera is able to move in the scene.
  93294. */
  93295. lowerRotationOffsetLimit: Nullable<number>;
  93296. /**
  93297. * Maximum allowed angle to camera position relative to target object.
  93298. * This can help limiting how the Camera is able to move in the scene.
  93299. */
  93300. upperRotationOffsetLimit: Nullable<number>;
  93301. /**
  93302. * Define a height offset between the camera and the object it follows.
  93303. * It can help following an object from the top (like a car chaing a plane)
  93304. */
  93305. heightOffset: number;
  93306. /**
  93307. * Minimum allowed height of camera position relative to target object.
  93308. * This can help limiting how the Camera is able to move in the scene.
  93309. */
  93310. lowerHeightOffsetLimit: Nullable<number>;
  93311. /**
  93312. * Maximum allowed height of camera position relative to target object.
  93313. * This can help limiting how the Camera is able to move in the scene.
  93314. */
  93315. upperHeightOffsetLimit: Nullable<number>;
  93316. /**
  93317. * Define how fast the camera can accelerate to follow it s target.
  93318. */
  93319. cameraAcceleration: number;
  93320. /**
  93321. * Define the speed limit of the camera following an object.
  93322. */
  93323. maxCameraSpeed: number;
  93324. /**
  93325. * Define the target of the camera.
  93326. */
  93327. lockedTarget: Nullable<AbstractMesh>;
  93328. /**
  93329. * Defines the input associated with the camera.
  93330. */
  93331. inputs: FollowCameraInputsManager;
  93332. /**
  93333. * Instantiates the follow camera.
  93334. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93335. * @param name Define the name of the camera in the scene
  93336. * @param position Define the position of the camera
  93337. * @param scene Define the scene the camera belong to
  93338. * @param lockedTarget Define the target of the camera
  93339. */
  93340. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93341. private _follow;
  93342. /**
  93343. * Attached controls to the current camera.
  93344. * @param element Defines the element the controls should be listened from
  93345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93346. */
  93347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93348. /**
  93349. * Detach the current controls from the camera.
  93350. * The camera will stop reacting to inputs.
  93351. * @param element Defines the element to stop listening the inputs from
  93352. */
  93353. detachControl(element: HTMLElement): void;
  93354. /** @hidden */
  93355. _checkInputs(): void;
  93356. private _checkLimits;
  93357. /**
  93358. * Gets the camera class name.
  93359. * @returns the class name
  93360. */
  93361. getClassName(): string;
  93362. }
  93363. /**
  93364. * Arc Rotate version of the follow camera.
  93365. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93366. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93367. */
  93368. export class ArcFollowCamera extends TargetCamera {
  93369. /** The longitudinal angle of the camera */
  93370. alpha: number;
  93371. /** The latitudinal angle of the camera */
  93372. beta: number;
  93373. /** The radius of the camera from its target */
  93374. radius: number;
  93375. /** Define the camera target (the messh it should follow) */
  93376. target: Nullable<AbstractMesh>;
  93377. private _cartesianCoordinates;
  93378. /**
  93379. * Instantiates a new ArcFollowCamera
  93380. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93381. * @param name Define the name of the camera
  93382. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93383. * @param beta Define the rotation angle of the camera around the elevation axis
  93384. * @param radius Define the radius of the camera from its target point
  93385. * @param target Define the target of the camera
  93386. * @param scene Define the scene the camera belongs to
  93387. */
  93388. constructor(name: string,
  93389. /** The longitudinal angle of the camera */
  93390. alpha: number,
  93391. /** The latitudinal angle of the camera */
  93392. beta: number,
  93393. /** The radius of the camera from its target */
  93394. radius: number,
  93395. /** Define the camera target (the messh it should follow) */
  93396. target: Nullable<AbstractMesh>, scene: Scene);
  93397. private _follow;
  93398. /** @hidden */
  93399. _checkInputs(): void;
  93400. /**
  93401. * Returns the class name of the object.
  93402. * It is mostly used internally for serialization purposes.
  93403. */
  93404. getClassName(): string;
  93405. }
  93406. }
  93407. declare module BABYLON {
  93408. /**
  93409. * Manage the keyboard inputs to control the movement of a follow camera.
  93410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93411. */
  93412. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  93413. /**
  93414. * Defines the camera the input is attached to.
  93415. */
  93416. camera: FollowCamera;
  93417. /**
  93418. * Defines the list of key codes associated with the up action (increase heightOffset)
  93419. */
  93420. keysHeightOffsetIncr: number[];
  93421. /**
  93422. * Defines the list of key codes associated with the down action (decrease heightOffset)
  93423. */
  93424. keysHeightOffsetDecr: number[];
  93425. /**
  93426. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  93427. */
  93428. keysHeightOffsetModifierAlt: boolean;
  93429. /**
  93430. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  93431. */
  93432. keysHeightOffsetModifierCtrl: boolean;
  93433. /**
  93434. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  93435. */
  93436. keysHeightOffsetModifierShift: boolean;
  93437. /**
  93438. * Defines the list of key codes associated with the left action (increase rotationOffset)
  93439. */
  93440. keysRotationOffsetIncr: number[];
  93441. /**
  93442. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  93443. */
  93444. keysRotationOffsetDecr: number[];
  93445. /**
  93446. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  93447. */
  93448. keysRotationOffsetModifierAlt: boolean;
  93449. /**
  93450. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  93451. */
  93452. keysRotationOffsetModifierCtrl: boolean;
  93453. /**
  93454. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  93455. */
  93456. keysRotationOffsetModifierShift: boolean;
  93457. /**
  93458. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  93459. */
  93460. keysRadiusIncr: number[];
  93461. /**
  93462. * Defines the list of key codes associated with the zoom-out action (increase radius)
  93463. */
  93464. keysRadiusDecr: number[];
  93465. /**
  93466. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  93467. */
  93468. keysRadiusModifierAlt: boolean;
  93469. /**
  93470. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  93471. */
  93472. keysRadiusModifierCtrl: boolean;
  93473. /**
  93474. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  93475. */
  93476. keysRadiusModifierShift: boolean;
  93477. /**
  93478. * Defines the rate of change of heightOffset.
  93479. */
  93480. heightSensibility: number;
  93481. /**
  93482. * Defines the rate of change of rotationOffset.
  93483. */
  93484. rotationSensibility: number;
  93485. /**
  93486. * Defines the rate of change of radius.
  93487. */
  93488. radiusSensibility: number;
  93489. private _keys;
  93490. private _ctrlPressed;
  93491. private _altPressed;
  93492. private _shiftPressed;
  93493. private _onCanvasBlurObserver;
  93494. private _onKeyboardObserver;
  93495. private _engine;
  93496. private _scene;
  93497. /**
  93498. * Attach the input controls to a specific dom element to get the input from.
  93499. * @param element Defines the element the controls should be listened from
  93500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93501. */
  93502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93503. /**
  93504. * Detach the current controls from the specified dom element.
  93505. * @param element Defines the element to stop listening the inputs from
  93506. */
  93507. detachControl(element: Nullable<HTMLElement>): void;
  93508. /**
  93509. * Update the current camera state depending on the inputs that have been used this frame.
  93510. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93511. */
  93512. checkInputs(): void;
  93513. /**
  93514. * Gets the class name of the current input.
  93515. * @returns the class name
  93516. */
  93517. getClassName(): string;
  93518. /**
  93519. * Get the friendly name associated with the input class.
  93520. * @returns the input friendly name
  93521. */
  93522. getSimpleName(): string;
  93523. /**
  93524. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93525. * allow modification of the heightOffset value.
  93526. */
  93527. private _modifierHeightOffset;
  93528. /**
  93529. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93530. * allow modification of the rotationOffset value.
  93531. */
  93532. private _modifierRotationOffset;
  93533. /**
  93534. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93535. * allow modification of the radius value.
  93536. */
  93537. private _modifierRadius;
  93538. }
  93539. }
  93540. declare module BABYLON {
  93541. interface FreeCameraInputsManager {
  93542. /**
  93543. * Add orientation input support to the input manager.
  93544. * @returns the current input manager
  93545. */
  93546. addDeviceOrientation(): FreeCameraInputsManager;
  93547. }
  93548. /**
  93549. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  93550. * Screen rotation is taken into account.
  93551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93552. */
  93553. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  93554. private _camera;
  93555. private _screenOrientationAngle;
  93556. private _constantTranform;
  93557. private _screenQuaternion;
  93558. private _alpha;
  93559. private _beta;
  93560. private _gamma;
  93561. /**
  93562. * Instantiates a new input
  93563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93564. */
  93565. constructor();
  93566. /**
  93567. * Define the camera controlled by the input.
  93568. */
  93569. camera: FreeCamera;
  93570. /**
  93571. * Attach the input controls to a specific dom element to get the input from.
  93572. * @param element Defines the element the controls should be listened from
  93573. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93574. */
  93575. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93576. private _orientationChanged;
  93577. private _deviceOrientation;
  93578. /**
  93579. * Detach the current controls from the specified dom element.
  93580. * @param element Defines the element to stop listening the inputs from
  93581. */
  93582. detachControl(element: Nullable<HTMLElement>): void;
  93583. /**
  93584. * Update the current camera state depending on the inputs that have been used this frame.
  93585. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93586. */
  93587. checkInputs(): void;
  93588. /**
  93589. * Gets the class name of the current intput.
  93590. * @returns the class name
  93591. */
  93592. getClassName(): string;
  93593. /**
  93594. * Get the friendly name associated with the input class.
  93595. * @returns the input friendly name
  93596. */
  93597. getSimpleName(): string;
  93598. }
  93599. }
  93600. declare module BABYLON {
  93601. /**
  93602. * Manage the gamepad inputs to control a free camera.
  93603. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93604. */
  93605. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  93606. /**
  93607. * Define the camera the input is attached to.
  93608. */
  93609. camera: FreeCamera;
  93610. /**
  93611. * Define the Gamepad controlling the input
  93612. */
  93613. gamepad: Nullable<Gamepad>;
  93614. /**
  93615. * Defines the gamepad rotation sensiblity.
  93616. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93617. */
  93618. gamepadAngularSensibility: number;
  93619. /**
  93620. * Defines the gamepad move sensiblity.
  93621. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93622. */
  93623. gamepadMoveSensibility: number;
  93624. private _onGamepadConnectedObserver;
  93625. private _onGamepadDisconnectedObserver;
  93626. private _cameraTransform;
  93627. private _deltaTransform;
  93628. private _vector3;
  93629. private _vector2;
  93630. /**
  93631. * Attach the input controls to a specific dom element to get the input from.
  93632. * @param element Defines the element the controls should be listened from
  93633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93634. */
  93635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93636. /**
  93637. * Detach the current controls from the specified dom element.
  93638. * @param element Defines the element to stop listening the inputs from
  93639. */
  93640. detachControl(element: Nullable<HTMLElement>): void;
  93641. /**
  93642. * Update the current camera state depending on the inputs that have been used this frame.
  93643. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93644. */
  93645. checkInputs(): void;
  93646. /**
  93647. * Gets the class name of the current intput.
  93648. * @returns the class name
  93649. */
  93650. getClassName(): string;
  93651. /**
  93652. * Get the friendly name associated with the input class.
  93653. * @returns the input friendly name
  93654. */
  93655. getSimpleName(): string;
  93656. }
  93657. }
  93658. declare module BABYLON {
  93659. /**
  93660. * Defines the potential axis of a Joystick
  93661. */
  93662. export enum JoystickAxis {
  93663. /** X axis */
  93664. X = 0,
  93665. /** Y axis */
  93666. Y = 1,
  93667. /** Z axis */
  93668. Z = 2
  93669. }
  93670. /**
  93671. * Class used to define virtual joystick (used in touch mode)
  93672. */
  93673. export class VirtualJoystick {
  93674. /**
  93675. * Gets or sets a boolean indicating that left and right values must be inverted
  93676. */
  93677. reverseLeftRight: boolean;
  93678. /**
  93679. * Gets or sets a boolean indicating that up and down values must be inverted
  93680. */
  93681. reverseUpDown: boolean;
  93682. /**
  93683. * Gets the offset value for the position (ie. the change of the position value)
  93684. */
  93685. deltaPosition: Vector3;
  93686. /**
  93687. * Gets a boolean indicating if the virtual joystick was pressed
  93688. */
  93689. pressed: boolean;
  93690. /**
  93691. * Canvas the virtual joystick will render onto, default z-index of this is 5
  93692. */
  93693. static Canvas: Nullable<HTMLCanvasElement>;
  93694. private static _globalJoystickIndex;
  93695. private static vjCanvasContext;
  93696. private static vjCanvasWidth;
  93697. private static vjCanvasHeight;
  93698. private static halfWidth;
  93699. private _action;
  93700. private _axisTargetedByLeftAndRight;
  93701. private _axisTargetedByUpAndDown;
  93702. private _joystickSensibility;
  93703. private _inversedSensibility;
  93704. private _joystickPointerID;
  93705. private _joystickColor;
  93706. private _joystickPointerPos;
  93707. private _joystickPreviousPointerPos;
  93708. private _joystickPointerStartPos;
  93709. private _deltaJoystickVector;
  93710. private _leftJoystick;
  93711. private _touches;
  93712. private _onPointerDownHandlerRef;
  93713. private _onPointerMoveHandlerRef;
  93714. private _onPointerUpHandlerRef;
  93715. private _onResize;
  93716. /**
  93717. * Creates a new virtual joystick
  93718. * @param leftJoystick defines that the joystick is for left hand (false by default)
  93719. */
  93720. constructor(leftJoystick?: boolean);
  93721. /**
  93722. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  93723. * @param newJoystickSensibility defines the new sensibility
  93724. */
  93725. setJoystickSensibility(newJoystickSensibility: number): void;
  93726. private _onPointerDown;
  93727. private _onPointerMove;
  93728. private _onPointerUp;
  93729. /**
  93730. * Change the color of the virtual joystick
  93731. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  93732. */
  93733. setJoystickColor(newColor: string): void;
  93734. /**
  93735. * Defines a callback to call when the joystick is touched
  93736. * @param action defines the callback
  93737. */
  93738. setActionOnTouch(action: () => any): void;
  93739. /**
  93740. * Defines which axis you'd like to control for left & right
  93741. * @param axis defines the axis to use
  93742. */
  93743. setAxisForLeftRight(axis: JoystickAxis): void;
  93744. /**
  93745. * Defines which axis you'd like to control for up & down
  93746. * @param axis defines the axis to use
  93747. */
  93748. setAxisForUpDown(axis: JoystickAxis): void;
  93749. private _drawVirtualJoystick;
  93750. /**
  93751. * Release internal HTML canvas
  93752. */
  93753. releaseCanvas(): void;
  93754. }
  93755. }
  93756. declare module BABYLON {
  93757. interface FreeCameraInputsManager {
  93758. /**
  93759. * Add virtual joystick input support to the input manager.
  93760. * @returns the current input manager
  93761. */
  93762. addVirtualJoystick(): FreeCameraInputsManager;
  93763. }
  93764. /**
  93765. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  93766. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93767. */
  93768. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  93769. /**
  93770. * Defines the camera the input is attached to.
  93771. */
  93772. camera: FreeCamera;
  93773. private _leftjoystick;
  93774. private _rightjoystick;
  93775. /**
  93776. * Gets the left stick of the virtual joystick.
  93777. * @returns The virtual Joystick
  93778. */
  93779. getLeftJoystick(): VirtualJoystick;
  93780. /**
  93781. * Gets the right stick of the virtual joystick.
  93782. * @returns The virtual Joystick
  93783. */
  93784. getRightJoystick(): VirtualJoystick;
  93785. /**
  93786. * Update the current camera state depending on the inputs that have been used this frame.
  93787. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93788. */
  93789. checkInputs(): void;
  93790. /**
  93791. * Attach the input controls to a specific dom element to get the input from.
  93792. * @param element Defines the element the controls should be listened from
  93793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93794. */
  93795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93796. /**
  93797. * Detach the current controls from the specified dom element.
  93798. * @param element Defines the element to stop listening the inputs from
  93799. */
  93800. detachControl(element: Nullable<HTMLElement>): void;
  93801. /**
  93802. * Gets the class name of the current intput.
  93803. * @returns the class name
  93804. */
  93805. getClassName(): string;
  93806. /**
  93807. * Get the friendly name associated with the input class.
  93808. * @returns the input friendly name
  93809. */
  93810. getSimpleName(): string;
  93811. }
  93812. }
  93813. declare module BABYLON {
  93814. /**
  93815. * This represents a FPS type of camera controlled by touch.
  93816. * This is like a universal camera minus the Gamepad controls.
  93817. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93818. */
  93819. export class TouchCamera extends FreeCamera {
  93820. /**
  93821. * Defines the touch sensibility for rotation.
  93822. * The higher the faster.
  93823. */
  93824. touchAngularSensibility: number;
  93825. /**
  93826. * Defines the touch sensibility for move.
  93827. * The higher the faster.
  93828. */
  93829. touchMoveSensibility: number;
  93830. /**
  93831. * Instantiates a new touch camera.
  93832. * This represents a FPS type of camera controlled by touch.
  93833. * This is like a universal camera minus the Gamepad controls.
  93834. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93835. * @param name Define the name of the camera in the scene
  93836. * @param position Define the start position of the camera in the scene
  93837. * @param scene Define the scene the camera belongs to
  93838. */
  93839. constructor(name: string, position: Vector3, scene: Scene);
  93840. /**
  93841. * Gets the current object class name.
  93842. * @return the class name
  93843. */
  93844. getClassName(): string;
  93845. /** @hidden */
  93846. _setupInputs(): void;
  93847. }
  93848. }
  93849. declare module BABYLON {
  93850. /**
  93851. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  93852. * being tilted forward or back and left or right.
  93853. */
  93854. export class DeviceOrientationCamera extends FreeCamera {
  93855. private _initialQuaternion;
  93856. private _quaternionCache;
  93857. /**
  93858. * Creates a new device orientation camera
  93859. * @param name The name of the camera
  93860. * @param position The start position camera
  93861. * @param scene The scene the camera belongs to
  93862. */
  93863. constructor(name: string, position: Vector3, scene: Scene);
  93864. /**
  93865. * Gets the current instance class name ("DeviceOrientationCamera").
  93866. * This helps avoiding instanceof at run time.
  93867. * @returns the class name
  93868. */
  93869. getClassName(): string;
  93870. /**
  93871. * @hidden
  93872. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  93873. */
  93874. _checkInputs(): void;
  93875. /**
  93876. * Reset the camera to its default orientation on the specified axis only.
  93877. * @param axis The axis to reset
  93878. */
  93879. resetToCurrentRotation(axis?: Axis): void;
  93880. }
  93881. }
  93882. declare module BABYLON {
  93883. /**
  93884. * 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,
  93885. * which still works and will still be found in many Playgrounds.
  93886. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93887. */
  93888. export class UniversalCamera extends TouchCamera {
  93889. /**
  93890. * Defines the gamepad rotation sensiblity.
  93891. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93892. */
  93893. gamepadAngularSensibility: number;
  93894. /**
  93895. * Defines the gamepad move sensiblity.
  93896. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93897. */
  93898. gamepadMoveSensibility: number;
  93899. /**
  93900. * 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,
  93901. * which still works and will still be found in many Playgrounds.
  93902. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93903. * @param name Define the name of the camera in the scene
  93904. * @param position Define the start position of the camera in the scene
  93905. * @param scene Define the scene the camera belongs to
  93906. */
  93907. constructor(name: string, position: Vector3, scene: Scene);
  93908. /**
  93909. * Gets the current object class name.
  93910. * @return the class name
  93911. */
  93912. getClassName(): string;
  93913. }
  93914. }
  93915. declare module BABYLON {
  93916. /**
  93917. * This represents a FPS type of camera. This is only here for back compat purpose.
  93918. * Please use the UniversalCamera instead as both are identical.
  93919. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93920. */
  93921. export class GamepadCamera extends UniversalCamera {
  93922. /**
  93923. * Instantiates a new Gamepad Camera
  93924. * This represents a FPS type of camera. This is only here for back compat purpose.
  93925. * Please use the UniversalCamera instead as both are identical.
  93926. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93927. * @param name Define the name of the camera in the scene
  93928. * @param position Define the start position of the camera in the scene
  93929. * @param scene Define the scene the camera belongs to
  93930. */
  93931. constructor(name: string, position: Vector3, scene: Scene);
  93932. /**
  93933. * Gets the current object class name.
  93934. * @return the class name
  93935. */
  93936. getClassName(): string;
  93937. }
  93938. }
  93939. declare module BABYLON {
  93940. /** @hidden */
  93941. export var passPixelShader: {
  93942. name: string;
  93943. shader: string;
  93944. };
  93945. }
  93946. declare module BABYLON {
  93947. /** @hidden */
  93948. export var passCubePixelShader: {
  93949. name: string;
  93950. shader: string;
  93951. };
  93952. }
  93953. declare module BABYLON {
  93954. /**
  93955. * PassPostProcess which produces an output the same as it's input
  93956. */
  93957. export class PassPostProcess extends PostProcess {
  93958. /**
  93959. * Creates the PassPostProcess
  93960. * @param name The name of the effect.
  93961. * @param options The required width/height ratio to downsize to before computing the render pass.
  93962. * @param camera The camera to apply the render pass to.
  93963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93964. * @param engine The engine which the post process will be applied. (default: current engine)
  93965. * @param reusable If the post process can be reused on the same frame. (default: false)
  93966. * @param textureType The type of texture to be used when performing the post processing.
  93967. * @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)
  93968. */
  93969. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  93970. }
  93971. /**
  93972. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  93973. */
  93974. export class PassCubePostProcess extends PostProcess {
  93975. private _face;
  93976. /**
  93977. * Gets or sets the cube face to display.
  93978. * * 0 is +X
  93979. * * 1 is -X
  93980. * * 2 is +Y
  93981. * * 3 is -Y
  93982. * * 4 is +Z
  93983. * * 5 is -Z
  93984. */
  93985. face: number;
  93986. /**
  93987. * Creates the PassCubePostProcess
  93988. * @param name The name of the effect.
  93989. * @param options The required width/height ratio to downsize to before computing the render pass.
  93990. * @param camera The camera to apply the render pass to.
  93991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93992. * @param engine The engine which the post process will be applied. (default: current engine)
  93993. * @param reusable If the post process can be reused on the same frame. (default: false)
  93994. * @param textureType The type of texture to be used when performing the post processing.
  93995. * @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)
  93996. */
  93997. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  93998. }
  93999. }
  94000. declare module BABYLON {
  94001. /** @hidden */
  94002. export var anaglyphPixelShader: {
  94003. name: string;
  94004. shader: string;
  94005. };
  94006. }
  94007. declare module BABYLON {
  94008. /**
  94009. * Postprocess used to generate anaglyphic rendering
  94010. */
  94011. export class AnaglyphPostProcess extends PostProcess {
  94012. private _passedProcess;
  94013. /**
  94014. * Creates a new AnaglyphPostProcess
  94015. * @param name defines postprocess name
  94016. * @param options defines creation options or target ratio scale
  94017. * @param rigCameras defines cameras using this postprocess
  94018. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  94019. * @param engine defines hosting engine
  94020. * @param reusable defines if the postprocess will be reused multiple times per frame
  94021. */
  94022. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  94023. }
  94024. }
  94025. declare module BABYLON {
  94026. /**
  94027. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  94028. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94029. */
  94030. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  94031. /**
  94032. * Creates a new AnaglyphArcRotateCamera
  94033. * @param name defines camera name
  94034. * @param alpha defines alpha angle (in radians)
  94035. * @param beta defines beta angle (in radians)
  94036. * @param radius defines radius
  94037. * @param target defines camera target
  94038. * @param interaxialDistance defines distance between each color axis
  94039. * @param scene defines the hosting scene
  94040. */
  94041. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  94042. /**
  94043. * Gets camera class name
  94044. * @returns AnaglyphArcRotateCamera
  94045. */
  94046. getClassName(): string;
  94047. }
  94048. }
  94049. declare module BABYLON {
  94050. /**
  94051. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  94052. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94053. */
  94054. export class AnaglyphFreeCamera extends FreeCamera {
  94055. /**
  94056. * Creates a new AnaglyphFreeCamera
  94057. * @param name defines camera name
  94058. * @param position defines initial position
  94059. * @param interaxialDistance defines distance between each color axis
  94060. * @param scene defines the hosting scene
  94061. */
  94062. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94063. /**
  94064. * Gets camera class name
  94065. * @returns AnaglyphFreeCamera
  94066. */
  94067. getClassName(): string;
  94068. }
  94069. }
  94070. declare module BABYLON {
  94071. /**
  94072. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94073. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94074. */
  94075. export class AnaglyphGamepadCamera extends GamepadCamera {
  94076. /**
  94077. * Creates a new AnaglyphGamepadCamera
  94078. * @param name defines camera name
  94079. * @param position defines initial position
  94080. * @param interaxialDistance defines distance between each color axis
  94081. * @param scene defines the hosting scene
  94082. */
  94083. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94084. /**
  94085. * Gets camera class name
  94086. * @returns AnaglyphGamepadCamera
  94087. */
  94088. getClassName(): string;
  94089. }
  94090. }
  94091. declare module BABYLON {
  94092. /**
  94093. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94094. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94095. */
  94096. export class AnaglyphUniversalCamera extends UniversalCamera {
  94097. /**
  94098. * Creates a new AnaglyphUniversalCamera
  94099. * @param name defines camera name
  94100. * @param position defines initial position
  94101. * @param interaxialDistance defines distance between each color axis
  94102. * @param scene defines the hosting scene
  94103. */
  94104. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94105. /**
  94106. * Gets camera class name
  94107. * @returns AnaglyphUniversalCamera
  94108. */
  94109. getClassName(): string;
  94110. }
  94111. }
  94112. declare module BABYLON {
  94113. /** @hidden */
  94114. export var stereoscopicInterlacePixelShader: {
  94115. name: string;
  94116. shader: string;
  94117. };
  94118. }
  94119. declare module BABYLON {
  94120. /**
  94121. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94122. */
  94123. export class StereoscopicInterlacePostProcess extends PostProcess {
  94124. private _stepSize;
  94125. private _passedProcess;
  94126. /**
  94127. * Initializes a StereoscopicInterlacePostProcess
  94128. * @param name The name of the effect.
  94129. * @param rigCameras The rig cameras to be appled to the post process
  94130. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94131. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94132. * @param engine The engine which the post process will be applied. (default: current engine)
  94133. * @param reusable If the post process can be reused on the same frame. (default: false)
  94134. */
  94135. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94136. }
  94137. }
  94138. declare module BABYLON {
  94139. /**
  94140. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94141. * @see http://doc.babylonjs.com/features/cameras
  94142. */
  94143. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94144. /**
  94145. * Creates a new StereoscopicArcRotateCamera
  94146. * @param name defines camera name
  94147. * @param alpha defines alpha angle (in radians)
  94148. * @param beta defines beta angle (in radians)
  94149. * @param radius defines radius
  94150. * @param target defines camera target
  94151. * @param interaxialDistance defines distance between each color axis
  94152. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94153. * @param scene defines the hosting scene
  94154. */
  94155. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94156. /**
  94157. * Gets camera class name
  94158. * @returns StereoscopicArcRotateCamera
  94159. */
  94160. getClassName(): string;
  94161. }
  94162. }
  94163. declare module BABYLON {
  94164. /**
  94165. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94166. * @see http://doc.babylonjs.com/features/cameras
  94167. */
  94168. export class StereoscopicFreeCamera extends FreeCamera {
  94169. /**
  94170. * Creates a new StereoscopicFreeCamera
  94171. * @param name defines camera name
  94172. * @param position defines initial position
  94173. * @param interaxialDistance defines distance between each color axis
  94174. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94175. * @param scene defines the hosting scene
  94176. */
  94177. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94178. /**
  94179. * Gets camera class name
  94180. * @returns StereoscopicFreeCamera
  94181. */
  94182. getClassName(): string;
  94183. }
  94184. }
  94185. declare module BABYLON {
  94186. /**
  94187. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94188. * @see http://doc.babylonjs.com/features/cameras
  94189. */
  94190. export class StereoscopicGamepadCamera extends GamepadCamera {
  94191. /**
  94192. * Creates a new StereoscopicGamepadCamera
  94193. * @param name defines camera name
  94194. * @param position defines initial position
  94195. * @param interaxialDistance defines distance between each color axis
  94196. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94197. * @param scene defines the hosting scene
  94198. */
  94199. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94200. /**
  94201. * Gets camera class name
  94202. * @returns StereoscopicGamepadCamera
  94203. */
  94204. getClassName(): string;
  94205. }
  94206. }
  94207. declare module BABYLON {
  94208. /**
  94209. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94210. * @see http://doc.babylonjs.com/features/cameras
  94211. */
  94212. export class StereoscopicUniversalCamera extends UniversalCamera {
  94213. /**
  94214. * Creates a new StereoscopicUniversalCamera
  94215. * @param name defines camera name
  94216. * @param position defines initial position
  94217. * @param interaxialDistance defines distance between each color axis
  94218. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94219. * @param scene defines the hosting scene
  94220. */
  94221. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94222. /**
  94223. * Gets camera class name
  94224. * @returns StereoscopicUniversalCamera
  94225. */
  94226. getClassName(): string;
  94227. }
  94228. }
  94229. declare module BABYLON {
  94230. /**
  94231. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94232. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94233. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94234. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94235. */
  94236. export class VirtualJoysticksCamera extends FreeCamera {
  94237. /**
  94238. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94239. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94240. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94241. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94242. * @param name Define the name of the camera in the scene
  94243. * @param position Define the start position of the camera in the scene
  94244. * @param scene Define the scene the camera belongs to
  94245. */
  94246. constructor(name: string, position: Vector3, scene: Scene);
  94247. /**
  94248. * Gets the current object class name.
  94249. * @return the class name
  94250. */
  94251. getClassName(): string;
  94252. }
  94253. }
  94254. declare module BABYLON {
  94255. /**
  94256. * This represents all the required metrics to create a VR camera.
  94257. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94258. */
  94259. export class VRCameraMetrics {
  94260. /**
  94261. * Define the horizontal resolution off the screen.
  94262. */
  94263. hResolution: number;
  94264. /**
  94265. * Define the vertical resolution off the screen.
  94266. */
  94267. vResolution: number;
  94268. /**
  94269. * Define the horizontal screen size.
  94270. */
  94271. hScreenSize: number;
  94272. /**
  94273. * Define the vertical screen size.
  94274. */
  94275. vScreenSize: number;
  94276. /**
  94277. * Define the vertical screen center position.
  94278. */
  94279. vScreenCenter: number;
  94280. /**
  94281. * Define the distance of the eyes to the screen.
  94282. */
  94283. eyeToScreenDistance: number;
  94284. /**
  94285. * Define the distance between both lenses
  94286. */
  94287. lensSeparationDistance: number;
  94288. /**
  94289. * Define the distance between both viewer's eyes.
  94290. */
  94291. interpupillaryDistance: number;
  94292. /**
  94293. * Define the distortion factor of the VR postprocess.
  94294. * Please, touch with care.
  94295. */
  94296. distortionK: number[];
  94297. /**
  94298. * Define the chromatic aberration correction factors for the VR post process.
  94299. */
  94300. chromaAbCorrection: number[];
  94301. /**
  94302. * Define the scale factor of the post process.
  94303. * The smaller the better but the slower.
  94304. */
  94305. postProcessScaleFactor: number;
  94306. /**
  94307. * Define an offset for the lens center.
  94308. */
  94309. lensCenterOffset: number;
  94310. /**
  94311. * Define if the current vr camera should compensate the distortion of the lense or not.
  94312. */
  94313. compensateDistortion: boolean;
  94314. /**
  94315. * Gets the rendering aspect ratio based on the provided resolutions.
  94316. */
  94317. readonly aspectRatio: number;
  94318. /**
  94319. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94320. */
  94321. readonly aspectRatioFov: number;
  94322. /**
  94323. * @hidden
  94324. */
  94325. readonly leftHMatrix: Matrix;
  94326. /**
  94327. * @hidden
  94328. */
  94329. readonly rightHMatrix: Matrix;
  94330. /**
  94331. * @hidden
  94332. */
  94333. readonly leftPreViewMatrix: Matrix;
  94334. /**
  94335. * @hidden
  94336. */
  94337. readonly rightPreViewMatrix: Matrix;
  94338. /**
  94339. * Get the default VRMetrics based on the most generic setup.
  94340. * @returns the default vr metrics
  94341. */
  94342. static GetDefault(): VRCameraMetrics;
  94343. }
  94344. }
  94345. declare module BABYLON {
  94346. /** @hidden */
  94347. export var vrDistortionCorrectionPixelShader: {
  94348. name: string;
  94349. shader: string;
  94350. };
  94351. }
  94352. declare module BABYLON {
  94353. /**
  94354. * VRDistortionCorrectionPostProcess used for mobile VR
  94355. */
  94356. export class VRDistortionCorrectionPostProcess extends PostProcess {
  94357. private _isRightEye;
  94358. private _distortionFactors;
  94359. private _postProcessScaleFactor;
  94360. private _lensCenterOffset;
  94361. private _scaleIn;
  94362. private _scaleFactor;
  94363. private _lensCenter;
  94364. /**
  94365. * Initializes the VRDistortionCorrectionPostProcess
  94366. * @param name The name of the effect.
  94367. * @param camera The camera to apply the render pass to.
  94368. * @param isRightEye If this is for the right eye distortion
  94369. * @param vrMetrics All the required metrics for the VR camera
  94370. */
  94371. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  94372. }
  94373. }
  94374. declare module BABYLON {
  94375. /**
  94376. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  94377. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94378. */
  94379. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  94380. /**
  94381. * Creates a new VRDeviceOrientationArcRotateCamera
  94382. * @param name defines camera name
  94383. * @param alpha defines the camera rotation along the logitudinal axis
  94384. * @param beta defines the camera rotation along the latitudinal axis
  94385. * @param radius defines the camera distance from its target
  94386. * @param target defines the camera target
  94387. * @param scene defines the scene the camera belongs to
  94388. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94389. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94390. */
  94391. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94392. /**
  94393. * Gets camera class name
  94394. * @returns VRDeviceOrientationArcRotateCamera
  94395. */
  94396. getClassName(): string;
  94397. }
  94398. }
  94399. declare module BABYLON {
  94400. /**
  94401. * Camera used to simulate VR rendering (based on FreeCamera)
  94402. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94403. */
  94404. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  94405. /**
  94406. * Creates a new VRDeviceOrientationFreeCamera
  94407. * @param name defines camera name
  94408. * @param position defines the start position of the camera
  94409. * @param scene defines the scene the camera belongs to
  94410. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94411. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94412. */
  94413. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94414. /**
  94415. * Gets camera class name
  94416. * @returns VRDeviceOrientationFreeCamera
  94417. */
  94418. getClassName(): string;
  94419. }
  94420. }
  94421. declare module BABYLON {
  94422. /**
  94423. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  94424. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94425. */
  94426. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  94427. /**
  94428. * Creates a new VRDeviceOrientationGamepadCamera
  94429. * @param name defines camera name
  94430. * @param position defines the start position of the camera
  94431. * @param scene defines the scene the camera belongs to
  94432. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94433. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94434. */
  94435. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94436. /**
  94437. * Gets camera class name
  94438. * @returns VRDeviceOrientationGamepadCamera
  94439. */
  94440. getClassName(): string;
  94441. }
  94442. }
  94443. declare module BABYLON {
  94444. /**
  94445. * Defines supported buttons for XBox360 compatible gamepads
  94446. */
  94447. export enum Xbox360Button {
  94448. /** A */
  94449. A = 0,
  94450. /** B */
  94451. B = 1,
  94452. /** X */
  94453. X = 2,
  94454. /** Y */
  94455. Y = 3,
  94456. /** Start */
  94457. Start = 4,
  94458. /** Back */
  94459. Back = 5,
  94460. /** Left button */
  94461. LB = 6,
  94462. /** Right button */
  94463. RB = 7,
  94464. /** Left stick */
  94465. LeftStick = 8,
  94466. /** Right stick */
  94467. RightStick = 9
  94468. }
  94469. /** Defines values for XBox360 DPad */
  94470. export enum Xbox360Dpad {
  94471. /** Up */
  94472. Up = 0,
  94473. /** Down */
  94474. Down = 1,
  94475. /** Left */
  94476. Left = 2,
  94477. /** Right */
  94478. Right = 3
  94479. }
  94480. /**
  94481. * Defines a XBox360 gamepad
  94482. */
  94483. export class Xbox360Pad extends Gamepad {
  94484. private _leftTrigger;
  94485. private _rightTrigger;
  94486. private _onlefttriggerchanged;
  94487. private _onrighttriggerchanged;
  94488. private _onbuttondown;
  94489. private _onbuttonup;
  94490. private _ondpaddown;
  94491. private _ondpadup;
  94492. /** Observable raised when a button is pressed */
  94493. onButtonDownObservable: Observable<Xbox360Button>;
  94494. /** Observable raised when a button is released */
  94495. onButtonUpObservable: Observable<Xbox360Button>;
  94496. /** Observable raised when a pad is pressed */
  94497. onPadDownObservable: Observable<Xbox360Dpad>;
  94498. /** Observable raised when a pad is released */
  94499. onPadUpObservable: Observable<Xbox360Dpad>;
  94500. private _buttonA;
  94501. private _buttonB;
  94502. private _buttonX;
  94503. private _buttonY;
  94504. private _buttonBack;
  94505. private _buttonStart;
  94506. private _buttonLB;
  94507. private _buttonRB;
  94508. private _buttonLeftStick;
  94509. private _buttonRightStick;
  94510. private _dPadUp;
  94511. private _dPadDown;
  94512. private _dPadLeft;
  94513. private _dPadRight;
  94514. private _isXboxOnePad;
  94515. /**
  94516. * Creates a new XBox360 gamepad object
  94517. * @param id defines the id of this gamepad
  94518. * @param index defines its index
  94519. * @param gamepad defines the internal HTML gamepad object
  94520. * @param xboxOne defines if it is a XBox One gamepad
  94521. */
  94522. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  94523. /**
  94524. * Defines the callback to call when left trigger is pressed
  94525. * @param callback defines the callback to use
  94526. */
  94527. onlefttriggerchanged(callback: (value: number) => void): void;
  94528. /**
  94529. * Defines the callback to call when right trigger is pressed
  94530. * @param callback defines the callback to use
  94531. */
  94532. onrighttriggerchanged(callback: (value: number) => void): void;
  94533. /**
  94534. * Gets the left trigger value
  94535. */
  94536. /**
  94537. * Sets the left trigger value
  94538. */
  94539. leftTrigger: number;
  94540. /**
  94541. * Gets the right trigger value
  94542. */
  94543. /**
  94544. * Sets the right trigger value
  94545. */
  94546. rightTrigger: number;
  94547. /**
  94548. * Defines the callback to call when a button is pressed
  94549. * @param callback defines the callback to use
  94550. */
  94551. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  94552. /**
  94553. * Defines the callback to call when a button is released
  94554. * @param callback defines the callback to use
  94555. */
  94556. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  94557. /**
  94558. * Defines the callback to call when a pad is pressed
  94559. * @param callback defines the callback to use
  94560. */
  94561. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  94562. /**
  94563. * Defines the callback to call when a pad is released
  94564. * @param callback defines the callback to use
  94565. */
  94566. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  94567. private _setButtonValue;
  94568. private _setDPadValue;
  94569. /**
  94570. * Gets the value of the `A` button
  94571. */
  94572. /**
  94573. * Sets the value of the `A` button
  94574. */
  94575. buttonA: number;
  94576. /**
  94577. * Gets the value of the `B` button
  94578. */
  94579. /**
  94580. * Sets the value of the `B` button
  94581. */
  94582. buttonB: number;
  94583. /**
  94584. * Gets the value of the `X` button
  94585. */
  94586. /**
  94587. * Sets the value of the `X` button
  94588. */
  94589. buttonX: number;
  94590. /**
  94591. * Gets the value of the `Y` button
  94592. */
  94593. /**
  94594. * Sets the value of the `Y` button
  94595. */
  94596. buttonY: number;
  94597. /**
  94598. * Gets the value of the `Start` button
  94599. */
  94600. /**
  94601. * Sets the value of the `Start` button
  94602. */
  94603. buttonStart: number;
  94604. /**
  94605. * Gets the value of the `Back` button
  94606. */
  94607. /**
  94608. * Sets the value of the `Back` button
  94609. */
  94610. buttonBack: number;
  94611. /**
  94612. * Gets the value of the `Left` button
  94613. */
  94614. /**
  94615. * Sets the value of the `Left` button
  94616. */
  94617. buttonLB: number;
  94618. /**
  94619. * Gets the value of the `Right` button
  94620. */
  94621. /**
  94622. * Sets the value of the `Right` button
  94623. */
  94624. buttonRB: number;
  94625. /**
  94626. * Gets the value of the Left joystick
  94627. */
  94628. /**
  94629. * Sets the value of the Left joystick
  94630. */
  94631. buttonLeftStick: number;
  94632. /**
  94633. * Gets the value of the Right joystick
  94634. */
  94635. /**
  94636. * Sets the value of the Right joystick
  94637. */
  94638. buttonRightStick: number;
  94639. /**
  94640. * Gets the value of D-pad up
  94641. */
  94642. /**
  94643. * Sets the value of D-pad up
  94644. */
  94645. dPadUp: number;
  94646. /**
  94647. * Gets the value of D-pad down
  94648. */
  94649. /**
  94650. * Sets the value of D-pad down
  94651. */
  94652. dPadDown: number;
  94653. /**
  94654. * Gets the value of D-pad left
  94655. */
  94656. /**
  94657. * Sets the value of D-pad left
  94658. */
  94659. dPadLeft: number;
  94660. /**
  94661. * Gets the value of D-pad right
  94662. */
  94663. /**
  94664. * Sets the value of D-pad right
  94665. */
  94666. dPadRight: number;
  94667. /**
  94668. * Force the gamepad to synchronize with device values
  94669. */
  94670. update(): void;
  94671. /**
  94672. * Disposes the gamepad
  94673. */
  94674. dispose(): void;
  94675. }
  94676. }
  94677. declare module BABYLON {
  94678. /**
  94679. * Base class of materials working in push mode in babylon JS
  94680. * @hidden
  94681. */
  94682. export class PushMaterial extends Material {
  94683. protected _activeEffect: Effect;
  94684. protected _normalMatrix: Matrix;
  94685. /**
  94686. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94687. * This means that the material can keep using a previous shader while a new one is being compiled.
  94688. * This is mostly used when shader parallel compilation is supported (true by default)
  94689. */
  94690. allowShaderHotSwapping: boolean;
  94691. constructor(name: string, scene: Scene);
  94692. getEffect(): Effect;
  94693. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94694. /**
  94695. * Binds the given world matrix to the active effect
  94696. *
  94697. * @param world the matrix to bind
  94698. */
  94699. bindOnlyWorldMatrix(world: Matrix): void;
  94700. /**
  94701. * Binds the given normal matrix to the active effect
  94702. *
  94703. * @param normalMatrix the matrix to bind
  94704. */
  94705. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94706. bind(world: Matrix, mesh?: Mesh): void;
  94707. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94708. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94709. }
  94710. }
  94711. declare module BABYLON {
  94712. /**
  94713. * This groups all the flags used to control the materials channel.
  94714. */
  94715. export class MaterialFlags {
  94716. private static _DiffuseTextureEnabled;
  94717. /**
  94718. * Are diffuse textures enabled in the application.
  94719. */
  94720. static DiffuseTextureEnabled: boolean;
  94721. private static _AmbientTextureEnabled;
  94722. /**
  94723. * Are ambient textures enabled in the application.
  94724. */
  94725. static AmbientTextureEnabled: boolean;
  94726. private static _OpacityTextureEnabled;
  94727. /**
  94728. * Are opacity textures enabled in the application.
  94729. */
  94730. static OpacityTextureEnabled: boolean;
  94731. private static _ReflectionTextureEnabled;
  94732. /**
  94733. * Are reflection textures enabled in the application.
  94734. */
  94735. static ReflectionTextureEnabled: boolean;
  94736. private static _EmissiveTextureEnabled;
  94737. /**
  94738. * Are emissive textures enabled in the application.
  94739. */
  94740. static EmissiveTextureEnabled: boolean;
  94741. private static _SpecularTextureEnabled;
  94742. /**
  94743. * Are specular textures enabled in the application.
  94744. */
  94745. static SpecularTextureEnabled: boolean;
  94746. private static _BumpTextureEnabled;
  94747. /**
  94748. * Are bump textures enabled in the application.
  94749. */
  94750. static BumpTextureEnabled: boolean;
  94751. private static _LightmapTextureEnabled;
  94752. /**
  94753. * Are lightmap textures enabled in the application.
  94754. */
  94755. static LightmapTextureEnabled: boolean;
  94756. private static _RefractionTextureEnabled;
  94757. /**
  94758. * Are refraction textures enabled in the application.
  94759. */
  94760. static RefractionTextureEnabled: boolean;
  94761. private static _ColorGradingTextureEnabled;
  94762. /**
  94763. * Are color grading textures enabled in the application.
  94764. */
  94765. static ColorGradingTextureEnabled: boolean;
  94766. private static _FresnelEnabled;
  94767. /**
  94768. * Are fresnels enabled in the application.
  94769. */
  94770. static FresnelEnabled: boolean;
  94771. private static _ClearCoatTextureEnabled;
  94772. /**
  94773. * Are clear coat textures enabled in the application.
  94774. */
  94775. static ClearCoatTextureEnabled: boolean;
  94776. private static _ClearCoatBumpTextureEnabled;
  94777. /**
  94778. * Are clear coat bump textures enabled in the application.
  94779. */
  94780. static ClearCoatBumpTextureEnabled: boolean;
  94781. private static _ClearCoatTintTextureEnabled;
  94782. /**
  94783. * Are clear coat tint textures enabled in the application.
  94784. */
  94785. static ClearCoatTintTextureEnabled: boolean;
  94786. }
  94787. }
  94788. declare module BABYLON {
  94789. /** @hidden */
  94790. export var defaultFragmentDeclaration: {
  94791. name: string;
  94792. shader: string;
  94793. };
  94794. }
  94795. declare module BABYLON {
  94796. /** @hidden */
  94797. export var defaultUboDeclaration: {
  94798. name: string;
  94799. shader: string;
  94800. };
  94801. }
  94802. declare module BABYLON {
  94803. /** @hidden */
  94804. export var lightFragmentDeclaration: {
  94805. name: string;
  94806. shader: string;
  94807. };
  94808. }
  94809. declare module BABYLON {
  94810. /** @hidden */
  94811. export var lightUboDeclaration: {
  94812. name: string;
  94813. shader: string;
  94814. };
  94815. }
  94816. declare module BABYLON {
  94817. /** @hidden */
  94818. export var lightsFragmentFunctions: {
  94819. name: string;
  94820. shader: string;
  94821. };
  94822. }
  94823. declare module BABYLON {
  94824. /** @hidden */
  94825. export var shadowsFragmentFunctions: {
  94826. name: string;
  94827. shader: string;
  94828. };
  94829. }
  94830. declare module BABYLON {
  94831. /** @hidden */
  94832. export var fresnelFunction: {
  94833. name: string;
  94834. shader: string;
  94835. };
  94836. }
  94837. declare module BABYLON {
  94838. /** @hidden */
  94839. export var reflectionFunction: {
  94840. name: string;
  94841. shader: string;
  94842. };
  94843. }
  94844. declare module BABYLON {
  94845. /** @hidden */
  94846. export var bumpFragmentFunctions: {
  94847. name: string;
  94848. shader: string;
  94849. };
  94850. }
  94851. declare module BABYLON {
  94852. /** @hidden */
  94853. export var logDepthDeclaration: {
  94854. name: string;
  94855. shader: string;
  94856. };
  94857. }
  94858. declare module BABYLON {
  94859. /** @hidden */
  94860. export var bumpFragment: {
  94861. name: string;
  94862. shader: string;
  94863. };
  94864. }
  94865. declare module BABYLON {
  94866. /** @hidden */
  94867. export var depthPrePass: {
  94868. name: string;
  94869. shader: string;
  94870. };
  94871. }
  94872. declare module BABYLON {
  94873. /** @hidden */
  94874. export var lightFragment: {
  94875. name: string;
  94876. shader: string;
  94877. };
  94878. }
  94879. declare module BABYLON {
  94880. /** @hidden */
  94881. export var logDepthFragment: {
  94882. name: string;
  94883. shader: string;
  94884. };
  94885. }
  94886. declare module BABYLON {
  94887. /** @hidden */
  94888. export var defaultPixelShader: {
  94889. name: string;
  94890. shader: string;
  94891. };
  94892. }
  94893. declare module BABYLON {
  94894. /** @hidden */
  94895. export var defaultVertexDeclaration: {
  94896. name: string;
  94897. shader: string;
  94898. };
  94899. }
  94900. declare module BABYLON {
  94901. /** @hidden */
  94902. export var bumpVertexDeclaration: {
  94903. name: string;
  94904. shader: string;
  94905. };
  94906. }
  94907. declare module BABYLON {
  94908. /** @hidden */
  94909. export var bumpVertex: {
  94910. name: string;
  94911. shader: string;
  94912. };
  94913. }
  94914. declare module BABYLON {
  94915. /** @hidden */
  94916. export var fogVertex: {
  94917. name: string;
  94918. shader: string;
  94919. };
  94920. }
  94921. declare module BABYLON {
  94922. /** @hidden */
  94923. export var shadowsVertex: {
  94924. name: string;
  94925. shader: string;
  94926. };
  94927. }
  94928. declare module BABYLON {
  94929. /** @hidden */
  94930. export var pointCloudVertex: {
  94931. name: string;
  94932. shader: string;
  94933. };
  94934. }
  94935. declare module BABYLON {
  94936. /** @hidden */
  94937. export var logDepthVertex: {
  94938. name: string;
  94939. shader: string;
  94940. };
  94941. }
  94942. declare module BABYLON {
  94943. /** @hidden */
  94944. export var defaultVertexShader: {
  94945. name: string;
  94946. shader: string;
  94947. };
  94948. }
  94949. declare module BABYLON {
  94950. /** @hidden */
  94951. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  94952. MAINUV1: boolean;
  94953. MAINUV2: boolean;
  94954. DIFFUSE: boolean;
  94955. DIFFUSEDIRECTUV: number;
  94956. AMBIENT: boolean;
  94957. AMBIENTDIRECTUV: number;
  94958. OPACITY: boolean;
  94959. OPACITYDIRECTUV: number;
  94960. OPACITYRGB: boolean;
  94961. REFLECTION: boolean;
  94962. EMISSIVE: boolean;
  94963. EMISSIVEDIRECTUV: number;
  94964. SPECULAR: boolean;
  94965. SPECULARDIRECTUV: number;
  94966. BUMP: boolean;
  94967. BUMPDIRECTUV: number;
  94968. PARALLAX: boolean;
  94969. PARALLAXOCCLUSION: boolean;
  94970. SPECULAROVERALPHA: boolean;
  94971. CLIPPLANE: boolean;
  94972. CLIPPLANE2: boolean;
  94973. CLIPPLANE3: boolean;
  94974. CLIPPLANE4: boolean;
  94975. ALPHATEST: boolean;
  94976. DEPTHPREPASS: boolean;
  94977. ALPHAFROMDIFFUSE: boolean;
  94978. POINTSIZE: boolean;
  94979. FOG: boolean;
  94980. SPECULARTERM: boolean;
  94981. DIFFUSEFRESNEL: boolean;
  94982. OPACITYFRESNEL: boolean;
  94983. REFLECTIONFRESNEL: boolean;
  94984. REFRACTIONFRESNEL: boolean;
  94985. EMISSIVEFRESNEL: boolean;
  94986. FRESNEL: boolean;
  94987. NORMAL: boolean;
  94988. UV1: boolean;
  94989. UV2: boolean;
  94990. VERTEXCOLOR: boolean;
  94991. VERTEXALPHA: boolean;
  94992. NUM_BONE_INFLUENCERS: number;
  94993. BonesPerMesh: number;
  94994. BONETEXTURE: boolean;
  94995. INSTANCES: boolean;
  94996. GLOSSINESS: boolean;
  94997. ROUGHNESS: boolean;
  94998. EMISSIVEASILLUMINATION: boolean;
  94999. LINKEMISSIVEWITHDIFFUSE: boolean;
  95000. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95001. LIGHTMAP: boolean;
  95002. LIGHTMAPDIRECTUV: number;
  95003. OBJECTSPACE_NORMALMAP: boolean;
  95004. USELIGHTMAPASSHADOWMAP: boolean;
  95005. REFLECTIONMAP_3D: boolean;
  95006. REFLECTIONMAP_SPHERICAL: boolean;
  95007. REFLECTIONMAP_PLANAR: boolean;
  95008. REFLECTIONMAP_CUBIC: boolean;
  95009. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95010. REFLECTIONMAP_PROJECTION: boolean;
  95011. REFLECTIONMAP_SKYBOX: boolean;
  95012. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95013. REFLECTIONMAP_EXPLICIT: boolean;
  95014. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95015. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95016. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95017. INVERTCUBICMAP: boolean;
  95018. LOGARITHMICDEPTH: boolean;
  95019. REFRACTION: boolean;
  95020. REFRACTIONMAP_3D: boolean;
  95021. REFLECTIONOVERALPHA: boolean;
  95022. TWOSIDEDLIGHTING: boolean;
  95023. SHADOWFLOAT: boolean;
  95024. MORPHTARGETS: boolean;
  95025. MORPHTARGETS_NORMAL: boolean;
  95026. MORPHTARGETS_TANGENT: boolean;
  95027. NUM_MORPH_INFLUENCERS: number;
  95028. NONUNIFORMSCALING: boolean;
  95029. PREMULTIPLYALPHA: boolean;
  95030. IMAGEPROCESSING: boolean;
  95031. VIGNETTE: boolean;
  95032. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95033. VIGNETTEBLENDMODEOPAQUE: boolean;
  95034. TONEMAPPING: boolean;
  95035. TONEMAPPING_ACES: boolean;
  95036. CONTRAST: boolean;
  95037. COLORCURVES: boolean;
  95038. COLORGRADING: boolean;
  95039. COLORGRADING3D: boolean;
  95040. SAMPLER3DGREENDEPTH: boolean;
  95041. SAMPLER3DBGRMAP: boolean;
  95042. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95043. /**
  95044. * If the reflection texture on this material is in linear color space
  95045. * @hidden
  95046. */
  95047. IS_REFLECTION_LINEAR: boolean;
  95048. /**
  95049. * If the refraction texture on this material is in linear color space
  95050. * @hidden
  95051. */
  95052. IS_REFRACTION_LINEAR: boolean;
  95053. EXPOSURE: boolean;
  95054. constructor();
  95055. setReflectionMode(modeToEnable: string): void;
  95056. }
  95057. /**
  95058. * This is the default material used in Babylon. It is the best trade off between quality
  95059. * and performances.
  95060. * @see http://doc.babylonjs.com/babylon101/materials
  95061. */
  95062. export class StandardMaterial extends PushMaterial {
  95063. private _diffuseTexture;
  95064. /**
  95065. * The basic texture of the material as viewed under a light.
  95066. */
  95067. diffuseTexture: Nullable<BaseTexture>;
  95068. private _ambientTexture;
  95069. /**
  95070. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95071. */
  95072. ambientTexture: Nullable<BaseTexture>;
  95073. private _opacityTexture;
  95074. /**
  95075. * Define the transparency of the material from a texture.
  95076. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95077. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95078. */
  95079. opacityTexture: Nullable<BaseTexture>;
  95080. private _reflectionTexture;
  95081. /**
  95082. * Define the texture used to display the reflection.
  95083. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95084. */
  95085. reflectionTexture: Nullable<BaseTexture>;
  95086. private _emissiveTexture;
  95087. /**
  95088. * Define texture of the material as if self lit.
  95089. * This will be mixed in the final result even in the absence of light.
  95090. */
  95091. emissiveTexture: Nullable<BaseTexture>;
  95092. private _specularTexture;
  95093. /**
  95094. * Define how the color and intensity of the highlight given by the light in the material.
  95095. */
  95096. specularTexture: Nullable<BaseTexture>;
  95097. private _bumpTexture;
  95098. /**
  95099. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95100. * 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.
  95101. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95102. */
  95103. bumpTexture: Nullable<BaseTexture>;
  95104. private _lightmapTexture;
  95105. /**
  95106. * Complex lighting can be computationally expensive to compute at runtime.
  95107. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95108. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95109. */
  95110. lightmapTexture: Nullable<BaseTexture>;
  95111. private _refractionTexture;
  95112. /**
  95113. * Define the texture used to display the refraction.
  95114. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95115. */
  95116. refractionTexture: Nullable<BaseTexture>;
  95117. /**
  95118. * The color of the material lit by the environmental background lighting.
  95119. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95120. */
  95121. ambientColor: Color3;
  95122. /**
  95123. * The basic color of the material as viewed under a light.
  95124. */
  95125. diffuseColor: Color3;
  95126. /**
  95127. * Define how the color and intensity of the highlight given by the light in the material.
  95128. */
  95129. specularColor: Color3;
  95130. /**
  95131. * Define the color of the material as if self lit.
  95132. * This will be mixed in the final result even in the absence of light.
  95133. */
  95134. emissiveColor: Color3;
  95135. /**
  95136. * Defines how sharp are the highlights in the material.
  95137. * The bigger the value the sharper giving a more glossy feeling to the result.
  95138. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95139. */
  95140. specularPower: number;
  95141. private _useAlphaFromDiffuseTexture;
  95142. /**
  95143. * Does the transparency come from the diffuse texture alpha channel.
  95144. */
  95145. useAlphaFromDiffuseTexture: boolean;
  95146. private _useEmissiveAsIllumination;
  95147. /**
  95148. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95149. */
  95150. useEmissiveAsIllumination: boolean;
  95151. private _linkEmissiveWithDiffuse;
  95152. /**
  95153. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95154. * the emissive level when the final color is close to one.
  95155. */
  95156. linkEmissiveWithDiffuse: boolean;
  95157. private _useSpecularOverAlpha;
  95158. /**
  95159. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95160. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95161. */
  95162. useSpecularOverAlpha: boolean;
  95163. private _useReflectionOverAlpha;
  95164. /**
  95165. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95166. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95167. */
  95168. useReflectionOverAlpha: boolean;
  95169. private _disableLighting;
  95170. /**
  95171. * Does lights from the scene impacts this material.
  95172. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95173. */
  95174. disableLighting: boolean;
  95175. private _useObjectSpaceNormalMap;
  95176. /**
  95177. * Allows using an object space normal map (instead of tangent space).
  95178. */
  95179. useObjectSpaceNormalMap: boolean;
  95180. private _useParallax;
  95181. /**
  95182. * Is parallax enabled or not.
  95183. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95184. */
  95185. useParallax: boolean;
  95186. private _useParallaxOcclusion;
  95187. /**
  95188. * Is parallax occlusion enabled or not.
  95189. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95190. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95191. */
  95192. useParallaxOcclusion: boolean;
  95193. /**
  95194. * 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.
  95195. */
  95196. parallaxScaleBias: number;
  95197. private _roughness;
  95198. /**
  95199. * Helps to define how blurry the reflections should appears in the material.
  95200. */
  95201. roughness: number;
  95202. /**
  95203. * In case of refraction, define the value of the indice of refraction.
  95204. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95205. */
  95206. indexOfRefraction: number;
  95207. /**
  95208. * Invert the refraction texture alongside the y axis.
  95209. * It can be useful with procedural textures or probe for instance.
  95210. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95211. */
  95212. invertRefractionY: boolean;
  95213. /**
  95214. * Defines the alpha limits in alpha test mode.
  95215. */
  95216. alphaCutOff: number;
  95217. private _useLightmapAsShadowmap;
  95218. /**
  95219. * In case of light mapping, define whether the map contains light or shadow informations.
  95220. */
  95221. useLightmapAsShadowmap: boolean;
  95222. private _diffuseFresnelParameters;
  95223. /**
  95224. * Define the diffuse fresnel parameters of the material.
  95225. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95226. */
  95227. diffuseFresnelParameters: FresnelParameters;
  95228. private _opacityFresnelParameters;
  95229. /**
  95230. * Define the opacity fresnel parameters of the material.
  95231. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95232. */
  95233. opacityFresnelParameters: FresnelParameters;
  95234. private _reflectionFresnelParameters;
  95235. /**
  95236. * Define the reflection fresnel parameters of the material.
  95237. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95238. */
  95239. reflectionFresnelParameters: FresnelParameters;
  95240. private _refractionFresnelParameters;
  95241. /**
  95242. * Define the refraction fresnel parameters of the material.
  95243. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95244. */
  95245. refractionFresnelParameters: FresnelParameters;
  95246. private _emissiveFresnelParameters;
  95247. /**
  95248. * Define the emissive fresnel parameters of the material.
  95249. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95250. */
  95251. emissiveFresnelParameters: FresnelParameters;
  95252. private _useReflectionFresnelFromSpecular;
  95253. /**
  95254. * If true automatically deducts the fresnels values from the material specularity.
  95255. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95256. */
  95257. useReflectionFresnelFromSpecular: boolean;
  95258. private _useGlossinessFromSpecularMapAlpha;
  95259. /**
  95260. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95261. */
  95262. useGlossinessFromSpecularMapAlpha: boolean;
  95263. private _maxSimultaneousLights;
  95264. /**
  95265. * Defines the maximum number of lights that can be used in the material
  95266. */
  95267. maxSimultaneousLights: number;
  95268. private _invertNormalMapX;
  95269. /**
  95270. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95271. */
  95272. invertNormalMapX: boolean;
  95273. private _invertNormalMapY;
  95274. /**
  95275. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95276. */
  95277. invertNormalMapY: boolean;
  95278. private _twoSidedLighting;
  95279. /**
  95280. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95281. */
  95282. twoSidedLighting: boolean;
  95283. /**
  95284. * Default configuration related to image processing available in the standard Material.
  95285. */
  95286. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95287. /**
  95288. * Gets the image processing configuration used either in this material.
  95289. */
  95290. /**
  95291. * Sets the Default image processing configuration used either in the this material.
  95292. *
  95293. * If sets to null, the scene one is in use.
  95294. */
  95295. imageProcessingConfiguration: ImageProcessingConfiguration;
  95296. /**
  95297. * Keep track of the image processing observer to allow dispose and replace.
  95298. */
  95299. private _imageProcessingObserver;
  95300. /**
  95301. * Attaches a new image processing configuration to the Standard Material.
  95302. * @param configuration
  95303. */
  95304. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95305. /**
  95306. * Gets wether the color curves effect is enabled.
  95307. */
  95308. /**
  95309. * Sets wether the color curves effect is enabled.
  95310. */
  95311. cameraColorCurvesEnabled: boolean;
  95312. /**
  95313. * Gets wether the color grading effect is enabled.
  95314. */
  95315. /**
  95316. * Gets wether the color grading effect is enabled.
  95317. */
  95318. cameraColorGradingEnabled: boolean;
  95319. /**
  95320. * Gets wether tonemapping is enabled or not.
  95321. */
  95322. /**
  95323. * Sets wether tonemapping is enabled or not
  95324. */
  95325. cameraToneMappingEnabled: boolean;
  95326. /**
  95327. * The camera exposure used on this material.
  95328. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95329. * This corresponds to a photographic exposure.
  95330. */
  95331. /**
  95332. * The camera exposure used on this material.
  95333. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95334. * This corresponds to a photographic exposure.
  95335. */
  95336. cameraExposure: number;
  95337. /**
  95338. * Gets The camera contrast used on this material.
  95339. */
  95340. /**
  95341. * Sets The camera contrast used on this material.
  95342. */
  95343. cameraContrast: number;
  95344. /**
  95345. * Gets the Color Grading 2D Lookup Texture.
  95346. */
  95347. /**
  95348. * Sets the Color Grading 2D Lookup Texture.
  95349. */
  95350. cameraColorGradingTexture: Nullable<BaseTexture>;
  95351. /**
  95352. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95353. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95354. * 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;
  95355. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95356. */
  95357. /**
  95358. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95359. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95360. * 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;
  95361. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95362. */
  95363. cameraColorCurves: Nullable<ColorCurves>;
  95364. /**
  95365. * Custom callback helping to override the default shader used in the material.
  95366. */
  95367. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95368. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95369. protected _worldViewProjectionMatrix: Matrix;
  95370. protected _globalAmbientColor: Color3;
  95371. protected _useLogarithmicDepth: boolean;
  95372. /**
  95373. * Instantiates a new standard material.
  95374. * This is the default material used in Babylon. It is the best trade off between quality
  95375. * and performances.
  95376. * @see http://doc.babylonjs.com/babylon101/materials
  95377. * @param name Define the name of the material in the scene
  95378. * @param scene Define the scene the material belong to
  95379. */
  95380. constructor(name: string, scene: Scene);
  95381. /**
  95382. * Gets a boolean indicating that current material needs to register RTT
  95383. */
  95384. readonly hasRenderTargetTextures: boolean;
  95385. /**
  95386. * Gets the current class name of the material e.g. "StandardMaterial"
  95387. * Mainly use in serialization.
  95388. * @returns the class name
  95389. */
  95390. getClassName(): string;
  95391. /**
  95392. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95393. * You can try switching to logarithmic depth.
  95394. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95395. */
  95396. useLogarithmicDepth: boolean;
  95397. /**
  95398. * Specifies if the material will require alpha blending
  95399. * @returns a boolean specifying if alpha blending is needed
  95400. */
  95401. needAlphaBlending(): boolean;
  95402. /**
  95403. * Specifies if this material should be rendered in alpha test mode
  95404. * @returns a boolean specifying if an alpha test is needed.
  95405. */
  95406. needAlphaTesting(): boolean;
  95407. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95408. /**
  95409. * Get the texture used for alpha test purpose.
  95410. * @returns the diffuse texture in case of the standard material.
  95411. */
  95412. getAlphaTestTexture(): Nullable<BaseTexture>;
  95413. /**
  95414. * Get if the submesh is ready to be used and all its information available.
  95415. * Child classes can use it to update shaders
  95416. * @param mesh defines the mesh to check
  95417. * @param subMesh defines which submesh to check
  95418. * @param useInstances specifies that instances should be used
  95419. * @returns a boolean indicating that the submesh is ready or not
  95420. */
  95421. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95422. /**
  95423. * Builds the material UBO layouts.
  95424. * Used internally during the effect preparation.
  95425. */
  95426. buildUniformLayout(): void;
  95427. /**
  95428. * Unbinds the material from the mesh
  95429. */
  95430. unbind(): void;
  95431. /**
  95432. * Binds the submesh to this material by preparing the effect and shader to draw
  95433. * @param world defines the world transformation matrix
  95434. * @param mesh defines the mesh containing the submesh
  95435. * @param subMesh defines the submesh to bind the material to
  95436. */
  95437. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95438. /**
  95439. * Get the list of animatables in the material.
  95440. * @returns the list of animatables object used in the material
  95441. */
  95442. getAnimatables(): IAnimatable[];
  95443. /**
  95444. * Gets the active textures from the material
  95445. * @returns an array of textures
  95446. */
  95447. getActiveTextures(): BaseTexture[];
  95448. /**
  95449. * Specifies if the material uses a texture
  95450. * @param texture defines the texture to check against the material
  95451. * @returns a boolean specifying if the material uses the texture
  95452. */
  95453. hasTexture(texture: BaseTexture): boolean;
  95454. /**
  95455. * Disposes the material
  95456. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95457. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95458. */
  95459. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95460. /**
  95461. * Makes a duplicate of the material, and gives it a new name
  95462. * @param name defines the new name for the duplicated material
  95463. * @returns the cloned material
  95464. */
  95465. clone(name: string): StandardMaterial;
  95466. /**
  95467. * Serializes this material in a JSON representation
  95468. * @returns the serialized material object
  95469. */
  95470. serialize(): any;
  95471. /**
  95472. * Creates a standard material from parsed material data
  95473. * @param source defines the JSON representation of the material
  95474. * @param scene defines the hosting scene
  95475. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95476. * @returns a new standard material
  95477. */
  95478. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95479. /**
  95480. * Are diffuse textures enabled in the application.
  95481. */
  95482. static DiffuseTextureEnabled: boolean;
  95483. /**
  95484. * Are ambient textures enabled in the application.
  95485. */
  95486. static AmbientTextureEnabled: boolean;
  95487. /**
  95488. * Are opacity textures enabled in the application.
  95489. */
  95490. static OpacityTextureEnabled: boolean;
  95491. /**
  95492. * Are reflection textures enabled in the application.
  95493. */
  95494. static ReflectionTextureEnabled: boolean;
  95495. /**
  95496. * Are emissive textures enabled in the application.
  95497. */
  95498. static EmissiveTextureEnabled: boolean;
  95499. /**
  95500. * Are specular textures enabled in the application.
  95501. */
  95502. static SpecularTextureEnabled: boolean;
  95503. /**
  95504. * Are bump textures enabled in the application.
  95505. */
  95506. static BumpTextureEnabled: boolean;
  95507. /**
  95508. * Are lightmap textures enabled in the application.
  95509. */
  95510. static LightmapTextureEnabled: boolean;
  95511. /**
  95512. * Are refraction textures enabled in the application.
  95513. */
  95514. static RefractionTextureEnabled: boolean;
  95515. /**
  95516. * Are color grading textures enabled in the application.
  95517. */
  95518. static ColorGradingTextureEnabled: boolean;
  95519. /**
  95520. * Are fresnels enabled in the application.
  95521. */
  95522. static FresnelEnabled: boolean;
  95523. }
  95524. }
  95525. declare module BABYLON {
  95526. /**
  95527. * A class extending Texture allowing drawing on a texture
  95528. * @see http://doc.babylonjs.com/how_to/dynamictexture
  95529. */
  95530. export class DynamicTexture extends Texture {
  95531. private _generateMipMaps;
  95532. private _canvas;
  95533. private _context;
  95534. private _engine;
  95535. /**
  95536. * Creates a DynamicTexture
  95537. * @param name defines the name of the texture
  95538. * @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
  95539. * @param scene defines the scene where you want the texture
  95540. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  95541. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95542. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  95543. */
  95544. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  95545. /**
  95546. * Get the current class name of the texture useful for serialization or dynamic coding.
  95547. * @returns "DynamicTexture"
  95548. */
  95549. getClassName(): string;
  95550. /**
  95551. * Gets the current state of canRescale
  95552. */
  95553. readonly canRescale: boolean;
  95554. private _recreate;
  95555. /**
  95556. * Scales the texture
  95557. * @param ratio the scale factor to apply to both width and height
  95558. */
  95559. scale(ratio: number): void;
  95560. /**
  95561. * Resizes the texture
  95562. * @param width the new width
  95563. * @param height the new height
  95564. */
  95565. scaleTo(width: number, height: number): void;
  95566. /**
  95567. * Gets the context of the canvas used by the texture
  95568. * @returns the canvas context of the dynamic texture
  95569. */
  95570. getContext(): CanvasRenderingContext2D;
  95571. /**
  95572. * Clears the texture
  95573. */
  95574. clear(): void;
  95575. /**
  95576. * Updates the texture
  95577. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95578. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  95579. */
  95580. update(invertY?: boolean, premulAlpha?: boolean): void;
  95581. /**
  95582. * Draws text onto the texture
  95583. * @param text defines the text to be drawn
  95584. * @param x defines the placement of the text from the left
  95585. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  95586. * @param font defines the font to be used with font-style, font-size, font-name
  95587. * @param color defines the color used for the text
  95588. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  95589. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95590. * @param update defines whether texture is immediately update (default is true)
  95591. */
  95592. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  95593. /**
  95594. * Clones the texture
  95595. * @returns the clone of the texture.
  95596. */
  95597. clone(): DynamicTexture;
  95598. /**
  95599. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  95600. * @returns a serialized dynamic texture object
  95601. */
  95602. serialize(): any;
  95603. /** @hidden */
  95604. _rebuild(): void;
  95605. }
  95606. }
  95607. declare module BABYLON {
  95608. /** @hidden */
  95609. export var imageProcessingPixelShader: {
  95610. name: string;
  95611. shader: string;
  95612. };
  95613. }
  95614. declare module BABYLON {
  95615. /**
  95616. * ImageProcessingPostProcess
  95617. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  95618. */
  95619. export class ImageProcessingPostProcess extends PostProcess {
  95620. /**
  95621. * Default configuration related to image processing available in the PBR Material.
  95622. */
  95623. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95624. /**
  95625. * Gets the image processing configuration used either in this material.
  95626. */
  95627. /**
  95628. * Sets the Default image processing configuration used either in the this material.
  95629. *
  95630. * If sets to null, the scene one is in use.
  95631. */
  95632. imageProcessingConfiguration: ImageProcessingConfiguration;
  95633. /**
  95634. * Keep track of the image processing observer to allow dispose and replace.
  95635. */
  95636. private _imageProcessingObserver;
  95637. /**
  95638. * Attaches a new image processing configuration to the PBR Material.
  95639. * @param configuration
  95640. */
  95641. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  95642. /**
  95643. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95644. */
  95645. /**
  95646. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95647. */
  95648. colorCurves: Nullable<ColorCurves>;
  95649. /**
  95650. * Gets wether the color curves effect is enabled.
  95651. */
  95652. /**
  95653. * Sets wether the color curves effect is enabled.
  95654. */
  95655. colorCurvesEnabled: boolean;
  95656. /**
  95657. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95658. */
  95659. /**
  95660. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95661. */
  95662. colorGradingTexture: Nullable<BaseTexture>;
  95663. /**
  95664. * Gets wether the color grading effect is enabled.
  95665. */
  95666. /**
  95667. * Gets wether the color grading effect is enabled.
  95668. */
  95669. colorGradingEnabled: boolean;
  95670. /**
  95671. * Gets exposure used in the effect.
  95672. */
  95673. /**
  95674. * Sets exposure used in the effect.
  95675. */
  95676. exposure: number;
  95677. /**
  95678. * Gets wether tonemapping is enabled or not.
  95679. */
  95680. /**
  95681. * Sets wether tonemapping is enabled or not
  95682. */
  95683. toneMappingEnabled: boolean;
  95684. /**
  95685. * Gets the type of tone mapping effect.
  95686. */
  95687. /**
  95688. * Sets the type of tone mapping effect.
  95689. */
  95690. toneMappingType: number;
  95691. /**
  95692. * Gets contrast used in the effect.
  95693. */
  95694. /**
  95695. * Sets contrast used in the effect.
  95696. */
  95697. contrast: number;
  95698. /**
  95699. * Gets Vignette stretch size.
  95700. */
  95701. /**
  95702. * Sets Vignette stretch size.
  95703. */
  95704. vignetteStretch: number;
  95705. /**
  95706. * Gets Vignette centre X Offset.
  95707. */
  95708. /**
  95709. * Sets Vignette centre X Offset.
  95710. */
  95711. vignetteCentreX: number;
  95712. /**
  95713. * Gets Vignette centre Y Offset.
  95714. */
  95715. /**
  95716. * Sets Vignette centre Y Offset.
  95717. */
  95718. vignetteCentreY: number;
  95719. /**
  95720. * Gets Vignette weight or intensity of the vignette effect.
  95721. */
  95722. /**
  95723. * Sets Vignette weight or intensity of the vignette effect.
  95724. */
  95725. vignetteWeight: number;
  95726. /**
  95727. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95728. * if vignetteEnabled is set to true.
  95729. */
  95730. /**
  95731. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95732. * if vignetteEnabled is set to true.
  95733. */
  95734. vignetteColor: Color4;
  95735. /**
  95736. * Gets Camera field of view used by the Vignette effect.
  95737. */
  95738. /**
  95739. * Sets Camera field of view used by the Vignette effect.
  95740. */
  95741. vignetteCameraFov: number;
  95742. /**
  95743. * Gets the vignette blend mode allowing different kind of effect.
  95744. */
  95745. /**
  95746. * Sets the vignette blend mode allowing different kind of effect.
  95747. */
  95748. vignetteBlendMode: number;
  95749. /**
  95750. * Gets wether the vignette effect is enabled.
  95751. */
  95752. /**
  95753. * Sets wether the vignette effect is enabled.
  95754. */
  95755. vignetteEnabled: boolean;
  95756. private _fromLinearSpace;
  95757. /**
  95758. * Gets wether the input of the processing is in Gamma or Linear Space.
  95759. */
  95760. /**
  95761. * Sets wether the input of the processing is in Gamma or Linear Space.
  95762. */
  95763. fromLinearSpace: boolean;
  95764. /**
  95765. * Defines cache preventing GC.
  95766. */
  95767. private _defines;
  95768. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  95769. /**
  95770. * "ImageProcessingPostProcess"
  95771. * @returns "ImageProcessingPostProcess"
  95772. */
  95773. getClassName(): string;
  95774. protected _updateParameters(): void;
  95775. dispose(camera?: Camera): void;
  95776. }
  95777. }
  95778. declare module BABYLON {
  95779. /**
  95780. * Class containing static functions to help procedurally build meshes
  95781. */
  95782. export class GroundBuilder {
  95783. /**
  95784. * Creates a ground mesh
  95785. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  95786. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  95787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95788. * @param name defines the name of the mesh
  95789. * @param options defines the options used to create the mesh
  95790. * @param scene defines the hosting scene
  95791. * @returns the ground mesh
  95792. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  95793. */
  95794. static CreateGround(name: string, options: {
  95795. width?: number;
  95796. height?: number;
  95797. subdivisions?: number;
  95798. subdivisionsX?: number;
  95799. subdivisionsY?: number;
  95800. updatable?: boolean;
  95801. }, scene: any): Mesh;
  95802. /**
  95803. * Creates a tiled ground mesh
  95804. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  95805. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  95806. * * 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
  95807. * * 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
  95808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95809. * @param name defines the name of the mesh
  95810. * @param options defines the options used to create the mesh
  95811. * @param scene defines the hosting scene
  95812. * @returns the tiled ground mesh
  95813. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  95814. */
  95815. static CreateTiledGround(name: string, options: {
  95816. xmin: number;
  95817. zmin: number;
  95818. xmax: number;
  95819. zmax: number;
  95820. subdivisions?: {
  95821. w: number;
  95822. h: number;
  95823. };
  95824. precision?: {
  95825. w: number;
  95826. h: number;
  95827. };
  95828. updatable?: boolean;
  95829. }, scene: Scene): Mesh;
  95830. /**
  95831. * Creates a ground mesh from a height map
  95832. * * The parameter `url` sets the URL of the height map image resource.
  95833. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  95834. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  95835. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  95836. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  95837. * * 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.
  95838. * * 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).
  95839. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95841. * @param name defines the name of the mesh
  95842. * @param url defines the url to the height map
  95843. * @param options defines the options used to create the mesh
  95844. * @param scene defines the hosting scene
  95845. * @returns the ground mesh
  95846. * @see https://doc.babylonjs.com/babylon101/height_map
  95847. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  95848. */
  95849. static CreateGroundFromHeightMap(name: string, url: string, options: {
  95850. width?: number;
  95851. height?: number;
  95852. subdivisions?: number;
  95853. minHeight?: number;
  95854. maxHeight?: number;
  95855. colorFilter?: Color3;
  95856. alphaFilter?: number;
  95857. updatable?: boolean;
  95858. onReady?: (mesh: GroundMesh) => void;
  95859. }, scene: Scene): GroundMesh;
  95860. }
  95861. }
  95862. declare module BABYLON {
  95863. /**
  95864. * Class containing static functions to help procedurally build meshes
  95865. */
  95866. export class TorusBuilder {
  95867. /**
  95868. * Creates a torus mesh
  95869. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  95870. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  95871. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  95872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95875. * @param name defines the name of the mesh
  95876. * @param options defines the options used to create the mesh
  95877. * @param scene defines the hosting scene
  95878. * @returns the torus mesh
  95879. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  95880. */
  95881. static CreateTorus(name: string, options: {
  95882. diameter?: number;
  95883. thickness?: number;
  95884. tessellation?: number;
  95885. updatable?: boolean;
  95886. sideOrientation?: number;
  95887. frontUVs?: Vector4;
  95888. backUVs?: Vector4;
  95889. }, scene: any): Mesh;
  95890. }
  95891. }
  95892. declare module BABYLON {
  95893. /**
  95894. * Class containing static functions to help procedurally build meshes
  95895. */
  95896. export class CylinderBuilder {
  95897. /**
  95898. * Creates a cylinder or a cone mesh
  95899. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  95900. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  95901. * * 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.
  95902. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  95903. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  95904. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  95905. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  95906. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  95907. * * 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).
  95908. * * 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
  95909. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  95910. * * 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
  95911. * * 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.
  95912. * * If `enclose` is false, a ring surface is one element.
  95913. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  95914. * * 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
  95915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95918. * @param name defines the name of the mesh
  95919. * @param options defines the options used to create the mesh
  95920. * @param scene defines the hosting scene
  95921. * @returns the cylinder mesh
  95922. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  95923. */
  95924. static CreateCylinder(name: string, options: {
  95925. height?: number;
  95926. diameterTop?: number;
  95927. diameterBottom?: number;
  95928. diameter?: number;
  95929. tessellation?: number;
  95930. subdivisions?: number;
  95931. arc?: number;
  95932. faceColors?: Color4[];
  95933. faceUV?: Vector4[];
  95934. updatable?: boolean;
  95935. hasRings?: boolean;
  95936. enclose?: boolean;
  95937. sideOrientation?: number;
  95938. frontUVs?: Vector4;
  95939. backUVs?: Vector4;
  95940. }, scene: any): Mesh;
  95941. }
  95942. }
  95943. declare module BABYLON {
  95944. /**
  95945. * Manager for handling gamepads
  95946. */
  95947. export class GamepadManager {
  95948. private _scene?;
  95949. private _babylonGamepads;
  95950. private _oneGamepadConnected;
  95951. /** @hidden */
  95952. _isMonitoring: boolean;
  95953. private _gamepadEventSupported;
  95954. private _gamepadSupport;
  95955. /**
  95956. * observable to be triggered when the gamepad controller has been connected
  95957. */
  95958. onGamepadConnectedObservable: Observable<Gamepad>;
  95959. /**
  95960. * observable to be triggered when the gamepad controller has been disconnected
  95961. */
  95962. onGamepadDisconnectedObservable: Observable<Gamepad>;
  95963. private _onGamepadConnectedEvent;
  95964. private _onGamepadDisconnectedEvent;
  95965. /**
  95966. * Initializes the gamepad manager
  95967. * @param _scene BabylonJS scene
  95968. */
  95969. constructor(_scene?: Scene | undefined);
  95970. /**
  95971. * The gamepads in the game pad manager
  95972. */
  95973. readonly gamepads: Gamepad[];
  95974. /**
  95975. * Get the gamepad controllers based on type
  95976. * @param type The type of gamepad controller
  95977. * @returns Nullable gamepad
  95978. */
  95979. getGamepadByType(type?: number): Nullable<Gamepad>;
  95980. /**
  95981. * Disposes the gamepad manager
  95982. */
  95983. dispose(): void;
  95984. private _addNewGamepad;
  95985. private _startMonitoringGamepads;
  95986. private _stopMonitoringGamepads;
  95987. /** @hidden */
  95988. _checkGamepadsStatus(): void;
  95989. private _updateGamepadObjects;
  95990. }
  95991. }
  95992. declare module BABYLON {
  95993. interface Scene {
  95994. /** @hidden */
  95995. _gamepadManager: Nullable<GamepadManager>;
  95996. /**
  95997. * Gets the gamepad manager associated with the scene
  95998. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  95999. */
  96000. gamepadManager: GamepadManager;
  96001. }
  96002. /**
  96003. * Interface representing a free camera inputs manager
  96004. */
  96005. interface FreeCameraInputsManager {
  96006. /**
  96007. * Adds gamepad input support to the FreeCameraInputsManager.
  96008. * @returns the FreeCameraInputsManager
  96009. */
  96010. addGamepad(): FreeCameraInputsManager;
  96011. }
  96012. /**
  96013. * Interface representing an arc rotate camera inputs manager
  96014. */
  96015. interface ArcRotateCameraInputsManager {
  96016. /**
  96017. * Adds gamepad input support to the ArcRotateCamera InputManager.
  96018. * @returns the camera inputs manager
  96019. */
  96020. addGamepad(): ArcRotateCameraInputsManager;
  96021. }
  96022. /**
  96023. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  96024. */
  96025. export class GamepadSystemSceneComponent implements ISceneComponent {
  96026. /**
  96027. * The component name helpfull to identify the component in the list of scene components.
  96028. */
  96029. readonly name: string;
  96030. /**
  96031. * The scene the component belongs to.
  96032. */
  96033. scene: Scene;
  96034. /**
  96035. * Creates a new instance of the component for the given scene
  96036. * @param scene Defines the scene to register the component in
  96037. */
  96038. constructor(scene: Scene);
  96039. /**
  96040. * Registers the component in a given scene
  96041. */
  96042. register(): void;
  96043. /**
  96044. * Rebuilds the elements related to this component in case of
  96045. * context lost for instance.
  96046. */
  96047. rebuild(): void;
  96048. /**
  96049. * Disposes the component and the associated ressources
  96050. */
  96051. dispose(): void;
  96052. private _beforeCameraUpdate;
  96053. }
  96054. }
  96055. declare module BABYLON {
  96056. /**
  96057. * Options to modify the vr teleportation behavior.
  96058. */
  96059. export interface VRTeleportationOptions {
  96060. /**
  96061. * The name of the mesh which should be used as the teleportation floor. (default: null)
  96062. */
  96063. floorMeshName?: string;
  96064. /**
  96065. * A list of meshes to be used as the teleportation floor. (default: empty)
  96066. */
  96067. floorMeshes?: Mesh[];
  96068. }
  96069. /**
  96070. * Options to modify the vr experience helper's behavior.
  96071. */
  96072. export interface VRExperienceHelperOptions extends WebVROptions {
  96073. /**
  96074. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96075. */
  96076. createDeviceOrientationCamera?: boolean;
  96077. /**
  96078. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96079. */
  96080. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96081. /**
  96082. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96083. */
  96084. laserToggle?: boolean;
  96085. /**
  96086. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96087. */
  96088. floorMeshes?: Mesh[];
  96089. /**
  96090. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96091. */
  96092. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96093. }
  96094. /**
  96095. * Event containing information after VR has been entered
  96096. */
  96097. export class OnAfterEnteringVRObservableEvent {
  96098. /**
  96099. * If entering vr was successful
  96100. */
  96101. success: boolean;
  96102. }
  96103. /**
  96104. * Helps to quickly add VR support to an existing scene.
  96105. * See http://doc.babylonjs.com/how_to/webvr_helper
  96106. */
  96107. export class VRExperienceHelper {
  96108. /** Options to modify the vr experience helper's behavior. */
  96109. webVROptions: VRExperienceHelperOptions;
  96110. private _scene;
  96111. private _position;
  96112. private _btnVR;
  96113. private _btnVRDisplayed;
  96114. private _webVRsupported;
  96115. private _webVRready;
  96116. private _webVRrequesting;
  96117. private _webVRpresenting;
  96118. private _hasEnteredVR;
  96119. private _fullscreenVRpresenting;
  96120. private _canvas;
  96121. private _webVRCamera;
  96122. private _vrDeviceOrientationCamera;
  96123. private _deviceOrientationCamera;
  96124. private _existingCamera;
  96125. private _onKeyDown;
  96126. private _onVrDisplayPresentChange;
  96127. private _onVRDisplayChanged;
  96128. private _onVRRequestPresentStart;
  96129. private _onVRRequestPresentComplete;
  96130. /**
  96131. * Observable raised right before entering VR.
  96132. */
  96133. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96134. /**
  96135. * Observable raised when entering VR has completed.
  96136. */
  96137. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96138. /**
  96139. * Observable raised when exiting VR.
  96140. */
  96141. onExitingVRObservable: Observable<VRExperienceHelper>;
  96142. /**
  96143. * Observable raised when controller mesh is loaded.
  96144. */
  96145. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96146. /** Return this.onEnteringVRObservable
  96147. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96148. */
  96149. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96150. /** Return this.onExitingVRObservable
  96151. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96152. */
  96153. readonly onExitingVR: Observable<VRExperienceHelper>;
  96154. /** Return this.onControllerMeshLoadedObservable
  96155. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96156. */
  96157. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96158. private _rayLength;
  96159. private _useCustomVRButton;
  96160. private _teleportationRequested;
  96161. private _teleportActive;
  96162. private _floorMeshName;
  96163. private _floorMeshesCollection;
  96164. private _rotationAllowed;
  96165. private _teleportBackwardsVector;
  96166. private _teleportationTarget;
  96167. private _isDefaultTeleportationTarget;
  96168. private _postProcessMove;
  96169. private _teleportationFillColor;
  96170. private _teleportationBorderColor;
  96171. private _rotationAngle;
  96172. private _haloCenter;
  96173. private _cameraGazer;
  96174. private _padSensibilityUp;
  96175. private _padSensibilityDown;
  96176. private _leftController;
  96177. private _rightController;
  96178. /**
  96179. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96180. */
  96181. onNewMeshSelected: Observable<AbstractMesh>;
  96182. /**
  96183. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96184. */
  96185. onNewMeshPicked: Observable<PickingInfo>;
  96186. private _circleEase;
  96187. /**
  96188. * Observable raised before camera teleportation
  96189. */
  96190. onBeforeCameraTeleport: Observable<Vector3>;
  96191. /**
  96192. * Observable raised after camera teleportation
  96193. */
  96194. onAfterCameraTeleport: Observable<Vector3>;
  96195. /**
  96196. * Observable raised when current selected mesh gets unselected
  96197. */
  96198. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96199. private _raySelectionPredicate;
  96200. /**
  96201. * To be optionaly changed by user to define custom ray selection
  96202. */
  96203. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96204. /**
  96205. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96206. */
  96207. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96208. /**
  96209. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96210. */
  96211. teleportationEnabled: boolean;
  96212. private _defaultHeight;
  96213. private _teleportationInitialized;
  96214. private _interactionsEnabled;
  96215. private _interactionsRequested;
  96216. private _displayGaze;
  96217. private _displayLaserPointer;
  96218. /**
  96219. * The mesh used to display where the user is going to teleport.
  96220. */
  96221. /**
  96222. * Sets the mesh to be used to display where the user is going to teleport.
  96223. */
  96224. teleportationTarget: Mesh;
  96225. /**
  96226. * 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
  96227. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96228. * See http://doc.babylonjs.com/resources/baking_transformations
  96229. */
  96230. gazeTrackerMesh: Mesh;
  96231. /**
  96232. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96233. */
  96234. updateGazeTrackerScale: boolean;
  96235. /**
  96236. * If the gaze trackers color should be updated when selecting meshes
  96237. */
  96238. updateGazeTrackerColor: boolean;
  96239. /**
  96240. * The gaze tracking mesh corresponding to the left controller
  96241. */
  96242. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96243. /**
  96244. * The gaze tracking mesh corresponding to the right controller
  96245. */
  96246. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96247. /**
  96248. * If the ray of the gaze should be displayed.
  96249. */
  96250. /**
  96251. * Sets if the ray of the gaze should be displayed.
  96252. */
  96253. displayGaze: boolean;
  96254. /**
  96255. * If the ray of the LaserPointer should be displayed.
  96256. */
  96257. /**
  96258. * Sets if the ray of the LaserPointer should be displayed.
  96259. */
  96260. displayLaserPointer: boolean;
  96261. /**
  96262. * The deviceOrientationCamera used as the camera when not in VR.
  96263. */
  96264. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96265. /**
  96266. * Based on the current WebVR support, returns the current VR camera used.
  96267. */
  96268. readonly currentVRCamera: Nullable<Camera>;
  96269. /**
  96270. * The webVRCamera which is used when in VR.
  96271. */
  96272. readonly webVRCamera: WebVRFreeCamera;
  96273. /**
  96274. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96275. */
  96276. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96277. private readonly _teleportationRequestInitiated;
  96278. /**
  96279. * Defines wether or not Pointer lock should be requested when switching to
  96280. * full screen.
  96281. */
  96282. requestPointerLockOnFullScreen: boolean;
  96283. /**
  96284. * Instantiates a VRExperienceHelper.
  96285. * Helps to quickly add VR support to an existing scene.
  96286. * @param scene The scene the VRExperienceHelper belongs to.
  96287. * @param webVROptions Options to modify the vr experience helper's behavior.
  96288. */
  96289. constructor(scene: Scene,
  96290. /** Options to modify the vr experience helper's behavior. */
  96291. webVROptions?: VRExperienceHelperOptions);
  96292. private _onDefaultMeshLoaded;
  96293. private _onResize;
  96294. private _onFullscreenChange;
  96295. /**
  96296. * Gets a value indicating if we are currently in VR mode.
  96297. */
  96298. readonly isInVRMode: boolean;
  96299. private onVrDisplayPresentChange;
  96300. private onVRDisplayChanged;
  96301. private moveButtonToBottomRight;
  96302. private displayVRButton;
  96303. private updateButtonVisibility;
  96304. private _cachedAngularSensibility;
  96305. /**
  96306. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96307. * Otherwise, will use the fullscreen API.
  96308. */
  96309. enterVR(): void;
  96310. /**
  96311. * Attempt to exit VR, or fullscreen.
  96312. */
  96313. exitVR(): void;
  96314. /**
  96315. * The position of the vr experience helper.
  96316. */
  96317. /**
  96318. * Sets the position of the vr experience helper.
  96319. */
  96320. position: Vector3;
  96321. /**
  96322. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96323. */
  96324. enableInteractions(): void;
  96325. private readonly _noControllerIsActive;
  96326. private beforeRender;
  96327. private _isTeleportationFloor;
  96328. /**
  96329. * Adds a floor mesh to be used for teleportation.
  96330. * @param floorMesh the mesh to be used for teleportation.
  96331. */
  96332. addFloorMesh(floorMesh: Mesh): void;
  96333. /**
  96334. * Removes a floor mesh from being used for teleportation.
  96335. * @param floorMesh the mesh to be removed.
  96336. */
  96337. removeFloorMesh(floorMesh: Mesh): void;
  96338. /**
  96339. * Enables interactions and teleportation using the VR controllers and gaze.
  96340. * @param vrTeleportationOptions options to modify teleportation behavior.
  96341. */
  96342. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96343. private _onNewGamepadConnected;
  96344. private _tryEnableInteractionOnController;
  96345. private _onNewGamepadDisconnected;
  96346. private _enableInteractionOnController;
  96347. private _checkTeleportWithRay;
  96348. private _checkRotate;
  96349. private _checkTeleportBackwards;
  96350. private _enableTeleportationOnController;
  96351. private _createTeleportationCircles;
  96352. private _displayTeleportationTarget;
  96353. private _hideTeleportationTarget;
  96354. private _rotateCamera;
  96355. private _moveTeleportationSelectorTo;
  96356. private _workingVector;
  96357. private _workingQuaternion;
  96358. private _workingMatrix;
  96359. /**
  96360. * Teleports the users feet to the desired location
  96361. * @param location The location where the user's feet should be placed
  96362. */
  96363. teleportCamera(location: Vector3): void;
  96364. private _convertNormalToDirectionOfRay;
  96365. private _castRayAndSelectObject;
  96366. private _notifySelectedMeshUnselected;
  96367. /**
  96368. * Sets the color of the laser ray from the vr controllers.
  96369. * @param color new color for the ray.
  96370. */
  96371. changeLaserColor(color: Color3): void;
  96372. /**
  96373. * Sets the color of the ray from the vr headsets gaze.
  96374. * @param color new color for the ray.
  96375. */
  96376. changeGazeColor(color: Color3): void;
  96377. /**
  96378. * Exits VR and disposes of the vr experience helper
  96379. */
  96380. dispose(): void;
  96381. /**
  96382. * Gets the name of the VRExperienceHelper class
  96383. * @returns "VRExperienceHelper"
  96384. */
  96385. getClassName(): string;
  96386. }
  96387. }
  96388. declare module BABYLON {
  96389. /**
  96390. * Manages an XRSession
  96391. * @see https://doc.babylonjs.com/how_to/webxr
  96392. */
  96393. export class WebXRSessionManager implements IDisposable {
  96394. private scene;
  96395. /**
  96396. * Fires every time a new xrFrame arrives which can be used to update the camera
  96397. */
  96398. onXRFrameObservable: Observable<any>;
  96399. /**
  96400. * Fires when the xr session is ended either by the device or manually done
  96401. */
  96402. onXRSessionEnded: Observable<any>;
  96403. /** @hidden */
  96404. _xrSession: XRSession;
  96405. /** @hidden */
  96406. _frameOfReference: XRFrameOfReference;
  96407. /** @hidden */
  96408. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  96409. /** @hidden */
  96410. _currentXRFrame: Nullable<XRFrame>;
  96411. private _xrNavigator;
  96412. private _xrDevice;
  96413. private _tmpMatrix;
  96414. /**
  96415. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  96416. * @param scene The scene which the session should be created for
  96417. */
  96418. constructor(scene: Scene);
  96419. /**
  96420. * Initializes the manager
  96421. * After initialization enterXR can be called to start an XR session
  96422. * @returns Promise which resolves after it is initialized
  96423. */
  96424. initializeAsync(): Promise<void>;
  96425. /**
  96426. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  96427. * @param sessionCreationOptions xr options to create the session with
  96428. * @param frameOfReferenceType option to configure how the xr pose is expressed
  96429. * @returns Promise which resolves after it enters XR
  96430. */
  96431. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  96432. /**
  96433. * Stops the xrSession and restores the renderloop
  96434. * @returns Promise which resolves after it exits XR
  96435. */
  96436. exitXRAsync(): Promise<void>;
  96437. /**
  96438. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96439. * @param ray ray to cast into the environment
  96440. * @returns Promise which resolves with a collision point in the environment if it exists
  96441. */
  96442. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96443. /**
  96444. * Checks if a session would be supported for the creation options specified
  96445. * @param options creation options to check if they are supported
  96446. * @returns true if supported
  96447. */
  96448. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96449. /**
  96450. * @hidden
  96451. * Converts the render layer of xrSession to a render target
  96452. * @param session session to create render target for
  96453. * @param scene scene the new render target should be created for
  96454. */
  96455. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  96456. /**
  96457. * Disposes of the session manager
  96458. */
  96459. dispose(): void;
  96460. }
  96461. }
  96462. declare module BABYLON {
  96463. /**
  96464. * WebXR Camera which holds the views for the xrSession
  96465. * @see https://doc.babylonjs.com/how_to/webxr
  96466. */
  96467. export class WebXRCamera extends FreeCamera {
  96468. private static _TmpMatrix;
  96469. /**
  96470. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  96471. * @param name the name of the camera
  96472. * @param scene the scene to add the camera to
  96473. */
  96474. constructor(name: string, scene: Scene);
  96475. private _updateNumberOfRigCameras;
  96476. /** @hidden */
  96477. _updateForDualEyeDebugging(pupilDistance?: number): void;
  96478. /**
  96479. * Updates the cameras position from the current pose information of the XR session
  96480. * @param xrSessionManager the session containing pose information
  96481. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  96482. */
  96483. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  96484. }
  96485. }
  96486. declare module BABYLON {
  96487. /**
  96488. * States of the webXR experience
  96489. */
  96490. export enum WebXRState {
  96491. /**
  96492. * Transitioning to being in XR mode
  96493. */
  96494. ENTERING_XR = 0,
  96495. /**
  96496. * Transitioning to non XR mode
  96497. */
  96498. EXITING_XR = 1,
  96499. /**
  96500. * In XR mode and presenting
  96501. */
  96502. IN_XR = 2,
  96503. /**
  96504. * Not entered XR mode
  96505. */
  96506. NOT_IN_XR = 3
  96507. }
  96508. /**
  96509. * Helper class used to enable XR
  96510. * @see https://doc.babylonjs.com/how_to/webxr
  96511. */
  96512. export class WebXRExperienceHelper implements IDisposable {
  96513. private scene;
  96514. /**
  96515. * 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
  96516. */
  96517. container: AbstractMesh;
  96518. /**
  96519. * Camera used to render xr content
  96520. */
  96521. camera: WebXRCamera;
  96522. /**
  96523. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  96524. */
  96525. state: WebXRState;
  96526. private _setState;
  96527. private static _TmpVector;
  96528. /**
  96529. * Fires when the state of the experience helper has changed
  96530. */
  96531. onStateChangedObservable: Observable<WebXRState>;
  96532. /** @hidden */
  96533. _sessionManager: WebXRSessionManager;
  96534. private _nonVRCamera;
  96535. private _originalSceneAutoClear;
  96536. private _supported;
  96537. /**
  96538. * Creates the experience helper
  96539. * @param scene the scene to attach the experience helper to
  96540. * @returns a promise for the experience helper
  96541. */
  96542. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  96543. /**
  96544. * Creates a WebXRExperienceHelper
  96545. * @param scene The scene the helper should be created in
  96546. */
  96547. private constructor();
  96548. /**
  96549. * Exits XR mode and returns the scene to its original state
  96550. * @returns promise that resolves after xr mode has exited
  96551. */
  96552. exitXRAsync(): Promise<void>;
  96553. /**
  96554. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  96555. * @param sessionCreationOptions options for the XR session
  96556. * @param frameOfReference frame of reference of the XR session
  96557. * @returns promise that resolves after xr mode has entered
  96558. */
  96559. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  96560. /**
  96561. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96562. * @param ray ray to cast into the environment
  96563. * @returns Promise which resolves with a collision point in the environment if it exists
  96564. */
  96565. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96566. /**
  96567. * Updates the global position of the camera by moving the camera's container
  96568. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  96569. * @param position The desired global position of the camera
  96570. */
  96571. setPositionOfCameraUsingContainer(position: Vector3): void;
  96572. /**
  96573. * Rotates the xr camera by rotating the camera's container around the camera's position
  96574. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  96575. * @param rotation the desired quaternion rotation to apply to the camera
  96576. */
  96577. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  96578. /**
  96579. * Checks if the creation options are supported by the xr session
  96580. * @param options creation options
  96581. * @returns true if supported
  96582. */
  96583. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96584. /**
  96585. * Disposes of the experience helper
  96586. */
  96587. dispose(): void;
  96588. }
  96589. }
  96590. declare module BABYLON {
  96591. /**
  96592. * Button which can be used to enter a different mode of XR
  96593. */
  96594. export class WebXREnterExitUIButton {
  96595. /** button element */
  96596. element: HTMLElement;
  96597. /** XR initialization options for the button */
  96598. initializationOptions: XRSessionCreationOptions;
  96599. /**
  96600. * Creates a WebXREnterExitUIButton
  96601. * @param element button element
  96602. * @param initializationOptions XR initialization options for the button
  96603. */
  96604. constructor(
  96605. /** button element */
  96606. element: HTMLElement,
  96607. /** XR initialization options for the button */
  96608. initializationOptions: XRSessionCreationOptions);
  96609. /**
  96610. * Overwritable function which can be used to update the button's visuals when the state changes
  96611. * @param activeButton the current active button in the UI
  96612. */
  96613. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  96614. }
  96615. /**
  96616. * Options to create the webXR UI
  96617. */
  96618. export class WebXREnterExitUIOptions {
  96619. /**
  96620. * Context to enter xr with
  96621. */
  96622. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  96623. /**
  96624. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  96625. */
  96626. customButtons?: Array<WebXREnterExitUIButton>;
  96627. }
  96628. /**
  96629. * UI to allow the user to enter/exit XR mode
  96630. */
  96631. export class WebXREnterExitUI implements IDisposable {
  96632. private scene;
  96633. private _overlay;
  96634. private _buttons;
  96635. private _activeButton;
  96636. /**
  96637. * Fired every time the active button is changed.
  96638. *
  96639. * When xr is entered via a button that launches xr that button will be the callback parameter
  96640. *
  96641. * When exiting xr the callback parameter will be null)
  96642. */
  96643. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  96644. /**
  96645. * Creates UI to allow the user to enter/exit XR mode
  96646. * @param scene the scene to add the ui to
  96647. * @param helper the xr experience helper to enter/exit xr with
  96648. * @param options options to configure the UI
  96649. * @returns the created ui
  96650. */
  96651. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  96652. private constructor();
  96653. private _updateButtons;
  96654. /**
  96655. * Disposes of the object
  96656. */
  96657. dispose(): void;
  96658. }
  96659. }
  96660. declare module BABYLON {
  96661. /**
  96662. * Represents an XR input
  96663. */
  96664. export class WebXRController {
  96665. /**
  96666. * 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
  96667. */
  96668. grip?: AbstractMesh;
  96669. /**
  96670. * Pointer which can be used to select objects or attach a visible laser to
  96671. */
  96672. pointer: AbstractMesh;
  96673. /**
  96674. * Creates the controller
  96675. * @see https://doc.babylonjs.com/how_to/webxr
  96676. * @param scene the scene which the controller should be associated to
  96677. */
  96678. constructor(scene: Scene);
  96679. /**
  96680. * Disposes of the object
  96681. */
  96682. dispose(): void;
  96683. }
  96684. /**
  96685. * XR input used to track XR inputs such as controllers/rays
  96686. */
  96687. export class WebXRInput implements IDisposable {
  96688. private helper;
  96689. /**
  96690. * XR controllers being tracked
  96691. */
  96692. controllers: Array<WebXRController>;
  96693. private _tmpMatrix;
  96694. private _frameObserver;
  96695. /**
  96696. * Initializes the WebXRInput
  96697. * @param helper experience helper which the input should be created for
  96698. */
  96699. constructor(helper: WebXRExperienceHelper);
  96700. /**
  96701. * Disposes of the object
  96702. */
  96703. dispose(): void;
  96704. }
  96705. }
  96706. declare module BABYLON {
  96707. /**
  96708. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  96709. */
  96710. export class WebXRManagedOutputCanvas implements IDisposable {
  96711. private _canvas;
  96712. /**
  96713. * xrpresent context of the canvas which can be used to display/mirror xr content
  96714. */
  96715. canvasContext: Nullable<WebGLRenderingContext>;
  96716. /**
  96717. * Initializes the canvas to be added/removed upon entering/exiting xr
  96718. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  96719. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  96720. */
  96721. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  96722. /**
  96723. * Disposes of the object
  96724. */
  96725. dispose(): void;
  96726. private _setManagedOutputCanvas;
  96727. private _addCanvas;
  96728. private _removeCanvas;
  96729. }
  96730. }
  96731. declare module BABYLON {
  96732. /**
  96733. * Contains an array of blocks representing the octree
  96734. */
  96735. export interface IOctreeContainer<T> {
  96736. /**
  96737. * Blocks within the octree
  96738. */
  96739. blocks: Array<OctreeBlock<T>>;
  96740. }
  96741. /**
  96742. * Class used to store a cell in an octree
  96743. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96744. */
  96745. export class OctreeBlock<T> {
  96746. /**
  96747. * Gets the content of the current block
  96748. */
  96749. entries: T[];
  96750. /**
  96751. * Gets the list of block children
  96752. */
  96753. blocks: Array<OctreeBlock<T>>;
  96754. private _depth;
  96755. private _maxDepth;
  96756. private _capacity;
  96757. private _minPoint;
  96758. private _maxPoint;
  96759. private _boundingVectors;
  96760. private _creationFunc;
  96761. /**
  96762. * Creates a new block
  96763. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  96764. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  96765. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96766. * @param depth defines the current depth of this block in the octree
  96767. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  96768. * @param creationFunc defines a callback to call when an element is added to the block
  96769. */
  96770. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  96771. /**
  96772. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96773. */
  96774. readonly capacity: number;
  96775. /**
  96776. * Gets the minimum vector (in world space) of the block's bounding box
  96777. */
  96778. readonly minPoint: Vector3;
  96779. /**
  96780. * Gets the maximum vector (in world space) of the block's bounding box
  96781. */
  96782. readonly maxPoint: Vector3;
  96783. /**
  96784. * Add a new element to this block
  96785. * @param entry defines the element to add
  96786. */
  96787. addEntry(entry: T): void;
  96788. /**
  96789. * Remove an element from this block
  96790. * @param entry defines the element to remove
  96791. */
  96792. removeEntry(entry: T): void;
  96793. /**
  96794. * Add an array of elements to this block
  96795. * @param entries defines the array of elements to add
  96796. */
  96797. addEntries(entries: T[]): void;
  96798. /**
  96799. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  96800. * @param frustumPlanes defines the frustum planes to test
  96801. * @param selection defines the array to store current content if selection is positive
  96802. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96803. */
  96804. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96805. /**
  96806. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  96807. * @param sphereCenter defines the bounding sphere center
  96808. * @param sphereRadius defines the bounding sphere radius
  96809. * @param selection defines the array to store current content if selection is positive
  96810. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96811. */
  96812. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96813. /**
  96814. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  96815. * @param ray defines the ray to test with
  96816. * @param selection defines the array to store current content if selection is positive
  96817. */
  96818. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  96819. /**
  96820. * Subdivide the content into child blocks (this block will then be empty)
  96821. */
  96822. createInnerBlocks(): void;
  96823. /**
  96824. * @hidden
  96825. */
  96826. 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;
  96827. }
  96828. }
  96829. declare module BABYLON {
  96830. /**
  96831. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  96832. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96833. */
  96834. export class Octree<T> {
  96835. /** 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.) */
  96836. maxDepth: number;
  96837. /**
  96838. * Blocks within the octree containing objects
  96839. */
  96840. blocks: Array<OctreeBlock<T>>;
  96841. /**
  96842. * Content stored in the octree
  96843. */
  96844. dynamicContent: T[];
  96845. private _maxBlockCapacity;
  96846. private _selectionContent;
  96847. private _creationFunc;
  96848. /**
  96849. * Creates a octree
  96850. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96851. * @param creationFunc function to be used to instatiate the octree
  96852. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  96853. * @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.)
  96854. */
  96855. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  96856. /** 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.) */
  96857. maxDepth?: number);
  96858. /**
  96859. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  96860. * @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);
  96861. * @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);
  96862. * @param entries meshes to be added to the octree blocks
  96863. */
  96864. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  96865. /**
  96866. * Adds a mesh to the octree
  96867. * @param entry Mesh to add to the octree
  96868. */
  96869. addMesh(entry: T): void;
  96870. /**
  96871. * Remove an element from the octree
  96872. * @param entry defines the element to remove
  96873. */
  96874. removeMesh(entry: T): void;
  96875. /**
  96876. * Selects an array of meshes within the frustum
  96877. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  96878. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  96879. * @returns array of meshes within the frustum
  96880. */
  96881. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  96882. /**
  96883. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  96884. * @param sphereCenter defines the bounding sphere center
  96885. * @param sphereRadius defines the bounding sphere radius
  96886. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96887. * @returns an array of objects that intersect the sphere
  96888. */
  96889. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  96890. /**
  96891. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  96892. * @param ray defines the ray to test with
  96893. * @returns array of intersected objects
  96894. */
  96895. intersectsRay(ray: Ray): SmartArray<T>;
  96896. /**
  96897. * Adds a mesh into the octree block if it intersects the block
  96898. */
  96899. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  96900. /**
  96901. * Adds a submesh into the octree block if it intersects the block
  96902. */
  96903. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  96904. }
  96905. }
  96906. declare module BABYLON {
  96907. interface Scene {
  96908. /**
  96909. * @hidden
  96910. * Backing Filed
  96911. */
  96912. _selectionOctree: Octree<AbstractMesh>;
  96913. /**
  96914. * Gets the octree used to boost mesh selection (picking)
  96915. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96916. */
  96917. selectionOctree: Octree<AbstractMesh>;
  96918. /**
  96919. * Creates or updates the octree used to boost selection (picking)
  96920. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96921. * @param maxCapacity defines the maximum capacity per leaf
  96922. * @param maxDepth defines the maximum depth of the octree
  96923. * @returns an octree of AbstractMesh
  96924. */
  96925. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  96926. }
  96927. interface AbstractMesh {
  96928. /**
  96929. * @hidden
  96930. * Backing Field
  96931. */
  96932. _submeshesOctree: Octree<SubMesh>;
  96933. /**
  96934. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  96935. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96936. * @param maxCapacity defines the maximum size of each block (64 by default)
  96937. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  96938. * @returns the new octree
  96939. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  96940. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96941. */
  96942. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  96943. }
  96944. /**
  96945. * Defines the octree scene component responsible to manage any octrees
  96946. * in a given scene.
  96947. */
  96948. export class OctreeSceneComponent {
  96949. /**
  96950. * The component name helpfull to identify the component in the list of scene components.
  96951. */
  96952. readonly name: string;
  96953. /**
  96954. * The scene the component belongs to.
  96955. */
  96956. scene: Scene;
  96957. /**
  96958. * Indicates if the meshes have been checked to make sure they are isEnabled()
  96959. */
  96960. readonly checksIsEnabled: boolean;
  96961. /**
  96962. * Creates a new instance of the component for the given scene
  96963. * @param scene Defines the scene to register the component in
  96964. */
  96965. constructor(scene: Scene);
  96966. /**
  96967. * Registers the component in a given scene
  96968. */
  96969. register(): void;
  96970. /**
  96971. * Return the list of active meshes
  96972. * @returns the list of active meshes
  96973. */
  96974. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  96975. /**
  96976. * Return the list of active sub meshes
  96977. * @param mesh The mesh to get the candidates sub meshes from
  96978. * @returns the list of active sub meshes
  96979. */
  96980. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  96981. private _tempRay;
  96982. /**
  96983. * Return the list of sub meshes intersecting with a given local ray
  96984. * @param mesh defines the mesh to find the submesh for
  96985. * @param localRay defines the ray in local space
  96986. * @returns the list of intersecting sub meshes
  96987. */
  96988. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  96989. /**
  96990. * Return the list of sub meshes colliding with a collider
  96991. * @param mesh defines the mesh to find the submesh for
  96992. * @param collider defines the collider to evaluate the collision against
  96993. * @returns the list of colliding sub meshes
  96994. */
  96995. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  96996. /**
  96997. * Rebuilds the elements related to this component in case of
  96998. * context lost for instance.
  96999. */
  97000. rebuild(): void;
  97001. /**
  97002. * Disposes the component and the associated ressources.
  97003. */
  97004. dispose(): void;
  97005. }
  97006. }
  97007. declare module BABYLON {
  97008. /**
  97009. * Class containing static functions to help procedurally build meshes
  97010. */
  97011. export class LinesBuilder {
  97012. /**
  97013. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  97014. * * 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
  97015. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  97016. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  97017. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  97018. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  97019. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  97020. * * 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
  97021. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  97022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97023. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  97024. * @param name defines the name of the new line system
  97025. * @param options defines the options used to create the line system
  97026. * @param scene defines the hosting scene
  97027. * @returns a new line system mesh
  97028. */
  97029. static CreateLineSystem(name: string, options: {
  97030. lines: Vector3[][];
  97031. updatable?: boolean;
  97032. instance?: Nullable<LinesMesh>;
  97033. colors?: Nullable<Color4[][]>;
  97034. useVertexAlpha?: boolean;
  97035. }, scene: Nullable<Scene>): LinesMesh;
  97036. /**
  97037. * Creates a line mesh
  97038. * 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
  97039. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97040. * * The parameter `points` is an array successive Vector3
  97041. * * 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
  97042. * * The optional parameter `colors` is an array of successive Color4, one per line point
  97043. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  97044. * * When updating an instance, remember that only point positions can change, not the number of points
  97045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97046. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  97047. * @param name defines the name of the new line system
  97048. * @param options defines the options used to create the line system
  97049. * @param scene defines the hosting scene
  97050. * @returns a new line mesh
  97051. */
  97052. static CreateLines(name: string, options: {
  97053. points: Vector3[];
  97054. updatable?: boolean;
  97055. instance?: Nullable<LinesMesh>;
  97056. colors?: Color4[];
  97057. useVertexAlpha?: boolean;
  97058. }, scene?: Nullable<Scene>): LinesMesh;
  97059. /**
  97060. * Creates a dashed line mesh
  97061. * * 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
  97062. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97063. * * The parameter `points` is an array successive Vector3
  97064. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97065. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97066. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97067. * * 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
  97068. * * When updating an instance, remember that only point positions can change, not the number of points
  97069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97070. * @param name defines the name of the mesh
  97071. * @param options defines the options used to create the mesh
  97072. * @param scene defines the hosting scene
  97073. * @returns the dashed line mesh
  97074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97075. */
  97076. static CreateDashedLines(name: string, options: {
  97077. points: Vector3[];
  97078. dashSize?: number;
  97079. gapSize?: number;
  97080. dashNb?: number;
  97081. updatable?: boolean;
  97082. instance?: LinesMesh;
  97083. }, scene?: Nullable<Scene>): LinesMesh;
  97084. }
  97085. }
  97086. declare module BABYLON {
  97087. /**
  97088. * Renders a layer on top of an existing scene
  97089. */
  97090. export class UtilityLayerRenderer implements IDisposable {
  97091. /** the original scene that will be rendered on top of */
  97092. originalScene: Scene;
  97093. private _pointerCaptures;
  97094. private _lastPointerEvents;
  97095. private static _DefaultUtilityLayer;
  97096. private static _DefaultKeepDepthUtilityLayer;
  97097. /**
  97098. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97099. */
  97100. pickUtilitySceneFirst: boolean;
  97101. /**
  97102. * 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)
  97103. */
  97104. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97105. /**
  97106. * 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)
  97107. */
  97108. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97109. /**
  97110. * The scene that is rendered on top of the original scene
  97111. */
  97112. utilityLayerScene: Scene;
  97113. /**
  97114. * If the utility layer should automatically be rendered on top of existing scene
  97115. */
  97116. shouldRender: boolean;
  97117. /**
  97118. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97119. */
  97120. onlyCheckPointerDownEvents: boolean;
  97121. /**
  97122. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97123. */
  97124. processAllEvents: boolean;
  97125. /**
  97126. * Observable raised when the pointer move from the utility layer scene to the main scene
  97127. */
  97128. onPointerOutObservable: Observable<number>;
  97129. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97130. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97131. private _afterRenderObserver;
  97132. private _sceneDisposeObserver;
  97133. private _originalPointerObserver;
  97134. /**
  97135. * Instantiates a UtilityLayerRenderer
  97136. * @param originalScene the original scene that will be rendered on top of
  97137. * @param handleEvents boolean indicating if the utility layer should handle events
  97138. */
  97139. constructor(
  97140. /** the original scene that will be rendered on top of */
  97141. originalScene: Scene, handleEvents?: boolean);
  97142. private _notifyObservers;
  97143. /**
  97144. * Renders the utility layers scene on top of the original scene
  97145. */
  97146. render(): void;
  97147. /**
  97148. * Disposes of the renderer
  97149. */
  97150. dispose(): void;
  97151. private _updateCamera;
  97152. }
  97153. }
  97154. declare module BABYLON {
  97155. /**
  97156. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97157. */
  97158. export class Gizmo implements IDisposable {
  97159. /** The utility layer the gizmo will be added to */
  97160. gizmoLayer: UtilityLayerRenderer;
  97161. /**
  97162. * The root mesh of the gizmo
  97163. */
  97164. _rootMesh: Mesh;
  97165. private _attachedMesh;
  97166. /**
  97167. * Ratio for the scale of the gizmo (Default: 1)
  97168. */
  97169. scaleRatio: number;
  97170. private _tmpMatrix;
  97171. /**
  97172. * If a custom mesh has been set (Default: false)
  97173. */
  97174. protected _customMeshSet: boolean;
  97175. /**
  97176. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97177. * * When set, interactions will be enabled
  97178. */
  97179. attachedMesh: Nullable<AbstractMesh>;
  97180. /**
  97181. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97182. * @param mesh The mesh to replace the default mesh of the gizmo
  97183. */
  97184. setCustomMesh(mesh: Mesh): void;
  97185. /**
  97186. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97187. */
  97188. updateGizmoRotationToMatchAttachedMesh: boolean;
  97189. /**
  97190. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97191. */
  97192. updateGizmoPositionToMatchAttachedMesh: boolean;
  97193. /**
  97194. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97195. */
  97196. protected _updateScale: boolean;
  97197. protected _interactionsEnabled: boolean;
  97198. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97199. private _beforeRenderObserver;
  97200. /**
  97201. * Creates a gizmo
  97202. * @param gizmoLayer The utility layer the gizmo will be added to
  97203. */
  97204. constructor(
  97205. /** The utility layer the gizmo will be added to */
  97206. gizmoLayer?: UtilityLayerRenderer);
  97207. private _tempVector;
  97208. /**
  97209. * @hidden
  97210. * Updates the gizmo to match the attached mesh's position/rotation
  97211. */
  97212. protected _update(): void;
  97213. /**
  97214. * Disposes of the gizmo
  97215. */
  97216. dispose(): void;
  97217. }
  97218. }
  97219. declare module BABYLON {
  97220. /**
  97221. * Single axis drag gizmo
  97222. */
  97223. export class AxisDragGizmo extends Gizmo {
  97224. /**
  97225. * Drag behavior responsible for the gizmos dragging interactions
  97226. */
  97227. dragBehavior: PointerDragBehavior;
  97228. private _pointerObserver;
  97229. /**
  97230. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97231. */
  97232. snapDistance: number;
  97233. /**
  97234. * Event that fires each time the gizmo snaps to a new location.
  97235. * * snapDistance is the the change in distance
  97236. */
  97237. onSnapObservable: Observable<{
  97238. snapDistance: number;
  97239. }>;
  97240. /** @hidden */
  97241. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97242. /** @hidden */
  97243. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97244. /**
  97245. * Creates an AxisDragGizmo
  97246. * @param gizmoLayer The utility layer the gizmo will be added to
  97247. * @param dragAxis The axis which the gizmo will be able to drag on
  97248. * @param color The color of the gizmo
  97249. */
  97250. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97251. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97252. /**
  97253. * Disposes of the gizmo
  97254. */
  97255. dispose(): void;
  97256. }
  97257. }
  97258. declare module BABYLON.Debug {
  97259. /**
  97260. * The Axes viewer will show 3 axes in a specific point in space
  97261. */
  97262. export class AxesViewer {
  97263. private _xAxis;
  97264. private _yAxis;
  97265. private _zAxis;
  97266. private _scaleLinesFactor;
  97267. private _instanced;
  97268. /**
  97269. * Gets the hosting scene
  97270. */
  97271. scene: Scene;
  97272. /**
  97273. * Gets or sets a number used to scale line length
  97274. */
  97275. scaleLines: number;
  97276. /** Gets the node hierarchy used to render x-axis */
  97277. readonly xAxis: TransformNode;
  97278. /** Gets the node hierarchy used to render y-axis */
  97279. readonly yAxis: TransformNode;
  97280. /** Gets the node hierarchy used to render z-axis */
  97281. readonly zAxis: TransformNode;
  97282. /**
  97283. * Creates a new AxesViewer
  97284. * @param scene defines the hosting scene
  97285. * @param scaleLines defines a number used to scale line length (1 by default)
  97286. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97287. * @param xAxis defines the node hierarchy used to render the x-axis
  97288. * @param yAxis defines the node hierarchy used to render the y-axis
  97289. * @param zAxis defines the node hierarchy used to render the z-axis
  97290. */
  97291. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97292. /**
  97293. * Force the viewer to update
  97294. * @param position defines the position of the viewer
  97295. * @param xaxis defines the x axis of the viewer
  97296. * @param yaxis defines the y axis of the viewer
  97297. * @param zaxis defines the z axis of the viewer
  97298. */
  97299. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97300. /**
  97301. * Creates an instance of this axes viewer.
  97302. * @returns a new axes viewer with instanced meshes
  97303. */
  97304. createInstance(): AxesViewer;
  97305. /** Releases resources */
  97306. dispose(): void;
  97307. private static _SetRenderingGroupId;
  97308. }
  97309. }
  97310. declare module BABYLON.Debug {
  97311. /**
  97312. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97313. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97314. */
  97315. export class BoneAxesViewer extends AxesViewer {
  97316. /**
  97317. * Gets or sets the target mesh where to display the axes viewer
  97318. */
  97319. mesh: Nullable<Mesh>;
  97320. /**
  97321. * Gets or sets the target bone where to display the axes viewer
  97322. */
  97323. bone: Nullable<Bone>;
  97324. /** Gets current position */
  97325. pos: Vector3;
  97326. /** Gets direction of X axis */
  97327. xaxis: Vector3;
  97328. /** Gets direction of Y axis */
  97329. yaxis: Vector3;
  97330. /** Gets direction of Z axis */
  97331. zaxis: Vector3;
  97332. /**
  97333. * Creates a new BoneAxesViewer
  97334. * @param scene defines the hosting scene
  97335. * @param bone defines the target bone
  97336. * @param mesh defines the target mesh
  97337. * @param scaleLines defines a scaling factor for line length (1 by default)
  97338. */
  97339. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97340. /**
  97341. * Force the viewer to update
  97342. */
  97343. update(): void;
  97344. /** Releases resources */
  97345. dispose(): void;
  97346. }
  97347. }
  97348. declare module BABYLON {
  97349. /**
  97350. * Interface used to define scene explorer extensibility option
  97351. */
  97352. export interface IExplorerExtensibilityOption {
  97353. /**
  97354. * Define the option label
  97355. */
  97356. label: string;
  97357. /**
  97358. * Defines the action to execute on click
  97359. */
  97360. action: (entity: any) => void;
  97361. }
  97362. /**
  97363. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  97364. */
  97365. export interface IExplorerExtensibilityGroup {
  97366. /**
  97367. * Defines a predicate to test if a given type mut be extended
  97368. */
  97369. predicate: (entity: any) => boolean;
  97370. /**
  97371. * Gets the list of options added to a type
  97372. */
  97373. entries: IExplorerExtensibilityOption[];
  97374. }
  97375. /**
  97376. * Interface used to define the options to use to create the Inspector
  97377. */
  97378. export interface IInspectorOptions {
  97379. /**
  97380. * Display in overlay mode (default: false)
  97381. */
  97382. overlay?: boolean;
  97383. /**
  97384. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  97385. */
  97386. globalRoot?: HTMLElement;
  97387. /**
  97388. * Display the Scene explorer
  97389. */
  97390. showExplorer?: boolean;
  97391. /**
  97392. * Display the property inspector
  97393. */
  97394. showInspector?: boolean;
  97395. /**
  97396. * Display in embed mode (both panes on the right)
  97397. */
  97398. embedMode?: boolean;
  97399. /**
  97400. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  97401. */
  97402. handleResize?: boolean;
  97403. /**
  97404. * Allow the panes to popup (default: true)
  97405. */
  97406. enablePopup?: boolean;
  97407. /**
  97408. * Allow the panes to be closed by users (default: true)
  97409. */
  97410. enableClose?: boolean;
  97411. /**
  97412. * Optional list of extensibility entries
  97413. */
  97414. explorerExtensibility?: IExplorerExtensibilityGroup[];
  97415. /**
  97416. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  97417. */
  97418. inspectorURL?: string;
  97419. }
  97420. interface Scene {
  97421. /**
  97422. * @hidden
  97423. * Backing field
  97424. */
  97425. _debugLayer: DebugLayer;
  97426. /**
  97427. * Gets the debug layer (aka Inspector) associated with the scene
  97428. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97429. */
  97430. debugLayer: DebugLayer;
  97431. }
  97432. /**
  97433. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97434. * what is happening in your scene
  97435. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97436. */
  97437. export class DebugLayer {
  97438. /**
  97439. * Define the url to get the inspector script from.
  97440. * By default it uses the babylonjs CDN.
  97441. * @ignoreNaming
  97442. */
  97443. static InspectorURL: string;
  97444. private _scene;
  97445. private BJSINSPECTOR;
  97446. /**
  97447. * Observable triggered when a property is changed through the inspector.
  97448. */
  97449. onPropertyChangedObservable: Observable<{
  97450. object: any;
  97451. property: string;
  97452. value: any;
  97453. initialValue: any;
  97454. }>;
  97455. /**
  97456. * Instantiates a new debug layer.
  97457. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97458. * what is happening in your scene
  97459. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97460. * @param scene Defines the scene to inspect
  97461. */
  97462. constructor(scene: Scene);
  97463. /** Creates the inspector window. */
  97464. private _createInspector;
  97465. /**
  97466. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  97467. * @param entity defines the entity to select
  97468. * @param lineContainerTitle defines the specific block to highlight
  97469. */
  97470. select(entity: any, lineContainerTitle?: string): void;
  97471. /** Get the inspector from bundle or global */
  97472. private _getGlobalInspector;
  97473. /**
  97474. * Get if the inspector is visible or not.
  97475. * @returns true if visible otherwise, false
  97476. */
  97477. isVisible(): boolean;
  97478. /**
  97479. * Hide the inspector and close its window.
  97480. */
  97481. hide(): void;
  97482. /**
  97483. * Launch the debugLayer.
  97484. * @param config Define the configuration of the inspector
  97485. * @return a promise fulfilled when the debug layer is visible
  97486. */
  97487. show(config?: IInspectorOptions): Promise<DebugLayer>;
  97488. }
  97489. }
  97490. declare module BABYLON {
  97491. /**
  97492. * Class containing static functions to help procedurally build meshes
  97493. */
  97494. export class BoxBuilder {
  97495. /**
  97496. * Creates a box mesh
  97497. * * The parameter `size` sets the size (float) of each box side (default 1)
  97498. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  97499. * * 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)
  97500. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  97501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97504. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  97505. * @param name defines the name of the mesh
  97506. * @param options defines the options used to create the mesh
  97507. * @param scene defines the hosting scene
  97508. * @returns the box mesh
  97509. */
  97510. static CreateBox(name: string, options: {
  97511. size?: number;
  97512. width?: number;
  97513. height?: number;
  97514. depth?: number;
  97515. faceUV?: Vector4[];
  97516. faceColors?: Color4[];
  97517. sideOrientation?: number;
  97518. frontUVs?: Vector4;
  97519. backUVs?: Vector4;
  97520. updatable?: boolean;
  97521. }, scene?: Nullable<Scene>): Mesh;
  97522. }
  97523. }
  97524. declare module BABYLON {
  97525. /**
  97526. * Class containing static functions to help procedurally build meshes
  97527. */
  97528. export class SphereBuilder {
  97529. /**
  97530. * Creates a sphere mesh
  97531. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  97532. * * 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`)
  97533. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  97534. * * 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
  97535. * * 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)
  97536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97539. * @param name defines the name of the mesh
  97540. * @param options defines the options used to create the mesh
  97541. * @param scene defines the hosting scene
  97542. * @returns the sphere mesh
  97543. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  97544. */
  97545. static CreateSphere(name: string, options: {
  97546. segments?: number;
  97547. diameter?: number;
  97548. diameterX?: number;
  97549. diameterY?: number;
  97550. diameterZ?: number;
  97551. arc?: number;
  97552. slice?: number;
  97553. sideOrientation?: number;
  97554. frontUVs?: Vector4;
  97555. backUVs?: Vector4;
  97556. updatable?: boolean;
  97557. }, scene: any): Mesh;
  97558. }
  97559. }
  97560. declare module BABYLON.Debug {
  97561. /**
  97562. * Used to show the physics impostor around the specific mesh
  97563. */
  97564. export class PhysicsViewer {
  97565. /** @hidden */
  97566. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  97567. /** @hidden */
  97568. protected _meshes: Array<Nullable<AbstractMesh>>;
  97569. /** @hidden */
  97570. protected _scene: Nullable<Scene>;
  97571. /** @hidden */
  97572. protected _numMeshes: number;
  97573. /** @hidden */
  97574. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  97575. private _renderFunction;
  97576. private _utilityLayer;
  97577. private _debugBoxMesh;
  97578. private _debugSphereMesh;
  97579. private _debugMaterial;
  97580. /**
  97581. * Creates a new PhysicsViewer
  97582. * @param scene defines the hosting scene
  97583. */
  97584. constructor(scene: Scene);
  97585. /** @hidden */
  97586. protected _updateDebugMeshes(): void;
  97587. /**
  97588. * Renders a specified physic impostor
  97589. * @param impostor defines the impostor to render
  97590. * @returns the new debug mesh used to render the impostor
  97591. */
  97592. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  97593. /**
  97594. * Hides a specified physic impostor
  97595. * @param impostor defines the impostor to hide
  97596. */
  97597. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  97598. private _getDebugMaterial;
  97599. private _getDebugBoxMesh;
  97600. private _getDebugSphereMesh;
  97601. private _getDebugMesh;
  97602. /** Releases all resources */
  97603. dispose(): void;
  97604. }
  97605. }
  97606. declare module BABYLON {
  97607. /**
  97608. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97609. * in order to better appreciate the issue one might have.
  97610. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97611. */
  97612. export class RayHelper {
  97613. /**
  97614. * Defines the ray we are currently tryin to visualize.
  97615. */
  97616. ray: Nullable<Ray>;
  97617. private _renderPoints;
  97618. private _renderLine;
  97619. private _renderFunction;
  97620. private _scene;
  97621. private _updateToMeshFunction;
  97622. private _attachedToMesh;
  97623. private _meshSpaceDirection;
  97624. private _meshSpaceOrigin;
  97625. /**
  97626. * Helper function to create a colored helper in a scene in one line.
  97627. * @param ray Defines the ray we are currently tryin to visualize
  97628. * @param scene Defines the scene the ray is used in
  97629. * @param color Defines the color we want to see the ray in
  97630. * @returns The newly created ray helper.
  97631. */
  97632. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  97633. /**
  97634. * Instantiate a new ray helper.
  97635. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97636. * in order to better appreciate the issue one might have.
  97637. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97638. * @param ray Defines the ray we are currently tryin to visualize
  97639. */
  97640. constructor(ray: Ray);
  97641. /**
  97642. * Shows the ray we are willing to debug.
  97643. * @param scene Defines the scene the ray needs to be rendered in
  97644. * @param color Defines the color the ray needs to be rendered in
  97645. */
  97646. show(scene: Scene, color?: Color3): void;
  97647. /**
  97648. * Hides the ray we are debugging.
  97649. */
  97650. hide(): void;
  97651. private _render;
  97652. /**
  97653. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  97654. * @param mesh Defines the mesh we want the helper attached to
  97655. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  97656. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  97657. * @param length Defines the length of the ray
  97658. */
  97659. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  97660. /**
  97661. * Detach the ray helper from the mesh it has previously been attached to.
  97662. */
  97663. detachFromMesh(): void;
  97664. private _updateToMesh;
  97665. /**
  97666. * Dispose the helper and release its associated resources.
  97667. */
  97668. dispose(): void;
  97669. }
  97670. }
  97671. declare module BABYLON.Debug {
  97672. /**
  97673. * Class used to render a debug view of a given skeleton
  97674. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  97675. */
  97676. export class SkeletonViewer {
  97677. /** defines the skeleton to render */
  97678. skeleton: Skeleton;
  97679. /** defines the mesh attached to the skeleton */
  97680. mesh: AbstractMesh;
  97681. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97682. autoUpdateBonesMatrices: boolean;
  97683. /** defines the rendering group id to use with the viewer */
  97684. renderingGroupId: number;
  97685. /** Gets or sets the color used to render the skeleton */
  97686. color: Color3;
  97687. private _scene;
  97688. private _debugLines;
  97689. private _debugMesh;
  97690. private _isEnabled;
  97691. private _renderFunction;
  97692. private _utilityLayer;
  97693. /**
  97694. * Returns the mesh used to render the bones
  97695. */
  97696. readonly debugMesh: Nullable<LinesMesh>;
  97697. /**
  97698. * Creates a new SkeletonViewer
  97699. * @param skeleton defines the skeleton to render
  97700. * @param mesh defines the mesh attached to the skeleton
  97701. * @param scene defines the hosting scene
  97702. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  97703. * @param renderingGroupId defines the rendering group id to use with the viewer
  97704. */
  97705. constructor(
  97706. /** defines the skeleton to render */
  97707. skeleton: Skeleton,
  97708. /** defines the mesh attached to the skeleton */
  97709. mesh: AbstractMesh, scene: Scene,
  97710. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97711. autoUpdateBonesMatrices?: boolean,
  97712. /** defines the rendering group id to use with the viewer */
  97713. renderingGroupId?: number);
  97714. /** Gets or sets a boolean indicating if the viewer is enabled */
  97715. isEnabled: boolean;
  97716. private _getBonePosition;
  97717. private _getLinesForBonesWithLength;
  97718. private _getLinesForBonesNoLength;
  97719. /** Update the viewer to sync with current skeleton state */
  97720. update(): void;
  97721. /** Release associated resources */
  97722. dispose(): void;
  97723. }
  97724. }
  97725. declare module BABYLON {
  97726. /**
  97727. * Options to create the null engine
  97728. */
  97729. export class NullEngineOptions {
  97730. /**
  97731. * Render width (Default: 512)
  97732. */
  97733. renderWidth: number;
  97734. /**
  97735. * Render height (Default: 256)
  97736. */
  97737. renderHeight: number;
  97738. /**
  97739. * Texture size (Default: 512)
  97740. */
  97741. textureSize: number;
  97742. /**
  97743. * If delta time between frames should be constant
  97744. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97745. */
  97746. deterministicLockstep: boolean;
  97747. /**
  97748. * Maximum about of steps between frames (Default: 4)
  97749. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97750. */
  97751. lockstepMaxSteps: number;
  97752. }
  97753. /**
  97754. * The null engine class provides support for headless version of babylon.js.
  97755. * This can be used in server side scenario or for testing purposes
  97756. */
  97757. export class NullEngine extends Engine {
  97758. private _options;
  97759. /**
  97760. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97761. */
  97762. isDeterministicLockStep(): boolean;
  97763. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  97764. getLockstepMaxSteps(): number;
  97765. /**
  97766. * Sets hardware scaling, used to save performance if needed
  97767. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97768. */
  97769. getHardwareScalingLevel(): number;
  97770. constructor(options?: NullEngineOptions);
  97771. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97772. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  97773. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97774. getRenderWidth(useScreen?: boolean): number;
  97775. getRenderHeight(useScreen?: boolean): number;
  97776. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  97777. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  97778. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  97779. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  97780. bindSamplers(effect: Effect): void;
  97781. enableEffect(effect: Effect): void;
  97782. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97783. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  97784. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  97785. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  97786. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  97787. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  97788. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  97789. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  97790. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  97791. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  97792. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  97793. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  97794. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  97795. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  97796. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  97797. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97798. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97799. setFloat(uniform: WebGLUniformLocation, value: number): void;
  97800. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  97801. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  97802. setBool(uniform: WebGLUniformLocation, bool: number): void;
  97803. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  97804. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  97805. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  97806. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97807. bindBuffers(vertexBuffers: {
  97808. [key: string]: VertexBuffer;
  97809. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  97810. wipeCaches(bruteForce?: boolean): void;
  97811. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97812. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97813. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97814. /** @hidden */
  97815. _createTexture(): WebGLTexture;
  97816. /** @hidden */
  97817. _releaseTexture(texture: InternalTexture): void;
  97818. 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;
  97819. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97820. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97821. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  97822. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97823. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97824. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  97825. areAllEffectsReady(): boolean;
  97826. /**
  97827. * @hidden
  97828. * Get the current error code of the webGL context
  97829. * @returns the error code
  97830. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97831. */
  97832. getError(): number;
  97833. /** @hidden */
  97834. _getUnpackAlignement(): number;
  97835. /** @hidden */
  97836. _unpackFlipY(value: boolean): void;
  97837. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  97838. /**
  97839. * Updates a dynamic vertex buffer.
  97840. * @param vertexBuffer the vertex buffer to update
  97841. * @param data the data used to update the vertex buffer
  97842. * @param byteOffset the byte offset of the data (optional)
  97843. * @param byteLength the byte length of the data (optional)
  97844. */
  97845. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  97846. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  97847. /** @hidden */
  97848. _bindTexture(channel: number, texture: InternalTexture): void;
  97849. /** @hidden */
  97850. _releaseBuffer(buffer: WebGLBuffer): boolean;
  97851. releaseEffects(): void;
  97852. displayLoadingUI(): void;
  97853. hideLoadingUI(): void;
  97854. /** @hidden */
  97855. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97856. /** @hidden */
  97857. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97858. /** @hidden */
  97859. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97860. /** @hidden */
  97861. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97862. }
  97863. }
  97864. declare module BABYLON {
  97865. /** @hidden */
  97866. export class _OcclusionDataStorage {
  97867. /** @hidden */
  97868. occlusionInternalRetryCounter: number;
  97869. /** @hidden */
  97870. isOcclusionQueryInProgress: boolean;
  97871. /** @hidden */
  97872. isOccluded: boolean;
  97873. /** @hidden */
  97874. occlusionRetryCount: number;
  97875. /** @hidden */
  97876. occlusionType: number;
  97877. /** @hidden */
  97878. occlusionQueryAlgorithmType: number;
  97879. }
  97880. interface Engine {
  97881. /**
  97882. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  97883. * @return the new query
  97884. */
  97885. createQuery(): WebGLQuery;
  97886. /**
  97887. * Delete and release a webGL query
  97888. * @param query defines the query to delete
  97889. * @return the current engine
  97890. */
  97891. deleteQuery(query: WebGLQuery): Engine;
  97892. /**
  97893. * Check if a given query has resolved and got its value
  97894. * @param query defines the query to check
  97895. * @returns true if the query got its value
  97896. */
  97897. isQueryResultAvailable(query: WebGLQuery): boolean;
  97898. /**
  97899. * Gets the value of a given query
  97900. * @param query defines the query to check
  97901. * @returns the value of the query
  97902. */
  97903. getQueryResult(query: WebGLQuery): number;
  97904. /**
  97905. * Initiates an occlusion query
  97906. * @param algorithmType defines the algorithm to use
  97907. * @param query defines the query to use
  97908. * @returns the current engine
  97909. * @see http://doc.babylonjs.com/features/occlusionquery
  97910. */
  97911. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  97912. /**
  97913. * Ends an occlusion query
  97914. * @see http://doc.babylonjs.com/features/occlusionquery
  97915. * @param algorithmType defines the algorithm to use
  97916. * @returns the current engine
  97917. */
  97918. endOcclusionQuery(algorithmType: number): Engine;
  97919. /**
  97920. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  97921. * Please note that only one query can be issued at a time
  97922. * @returns a time token used to track the time span
  97923. */
  97924. startTimeQuery(): Nullable<_TimeToken>;
  97925. /**
  97926. * Ends a time query
  97927. * @param token defines the token used to measure the time span
  97928. * @returns the time spent (in ns)
  97929. */
  97930. endTimeQuery(token: _TimeToken): int;
  97931. /** @hidden */
  97932. _currentNonTimestampToken: Nullable<_TimeToken>;
  97933. /** @hidden */
  97934. _createTimeQuery(): WebGLQuery;
  97935. /** @hidden */
  97936. _deleteTimeQuery(query: WebGLQuery): void;
  97937. /** @hidden */
  97938. _getGlAlgorithmType(algorithmType: number): number;
  97939. /** @hidden */
  97940. _getTimeQueryResult(query: WebGLQuery): any;
  97941. /** @hidden */
  97942. _getTimeQueryAvailability(query: WebGLQuery): any;
  97943. }
  97944. interface AbstractMesh {
  97945. /**
  97946. * Backing filed
  97947. * @hidden
  97948. */
  97949. __occlusionDataStorage: _OcclusionDataStorage;
  97950. /**
  97951. * Access property
  97952. * @hidden
  97953. */
  97954. _occlusionDataStorage: _OcclusionDataStorage;
  97955. /**
  97956. * 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.
  97957. * The default value is -1 which means don't break the query and wait till the result
  97958. * @see http://doc.babylonjs.com/features/occlusionquery
  97959. */
  97960. occlusionRetryCount: number;
  97961. /**
  97962. * 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:
  97963. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  97964. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  97965. * * 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.
  97966. * @see http://doc.babylonjs.com/features/occlusionquery
  97967. */
  97968. occlusionType: number;
  97969. /**
  97970. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  97971. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  97972. * * 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.
  97973. * @see http://doc.babylonjs.com/features/occlusionquery
  97974. */
  97975. occlusionQueryAlgorithmType: number;
  97976. /**
  97977. * 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
  97978. * @see http://doc.babylonjs.com/features/occlusionquery
  97979. */
  97980. isOccluded: boolean;
  97981. /**
  97982. * Flag to check the progress status of the query
  97983. * @see http://doc.babylonjs.com/features/occlusionquery
  97984. */
  97985. isOcclusionQueryInProgress: boolean;
  97986. }
  97987. }
  97988. declare module BABYLON {
  97989. /** @hidden */
  97990. export var _forceTransformFeedbackToBundle: boolean;
  97991. interface Engine {
  97992. /**
  97993. * Creates a webGL transform feedback object
  97994. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  97995. * @returns the webGL transform feedback object
  97996. */
  97997. createTransformFeedback(): WebGLTransformFeedback;
  97998. /**
  97999. * Delete a webGL transform feedback object
  98000. * @param value defines the webGL transform feedback object to delete
  98001. */
  98002. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  98003. /**
  98004. * Bind a webGL transform feedback object to the webgl context
  98005. * @param value defines the webGL transform feedback object to bind
  98006. */
  98007. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  98008. /**
  98009. * Begins a transform feedback operation
  98010. * @param usePoints defines if points or triangles must be used
  98011. */
  98012. beginTransformFeedback(usePoints: boolean): void;
  98013. /**
  98014. * Ends a transform feedback operation
  98015. */
  98016. endTransformFeedback(): void;
  98017. /**
  98018. * Specify the varyings to use with transform feedback
  98019. * @param program defines the associated webGL program
  98020. * @param value defines the list of strings representing the varying names
  98021. */
  98022. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  98023. /**
  98024. * Bind a webGL buffer for a transform feedback operation
  98025. * @param value defines the webGL buffer to bind
  98026. */
  98027. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  98028. }
  98029. }
  98030. declare module BABYLON {
  98031. /**
  98032. * Gather the list of clipboard event types as constants.
  98033. */
  98034. export class ClipboardEventTypes {
  98035. /**
  98036. * The clipboard event is fired when a copy command is active (pressed).
  98037. */
  98038. static readonly COPY: number;
  98039. /**
  98040. * The clipboard event is fired when a cut command is active (pressed).
  98041. */
  98042. static readonly CUT: number;
  98043. /**
  98044. * The clipboard event is fired when a paste command is active (pressed).
  98045. */
  98046. static readonly PASTE: number;
  98047. }
  98048. /**
  98049. * This class is used to store clipboard related info for the onClipboardObservable event.
  98050. */
  98051. export class ClipboardInfo {
  98052. /**
  98053. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98054. */
  98055. type: number;
  98056. /**
  98057. * Defines the related dom event
  98058. */
  98059. event: ClipboardEvent;
  98060. /**
  98061. *Creates an instance of ClipboardInfo.
  98062. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  98063. * @param event Defines the related dom event
  98064. */
  98065. constructor(
  98066. /**
  98067. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98068. */
  98069. type: number,
  98070. /**
  98071. * Defines the related dom event
  98072. */
  98073. event: ClipboardEvent);
  98074. /**
  98075. * Get the clipboard event's type from the keycode.
  98076. * @param keyCode Defines the keyCode for the current keyboard event.
  98077. * @return {number}
  98078. */
  98079. static GetTypeFromCharacter(keyCode: number): number;
  98080. }
  98081. }
  98082. declare module BABYLON {
  98083. /**
  98084. * Class used to represent data loading progression
  98085. */
  98086. export class SceneLoaderProgressEvent {
  98087. /** defines if data length to load can be evaluated */
  98088. readonly lengthComputable: boolean;
  98089. /** defines the loaded data length */
  98090. readonly loaded: number;
  98091. /** defines the data length to load */
  98092. readonly total: number;
  98093. /**
  98094. * Create a new progress event
  98095. * @param lengthComputable defines if data length to load can be evaluated
  98096. * @param loaded defines the loaded data length
  98097. * @param total defines the data length to load
  98098. */
  98099. constructor(
  98100. /** defines if data length to load can be evaluated */
  98101. lengthComputable: boolean,
  98102. /** defines the loaded data length */
  98103. loaded: number,
  98104. /** defines the data length to load */
  98105. total: number);
  98106. /**
  98107. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98108. * @param event defines the source event
  98109. * @returns a new SceneLoaderProgressEvent
  98110. */
  98111. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98112. }
  98113. /**
  98114. * Interface used by SceneLoader plugins to define supported file extensions
  98115. */
  98116. export interface ISceneLoaderPluginExtensions {
  98117. /**
  98118. * Defines the list of supported extensions
  98119. */
  98120. [extension: string]: {
  98121. isBinary: boolean;
  98122. };
  98123. }
  98124. /**
  98125. * Interface used by SceneLoader plugin factory
  98126. */
  98127. export interface ISceneLoaderPluginFactory {
  98128. /**
  98129. * Defines the name of the factory
  98130. */
  98131. name: string;
  98132. /**
  98133. * Function called to create a new plugin
  98134. * @return the new plugin
  98135. */
  98136. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98137. /**
  98138. * Boolean indicating if the plugin can direct load specific data
  98139. */
  98140. canDirectLoad?: (data: string) => boolean;
  98141. }
  98142. /**
  98143. * Interface used to define a SceneLoader plugin
  98144. */
  98145. export interface ISceneLoaderPlugin {
  98146. /**
  98147. * The friendly name of this plugin.
  98148. */
  98149. name: string;
  98150. /**
  98151. * The file extensions supported by this plugin.
  98152. */
  98153. extensions: string | ISceneLoaderPluginExtensions;
  98154. /**
  98155. * Import meshes into a scene.
  98156. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98157. * @param scene The scene to import into
  98158. * @param data The data to import
  98159. * @param rootUrl The root url for scene and resources
  98160. * @param meshes The meshes array to import into
  98161. * @param particleSystems The particle systems array to import into
  98162. * @param skeletons The skeletons array to import into
  98163. * @param onError The callback when import fails
  98164. * @returns True if successful or false otherwise
  98165. */
  98166. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98167. /**
  98168. * Load into a scene.
  98169. * @param scene The scene to load into
  98170. * @param data The data to import
  98171. * @param rootUrl The root url for scene and resources
  98172. * @param onError The callback when import fails
  98173. * @returns true if successful or false otherwise
  98174. */
  98175. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98176. /**
  98177. * The callback that returns true if the data can be directly loaded.
  98178. */
  98179. canDirectLoad?: (data: string) => boolean;
  98180. /**
  98181. * The callback that allows custom handling of the root url based on the response url.
  98182. */
  98183. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98184. /**
  98185. * Load into an asset container.
  98186. * @param scene The scene to load into
  98187. * @param data The data to import
  98188. * @param rootUrl The root url for scene and resources
  98189. * @param onError The callback when import fails
  98190. * @returns The loaded asset container
  98191. */
  98192. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98193. }
  98194. /**
  98195. * Interface used to define an async SceneLoader plugin
  98196. */
  98197. export interface ISceneLoaderPluginAsync {
  98198. /**
  98199. * The friendly name of this plugin.
  98200. */
  98201. name: string;
  98202. /**
  98203. * The file extensions supported by this plugin.
  98204. */
  98205. extensions: string | ISceneLoaderPluginExtensions;
  98206. /**
  98207. * Import meshes into a scene.
  98208. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98209. * @param scene The scene to import into
  98210. * @param data The data to import
  98211. * @param rootUrl The root url for scene and resources
  98212. * @param onProgress The callback when the load progresses
  98213. * @param fileName Defines the name of the file to load
  98214. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98215. */
  98216. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98217. meshes: AbstractMesh[];
  98218. particleSystems: IParticleSystem[];
  98219. skeletons: Skeleton[];
  98220. animationGroups: AnimationGroup[];
  98221. }>;
  98222. /**
  98223. * Load into a scene.
  98224. * @param scene The scene to load into
  98225. * @param data The data to import
  98226. * @param rootUrl The root url for scene and resources
  98227. * @param onProgress The callback when the load progresses
  98228. * @param fileName Defines the name of the file to load
  98229. * @returns Nothing
  98230. */
  98231. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98232. /**
  98233. * The callback that returns true if the data can be directly loaded.
  98234. */
  98235. canDirectLoad?: (data: string) => boolean;
  98236. /**
  98237. * The callback that allows custom handling of the root url based on the response url.
  98238. */
  98239. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98240. /**
  98241. * Load into an asset container.
  98242. * @param scene The scene to load into
  98243. * @param data The data to import
  98244. * @param rootUrl The root url for scene and resources
  98245. * @param onProgress The callback when the load progresses
  98246. * @param fileName Defines the name of the file to load
  98247. * @returns The loaded asset container
  98248. */
  98249. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98250. }
  98251. /**
  98252. * Class used to load scene from various file formats using registered plugins
  98253. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98254. */
  98255. export class SceneLoader {
  98256. /**
  98257. * No logging while loading
  98258. */
  98259. static readonly NO_LOGGING: number;
  98260. /**
  98261. * Minimal logging while loading
  98262. */
  98263. static readonly MINIMAL_LOGGING: number;
  98264. /**
  98265. * Summary logging while loading
  98266. */
  98267. static readonly SUMMARY_LOGGING: number;
  98268. /**
  98269. * Detailled logging while loading
  98270. */
  98271. static readonly DETAILED_LOGGING: number;
  98272. /**
  98273. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98274. */
  98275. static ForceFullSceneLoadingForIncremental: boolean;
  98276. /**
  98277. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98278. */
  98279. static ShowLoadingScreen: boolean;
  98280. /**
  98281. * Defines the current logging level (while loading the scene)
  98282. * @ignorenaming
  98283. */
  98284. static loggingLevel: number;
  98285. /**
  98286. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98287. */
  98288. static CleanBoneMatrixWeights: boolean;
  98289. /**
  98290. * Event raised when a plugin is used to load a scene
  98291. */
  98292. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98293. private static _registeredPlugins;
  98294. private static _getDefaultPlugin;
  98295. private static _getPluginForExtension;
  98296. private static _getPluginForDirectLoad;
  98297. private static _getPluginForFilename;
  98298. private static _getDirectLoad;
  98299. private static _loadData;
  98300. private static _getFileInfo;
  98301. /**
  98302. * Gets a plugin that can load the given extension
  98303. * @param extension defines the extension to load
  98304. * @returns a plugin or null if none works
  98305. */
  98306. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98307. /**
  98308. * Gets a boolean indicating that the given extension can be loaded
  98309. * @param extension defines the extension to load
  98310. * @returns true if the extension is supported
  98311. */
  98312. static IsPluginForExtensionAvailable(extension: string): boolean;
  98313. /**
  98314. * Adds a new plugin to the list of registered plugins
  98315. * @param plugin defines the plugin to add
  98316. */
  98317. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98318. /**
  98319. * Import meshes into a scene
  98320. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98321. * @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)
  98322. * @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)
  98323. * @param scene the instance of BABYLON.Scene to append to
  98324. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98325. * @param onProgress a callback with a progress event for each file being loaded
  98326. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98327. * @param pluginExtension the extension used to determine the plugin
  98328. * @returns The loaded plugin
  98329. */
  98330. 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>;
  98331. /**
  98332. * Import meshes into a scene
  98333. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98334. * @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)
  98335. * @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)
  98336. * @param scene the instance of BABYLON.Scene to append to
  98337. * @param onProgress a callback with a progress event for each file being loaded
  98338. * @param pluginExtension the extension used to determine the plugin
  98339. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98340. */
  98341. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98342. meshes: AbstractMesh[];
  98343. particleSystems: IParticleSystem[];
  98344. skeletons: Skeleton[];
  98345. animationGroups: AnimationGroup[];
  98346. }>;
  98347. /**
  98348. * Load a scene
  98349. * @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)
  98350. * @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)
  98351. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98352. * @param onSuccess a callback with the scene when import succeeds
  98353. * @param onProgress a callback with a progress event for each file being loaded
  98354. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98355. * @param pluginExtension the extension used to determine the plugin
  98356. * @returns The loaded plugin
  98357. */
  98358. 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>;
  98359. /**
  98360. * Load a scene
  98361. * @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)
  98362. * @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)
  98363. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98364. * @param onProgress a callback with a progress event for each file being loaded
  98365. * @param pluginExtension the extension used to determine the plugin
  98366. * @returns The loaded scene
  98367. */
  98368. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98369. /**
  98370. * Append a scene
  98371. * @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)
  98372. * @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)
  98373. * @param scene is the instance of BABYLON.Scene to append to
  98374. * @param onSuccess a callback with the scene when import succeeds
  98375. * @param onProgress a callback with a progress event for each file being loaded
  98376. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98377. * @param pluginExtension the extension used to determine the plugin
  98378. * @returns The loaded plugin
  98379. */
  98380. 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>;
  98381. /**
  98382. * Append a scene
  98383. * @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)
  98384. * @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)
  98385. * @param scene is the instance of BABYLON.Scene to append to
  98386. * @param onProgress a callback with a progress event for each file being loaded
  98387. * @param pluginExtension the extension used to determine the plugin
  98388. * @returns The given scene
  98389. */
  98390. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98391. /**
  98392. * Load a scene into an asset container
  98393. * @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)
  98394. * @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)
  98395. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  98396. * @param onSuccess a callback with the scene when import succeeds
  98397. * @param onProgress a callback with a progress event for each file being loaded
  98398. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98399. * @param pluginExtension the extension used to determine the plugin
  98400. * @returns The loaded plugin
  98401. */
  98402. 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>;
  98403. /**
  98404. * Load a scene into an asset container
  98405. * @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)
  98406. * @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)
  98407. * @param scene is the instance of Scene to append to
  98408. * @param onProgress a callback with a progress event for each file being loaded
  98409. * @param pluginExtension the extension used to determine the plugin
  98410. * @returns The loaded asset container
  98411. */
  98412. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  98413. }
  98414. }
  98415. declare module BABYLON {
  98416. /**
  98417. * Google Daydream controller
  98418. */
  98419. export class DaydreamController extends WebVRController {
  98420. /**
  98421. * Base Url for the controller model.
  98422. */
  98423. static MODEL_BASE_URL: string;
  98424. /**
  98425. * File name for the controller model.
  98426. */
  98427. static MODEL_FILENAME: string;
  98428. /**
  98429. * Gamepad Id prefix used to identify Daydream Controller.
  98430. */
  98431. static readonly GAMEPAD_ID_PREFIX: string;
  98432. /**
  98433. * Creates a new DaydreamController from a gamepad
  98434. * @param vrGamepad the gamepad that the controller should be created from
  98435. */
  98436. constructor(vrGamepad: any);
  98437. /**
  98438. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98439. * @param scene scene in which to add meshes
  98440. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98441. */
  98442. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98443. /**
  98444. * Called once for each button that changed state since the last frame
  98445. * @param buttonIdx Which button index changed
  98446. * @param state New state of the button
  98447. * @param changes Which properties on the state changed since last frame
  98448. */
  98449. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98450. }
  98451. }
  98452. declare module BABYLON {
  98453. /**
  98454. * Gear VR Controller
  98455. */
  98456. export class GearVRController extends WebVRController {
  98457. /**
  98458. * Base Url for the controller model.
  98459. */
  98460. static MODEL_BASE_URL: string;
  98461. /**
  98462. * File name for the controller model.
  98463. */
  98464. static MODEL_FILENAME: string;
  98465. /**
  98466. * Gamepad Id prefix used to identify this controller.
  98467. */
  98468. static readonly GAMEPAD_ID_PREFIX: string;
  98469. private readonly _buttonIndexToObservableNameMap;
  98470. /**
  98471. * Creates a new GearVRController from a gamepad
  98472. * @param vrGamepad the gamepad that the controller should be created from
  98473. */
  98474. constructor(vrGamepad: any);
  98475. /**
  98476. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98477. * @param scene scene in which to add meshes
  98478. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98479. */
  98480. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98481. /**
  98482. * Called once for each button that changed state since the last frame
  98483. * @param buttonIdx Which button index changed
  98484. * @param state New state of the button
  98485. * @param changes Which properties on the state changed since last frame
  98486. */
  98487. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98488. }
  98489. }
  98490. declare module BABYLON {
  98491. /**
  98492. * Generic Controller
  98493. */
  98494. export class GenericController extends WebVRController {
  98495. /**
  98496. * Base Url for the controller model.
  98497. */
  98498. static readonly MODEL_BASE_URL: string;
  98499. /**
  98500. * File name for the controller model.
  98501. */
  98502. static readonly MODEL_FILENAME: string;
  98503. /**
  98504. * Creates a new GenericController from a gamepad
  98505. * @param vrGamepad the gamepad that the controller should be created from
  98506. */
  98507. constructor(vrGamepad: any);
  98508. /**
  98509. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98510. * @param scene scene in which to add meshes
  98511. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98512. */
  98513. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98514. /**
  98515. * Called once for each button that changed state since the last frame
  98516. * @param buttonIdx Which button index changed
  98517. * @param state New state of the button
  98518. * @param changes Which properties on the state changed since last frame
  98519. */
  98520. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98521. }
  98522. }
  98523. declare module BABYLON {
  98524. /**
  98525. * Oculus Touch Controller
  98526. */
  98527. export class OculusTouchController extends WebVRController {
  98528. /**
  98529. * Base Url for the controller model.
  98530. */
  98531. static MODEL_BASE_URL: string;
  98532. /**
  98533. * File name for the left controller model.
  98534. */
  98535. static MODEL_LEFT_FILENAME: string;
  98536. /**
  98537. * File name for the right controller model.
  98538. */
  98539. static MODEL_RIGHT_FILENAME: string;
  98540. /**
  98541. * Fired when the secondary trigger on this controller is modified
  98542. */
  98543. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98544. /**
  98545. * Fired when the thumb rest on this controller is modified
  98546. */
  98547. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  98548. /**
  98549. * Creates a new OculusTouchController from a gamepad
  98550. * @param vrGamepad the gamepad that the controller should be created from
  98551. */
  98552. constructor(vrGamepad: any);
  98553. /**
  98554. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98555. * @param scene scene in which to add meshes
  98556. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98557. */
  98558. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98559. /**
  98560. * Fired when the A button on this controller is modified
  98561. */
  98562. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98563. /**
  98564. * Fired when the B button on this controller is modified
  98565. */
  98566. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98567. /**
  98568. * Fired when the X button on this controller is modified
  98569. */
  98570. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98571. /**
  98572. * Fired when the Y button on this controller is modified
  98573. */
  98574. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98575. /**
  98576. * Called once for each button that changed state since the last frame
  98577. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  98578. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  98579. * 2) secondary trigger (same)
  98580. * 3) A (right) X (left), touch, pressed = value
  98581. * 4) B / Y
  98582. * 5) thumb rest
  98583. * @param buttonIdx Which button index changed
  98584. * @param state New state of the button
  98585. * @param changes Which properties on the state changed since last frame
  98586. */
  98587. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98588. }
  98589. }
  98590. declare module BABYLON {
  98591. /**
  98592. * Vive Controller
  98593. */
  98594. export class ViveController extends WebVRController {
  98595. /**
  98596. * Base Url for the controller model.
  98597. */
  98598. static MODEL_BASE_URL: string;
  98599. /**
  98600. * File name for the controller model.
  98601. */
  98602. static MODEL_FILENAME: string;
  98603. /**
  98604. * Creates a new ViveController from a gamepad
  98605. * @param vrGamepad the gamepad that the controller should be created from
  98606. */
  98607. constructor(vrGamepad: any);
  98608. /**
  98609. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98610. * @param scene scene in which to add meshes
  98611. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98612. */
  98613. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98614. /**
  98615. * Fired when the left button on this controller is modified
  98616. */
  98617. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98618. /**
  98619. * Fired when the right button on this controller is modified
  98620. */
  98621. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98622. /**
  98623. * Fired when the menu button on this controller is modified
  98624. */
  98625. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98626. /**
  98627. * Called once for each button that changed state since the last frame
  98628. * Vive mapping:
  98629. * 0: touchpad
  98630. * 1: trigger
  98631. * 2: left AND right buttons
  98632. * 3: menu button
  98633. * @param buttonIdx Which button index changed
  98634. * @param state New state of the button
  98635. * @param changes Which properties on the state changed since last frame
  98636. */
  98637. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98638. }
  98639. }
  98640. declare module BABYLON {
  98641. /**
  98642. * Defines the WindowsMotionController object that the state of the windows motion controller
  98643. */
  98644. export class WindowsMotionController extends WebVRController {
  98645. /**
  98646. * The base url used to load the left and right controller models
  98647. */
  98648. static MODEL_BASE_URL: string;
  98649. /**
  98650. * The name of the left controller model file
  98651. */
  98652. static MODEL_LEFT_FILENAME: string;
  98653. /**
  98654. * The name of the right controller model file
  98655. */
  98656. static MODEL_RIGHT_FILENAME: string;
  98657. /**
  98658. * The controller name prefix for this controller type
  98659. */
  98660. static readonly GAMEPAD_ID_PREFIX: string;
  98661. /**
  98662. * The controller id pattern for this controller type
  98663. */
  98664. private static readonly GAMEPAD_ID_PATTERN;
  98665. private _loadedMeshInfo;
  98666. private readonly _mapping;
  98667. /**
  98668. * Fired when the trackpad on this controller is clicked
  98669. */
  98670. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  98671. /**
  98672. * Fired when the trackpad on this controller is modified
  98673. */
  98674. onTrackpadValuesChangedObservable: Observable<StickValues>;
  98675. /**
  98676. * The current x and y values of this controller's trackpad
  98677. */
  98678. trackpad: StickValues;
  98679. /**
  98680. * Creates a new WindowsMotionController from a gamepad
  98681. * @param vrGamepad the gamepad that the controller should be created from
  98682. */
  98683. constructor(vrGamepad: any);
  98684. /**
  98685. * Fired when the trigger on this controller is modified
  98686. */
  98687. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98688. /**
  98689. * Fired when the menu button on this controller is modified
  98690. */
  98691. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98692. /**
  98693. * Fired when the grip button on this controller is modified
  98694. */
  98695. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98696. /**
  98697. * Fired when the thumbstick button on this controller is modified
  98698. */
  98699. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98700. /**
  98701. * Fired when the touchpad button on this controller is modified
  98702. */
  98703. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98704. /**
  98705. * Fired when the touchpad values on this controller are modified
  98706. */
  98707. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  98708. private _updateTrackpad;
  98709. /**
  98710. * Called once per frame by the engine.
  98711. */
  98712. update(): void;
  98713. /**
  98714. * Called once for each button that changed state since the last frame
  98715. * @param buttonIdx Which button index changed
  98716. * @param state New state of the button
  98717. * @param changes Which properties on the state changed since last frame
  98718. */
  98719. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98720. /**
  98721. * Moves the buttons on the controller mesh based on their current state
  98722. * @param buttonName the name of the button to move
  98723. * @param buttonValue the value of the button which determines the buttons new position
  98724. */
  98725. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  98726. /**
  98727. * Moves the axis on the controller mesh based on its current state
  98728. * @param axis the index of the axis
  98729. * @param axisValue the value of the axis which determines the meshes new position
  98730. * @hidden
  98731. */
  98732. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  98733. /**
  98734. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98735. * @param scene scene in which to add meshes
  98736. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98737. */
  98738. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  98739. /**
  98740. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  98741. * can be transformed by button presses and axes values, based on this._mapping.
  98742. *
  98743. * @param scene scene in which the meshes exist
  98744. * @param meshes list of meshes that make up the controller model to process
  98745. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  98746. */
  98747. private processModel;
  98748. private createMeshInfo;
  98749. /**
  98750. * Gets the ray of the controller in the direction the controller is pointing
  98751. * @param length the length the resulting ray should be
  98752. * @returns a ray in the direction the controller is pointing
  98753. */
  98754. getForwardRay(length?: number): Ray;
  98755. /**
  98756. * Disposes of the controller
  98757. */
  98758. dispose(): void;
  98759. }
  98760. }
  98761. declare module BABYLON {
  98762. /**
  98763. * Single axis scale gizmo
  98764. */
  98765. export class AxisScaleGizmo extends Gizmo {
  98766. private _coloredMaterial;
  98767. /**
  98768. * Drag behavior responsible for the gizmos dragging interactions
  98769. */
  98770. dragBehavior: PointerDragBehavior;
  98771. private _pointerObserver;
  98772. /**
  98773. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98774. */
  98775. snapDistance: number;
  98776. /**
  98777. * Event that fires each time the gizmo snaps to a new location.
  98778. * * snapDistance is the the change in distance
  98779. */
  98780. onSnapObservable: Observable<{
  98781. snapDistance: number;
  98782. }>;
  98783. /**
  98784. * If the scaling operation should be done on all axis (default: false)
  98785. */
  98786. uniformScaling: boolean;
  98787. /**
  98788. * Creates an AxisScaleGizmo
  98789. * @param gizmoLayer The utility layer the gizmo will be added to
  98790. * @param dragAxis The axis which the gizmo will be able to scale on
  98791. * @param color The color of the gizmo
  98792. */
  98793. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98794. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98795. /**
  98796. * Disposes of the gizmo
  98797. */
  98798. dispose(): void;
  98799. /**
  98800. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  98801. * @param mesh The mesh to replace the default mesh of the gizmo
  98802. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  98803. */
  98804. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  98805. }
  98806. }
  98807. declare module BABYLON {
  98808. /**
  98809. * Bounding box gizmo
  98810. */
  98811. export class BoundingBoxGizmo extends Gizmo {
  98812. private _lineBoundingBox;
  98813. private _rotateSpheresParent;
  98814. private _scaleBoxesParent;
  98815. private _boundingDimensions;
  98816. private _renderObserver;
  98817. private _pointerObserver;
  98818. private _scaleDragSpeed;
  98819. private _tmpQuaternion;
  98820. private _tmpVector;
  98821. private _tmpRotationMatrix;
  98822. /**
  98823. * 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)
  98824. */
  98825. ignoreChildren: boolean;
  98826. /**
  98827. * 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)
  98828. */
  98829. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  98830. /**
  98831. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  98832. */
  98833. rotationSphereSize: number;
  98834. /**
  98835. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  98836. */
  98837. scaleBoxSize: number;
  98838. /**
  98839. * 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)
  98840. */
  98841. fixedDragMeshScreenSize: boolean;
  98842. /**
  98843. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  98844. */
  98845. fixedDragMeshScreenSizeDistanceFactor: number;
  98846. /**
  98847. * Fired when a rotation sphere or scale box is dragged
  98848. */
  98849. onDragStartObservable: Observable<{}>;
  98850. /**
  98851. * Fired when a scale box is dragged
  98852. */
  98853. onScaleBoxDragObservable: Observable<{}>;
  98854. /**
  98855. * Fired when a scale box drag is ended
  98856. */
  98857. onScaleBoxDragEndObservable: Observable<{}>;
  98858. /**
  98859. * Fired when a rotation sphere is dragged
  98860. */
  98861. onRotationSphereDragObservable: Observable<{}>;
  98862. /**
  98863. * Fired when a rotation sphere drag is ended
  98864. */
  98865. onRotationSphereDragEndObservable: Observable<{}>;
  98866. /**
  98867. * 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)
  98868. */
  98869. scalePivot: Nullable<Vector3>;
  98870. private _anchorMesh;
  98871. private _existingMeshScale;
  98872. private _dragMesh;
  98873. private pointerDragBehavior;
  98874. private coloredMaterial;
  98875. private hoverColoredMaterial;
  98876. /**
  98877. * Sets the color of the bounding box gizmo
  98878. * @param color the color to set
  98879. */
  98880. setColor(color: Color3): void;
  98881. /**
  98882. * Creates an BoundingBoxGizmo
  98883. * @param gizmoLayer The utility layer the gizmo will be added to
  98884. * @param color The color of the gizmo
  98885. */
  98886. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98887. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98888. private _selectNode;
  98889. /**
  98890. * Updates the bounding box information for the Gizmo
  98891. */
  98892. updateBoundingBox(): void;
  98893. private _updateRotationSpheres;
  98894. private _updateScaleBoxes;
  98895. /**
  98896. * Enables rotation on the specified axis and disables rotation on the others
  98897. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  98898. */
  98899. setEnabledRotationAxis(axis: string): void;
  98900. /**
  98901. * Enables/disables scaling
  98902. * @param enable if scaling should be enabled
  98903. */
  98904. setEnabledScaling(enable: boolean): void;
  98905. private _updateDummy;
  98906. /**
  98907. * Enables a pointer drag behavior on the bounding box of the gizmo
  98908. */
  98909. enableDragBehavior(): void;
  98910. /**
  98911. * Disposes of the gizmo
  98912. */
  98913. dispose(): void;
  98914. /**
  98915. * 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)
  98916. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  98917. * @returns the bounding box mesh with the passed in mesh as a child
  98918. */
  98919. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  98920. /**
  98921. * CustomMeshes are not supported by this gizmo
  98922. * @param mesh The mesh to replace the default mesh of the gizmo
  98923. */
  98924. setCustomMesh(mesh: Mesh): void;
  98925. }
  98926. }
  98927. declare module BABYLON {
  98928. /**
  98929. * Single plane rotation gizmo
  98930. */
  98931. export class PlaneRotationGizmo extends Gizmo {
  98932. /**
  98933. * Drag behavior responsible for the gizmos dragging interactions
  98934. */
  98935. dragBehavior: PointerDragBehavior;
  98936. private _pointerObserver;
  98937. /**
  98938. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  98939. */
  98940. snapDistance: number;
  98941. /**
  98942. * Event that fires each time the gizmo snaps to a new location.
  98943. * * snapDistance is the the change in distance
  98944. */
  98945. onSnapObservable: Observable<{
  98946. snapDistance: number;
  98947. }>;
  98948. /**
  98949. * Creates a PlaneRotationGizmo
  98950. * @param gizmoLayer The utility layer the gizmo will be added to
  98951. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  98952. * @param color The color of the gizmo
  98953. * @param tessellation Amount of tessellation to be used when creating rotation circles
  98954. */
  98955. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  98956. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98957. /**
  98958. * Disposes of the gizmo
  98959. */
  98960. dispose(): void;
  98961. }
  98962. }
  98963. declare module BABYLON {
  98964. /**
  98965. * Gizmo that enables rotating a mesh along 3 axis
  98966. */
  98967. export class RotationGizmo extends Gizmo {
  98968. /**
  98969. * Internal gizmo used for interactions on the x axis
  98970. */
  98971. xGizmo: PlaneRotationGizmo;
  98972. /**
  98973. * Internal gizmo used for interactions on the y axis
  98974. */
  98975. yGizmo: PlaneRotationGizmo;
  98976. /**
  98977. * Internal gizmo used for interactions on the z axis
  98978. */
  98979. zGizmo: PlaneRotationGizmo;
  98980. /** Fires an event when any of it's sub gizmos are dragged */
  98981. onDragStartObservable: Observable<{}>;
  98982. /** Fires an event when any of it's sub gizmos are released from dragging */
  98983. onDragEndObservable: Observable<{}>;
  98984. attachedMesh: Nullable<AbstractMesh>;
  98985. /**
  98986. * Creates a RotationGizmo
  98987. * @param gizmoLayer The utility layer the gizmo will be added to
  98988. * @param tessellation Amount of tessellation to be used when creating rotation circles
  98989. */
  98990. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  98991. updateGizmoRotationToMatchAttachedMesh: boolean;
  98992. /**
  98993. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98994. */
  98995. snapDistance: number;
  98996. /**
  98997. * Ratio for the scale of the gizmo (Default: 1)
  98998. */
  98999. scaleRatio: number;
  99000. /**
  99001. * Disposes of the gizmo
  99002. */
  99003. dispose(): void;
  99004. /**
  99005. * CustomMeshes are not supported by this gizmo
  99006. * @param mesh The mesh to replace the default mesh of the gizmo
  99007. */
  99008. setCustomMesh(mesh: Mesh): void;
  99009. }
  99010. }
  99011. declare module BABYLON {
  99012. /**
  99013. * Gizmo that enables dragging a mesh along 3 axis
  99014. */
  99015. export class PositionGizmo extends Gizmo {
  99016. /**
  99017. * Internal gizmo used for interactions on the x axis
  99018. */
  99019. xGizmo: AxisDragGizmo;
  99020. /**
  99021. * Internal gizmo used for interactions on the y axis
  99022. */
  99023. yGizmo: AxisDragGizmo;
  99024. /**
  99025. * Internal gizmo used for interactions on the z axis
  99026. */
  99027. zGizmo: AxisDragGizmo;
  99028. /** Fires an event when any of it's sub gizmos are dragged */
  99029. onDragStartObservable: Observable<{}>;
  99030. /** Fires an event when any of it's sub gizmos are released from dragging */
  99031. onDragEndObservable: Observable<{}>;
  99032. attachedMesh: Nullable<AbstractMesh>;
  99033. /**
  99034. * Creates a PositionGizmo
  99035. * @param gizmoLayer The utility layer the gizmo will be added to
  99036. */
  99037. constructor(gizmoLayer?: UtilityLayerRenderer);
  99038. updateGizmoRotationToMatchAttachedMesh: boolean;
  99039. /**
  99040. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99041. */
  99042. snapDistance: number;
  99043. /**
  99044. * Ratio for the scale of the gizmo (Default: 1)
  99045. */
  99046. scaleRatio: number;
  99047. /**
  99048. * Disposes of the gizmo
  99049. */
  99050. dispose(): void;
  99051. /**
  99052. * CustomMeshes are not supported by this gizmo
  99053. * @param mesh The mesh to replace the default mesh of the gizmo
  99054. */
  99055. setCustomMesh(mesh: Mesh): void;
  99056. }
  99057. }
  99058. declare module BABYLON {
  99059. /**
  99060. * Class containing static functions to help procedurally build meshes
  99061. */
  99062. export class PolyhedronBuilder {
  99063. /**
  99064. * Creates a polyhedron mesh
  99065. * * 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
  99066. * * The parameter `size` (positive float, default 1) sets the polygon size
  99067. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99068. * * 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`
  99069. * * 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
  99070. * * 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)`)
  99071. * * 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
  99072. * * 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
  99073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99076. * @param name defines the name of the mesh
  99077. * @param options defines the options used to create the mesh
  99078. * @param scene defines the hosting scene
  99079. * @returns the polyhedron mesh
  99080. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99081. */
  99082. static CreatePolyhedron(name: string, options: {
  99083. type?: number;
  99084. size?: number;
  99085. sizeX?: number;
  99086. sizeY?: number;
  99087. sizeZ?: number;
  99088. custom?: any;
  99089. faceUV?: Vector4[];
  99090. faceColors?: Color4[];
  99091. flat?: boolean;
  99092. updatable?: boolean;
  99093. sideOrientation?: number;
  99094. frontUVs?: Vector4;
  99095. backUVs?: Vector4;
  99096. }, scene: Scene): Mesh;
  99097. }
  99098. }
  99099. declare module BABYLON {
  99100. /**
  99101. * Gizmo that enables scaling a mesh along 3 axis
  99102. */
  99103. export class ScaleGizmo extends Gizmo {
  99104. /**
  99105. * Internal gizmo used for interactions on the x axis
  99106. */
  99107. xGizmo: AxisScaleGizmo;
  99108. /**
  99109. * Internal gizmo used for interactions on the y axis
  99110. */
  99111. yGizmo: AxisScaleGizmo;
  99112. /**
  99113. * Internal gizmo used for interactions on the z axis
  99114. */
  99115. zGizmo: AxisScaleGizmo;
  99116. /**
  99117. * Internal gizmo used to scale all axis equally
  99118. */
  99119. uniformScaleGizmo: AxisScaleGizmo;
  99120. /** Fires an event when any of it's sub gizmos are dragged */
  99121. onDragStartObservable: Observable<{}>;
  99122. /** Fires an event when any of it's sub gizmos are released from dragging */
  99123. onDragEndObservable: Observable<{}>;
  99124. attachedMesh: Nullable<AbstractMesh>;
  99125. /**
  99126. * Creates a ScaleGizmo
  99127. * @param gizmoLayer The utility layer the gizmo will be added to
  99128. */
  99129. constructor(gizmoLayer?: UtilityLayerRenderer);
  99130. updateGizmoRotationToMatchAttachedMesh: boolean;
  99131. /**
  99132. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99133. */
  99134. snapDistance: number;
  99135. /**
  99136. * Ratio for the scale of the gizmo (Default: 1)
  99137. */
  99138. scaleRatio: number;
  99139. /**
  99140. * Disposes of the gizmo
  99141. */
  99142. dispose(): void;
  99143. }
  99144. }
  99145. declare module BABYLON {
  99146. /**
  99147. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99148. */
  99149. export class GizmoManager implements IDisposable {
  99150. private scene;
  99151. /**
  99152. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99153. */
  99154. gizmos: {
  99155. positionGizmo: Nullable<PositionGizmo>;
  99156. rotationGizmo: Nullable<RotationGizmo>;
  99157. scaleGizmo: Nullable<ScaleGizmo>;
  99158. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99159. };
  99160. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99161. clearGizmoOnEmptyPointerEvent: boolean;
  99162. /** Fires an event when the manager is attached to a mesh */
  99163. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99164. private _gizmosEnabled;
  99165. private _pointerObserver;
  99166. private _attachedMesh;
  99167. private _boundingBoxColor;
  99168. private _defaultUtilityLayer;
  99169. private _defaultKeepDepthUtilityLayer;
  99170. /**
  99171. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99172. */
  99173. boundingBoxDragBehavior: SixDofDragBehavior;
  99174. /**
  99175. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99176. */
  99177. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99178. /**
  99179. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99180. */
  99181. usePointerToAttachGizmos: boolean;
  99182. /**
  99183. * Instatiates a gizmo manager
  99184. * @param scene the scene to overlay the gizmos on top of
  99185. */
  99186. constructor(scene: Scene);
  99187. /**
  99188. * Attaches a set of gizmos to the specified mesh
  99189. * @param mesh The mesh the gizmo's should be attached to
  99190. */
  99191. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99192. /**
  99193. * If the position gizmo is enabled
  99194. */
  99195. positionGizmoEnabled: boolean;
  99196. /**
  99197. * If the rotation gizmo is enabled
  99198. */
  99199. rotationGizmoEnabled: boolean;
  99200. /**
  99201. * If the scale gizmo is enabled
  99202. */
  99203. scaleGizmoEnabled: boolean;
  99204. /**
  99205. * If the boundingBox gizmo is enabled
  99206. */
  99207. boundingBoxGizmoEnabled: boolean;
  99208. /**
  99209. * Disposes of the gizmo manager
  99210. */
  99211. dispose(): void;
  99212. }
  99213. }
  99214. declare module BABYLON {
  99215. /**
  99216. * Gizmo that enables viewing a light
  99217. */
  99218. export class LightGizmo extends Gizmo {
  99219. private _box;
  99220. /**
  99221. * Creates a LightGizmo
  99222. * @param gizmoLayer The utility layer the gizmo will be added to
  99223. */
  99224. constructor(gizmoLayer?: UtilityLayerRenderer);
  99225. private _light;
  99226. /**
  99227. * The light that the gizmo is attached to
  99228. */
  99229. light: Nullable<Light>;
  99230. /**
  99231. * @hidden
  99232. * Updates the gizmo to match the attached mesh's position/rotation
  99233. */
  99234. protected _update(): void;
  99235. }
  99236. }
  99237. declare module BABYLON {
  99238. /** @hidden */
  99239. export var backgroundFragmentDeclaration: {
  99240. name: string;
  99241. shader: string;
  99242. };
  99243. }
  99244. declare module BABYLON {
  99245. /** @hidden */
  99246. export var backgroundUboDeclaration: {
  99247. name: string;
  99248. shader: string;
  99249. };
  99250. }
  99251. declare module BABYLON {
  99252. /** @hidden */
  99253. export var backgroundPixelShader: {
  99254. name: string;
  99255. shader: string;
  99256. };
  99257. }
  99258. declare module BABYLON {
  99259. /** @hidden */
  99260. export var backgroundVertexDeclaration: {
  99261. name: string;
  99262. shader: string;
  99263. };
  99264. }
  99265. declare module BABYLON {
  99266. /** @hidden */
  99267. export var backgroundVertexShader: {
  99268. name: string;
  99269. shader: string;
  99270. };
  99271. }
  99272. declare module BABYLON {
  99273. /**
  99274. * Background material used to create an efficient environement around your scene.
  99275. */
  99276. export class BackgroundMaterial extends PushMaterial {
  99277. /**
  99278. * Standard reflectance value at parallel view angle.
  99279. */
  99280. static StandardReflectance0: number;
  99281. /**
  99282. * Standard reflectance value at grazing angle.
  99283. */
  99284. static StandardReflectance90: number;
  99285. protected _primaryColor: Color3;
  99286. /**
  99287. * Key light Color (multiply against the environement texture)
  99288. */
  99289. primaryColor: Color3;
  99290. protected __perceptualColor: Nullable<Color3>;
  99291. /**
  99292. * Experimental Internal Use Only.
  99293. *
  99294. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99295. * This acts as a helper to set the primary color to a more "human friendly" value.
  99296. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99297. * output color as close as possible from the chosen value.
  99298. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99299. * part of lighting setup.)
  99300. */
  99301. _perceptualColor: Nullable<Color3>;
  99302. protected _primaryColorShadowLevel: float;
  99303. /**
  99304. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99305. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99306. */
  99307. primaryColorShadowLevel: float;
  99308. protected _primaryColorHighlightLevel: float;
  99309. /**
  99310. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99311. * The primary color is used at the level chosen to define what the white area would look.
  99312. */
  99313. primaryColorHighlightLevel: float;
  99314. protected _reflectionTexture: Nullable<BaseTexture>;
  99315. /**
  99316. * Reflection Texture used in the material.
  99317. * Should be author in a specific way for the best result (refer to the documentation).
  99318. */
  99319. reflectionTexture: Nullable<BaseTexture>;
  99320. protected _reflectionBlur: float;
  99321. /**
  99322. * Reflection Texture level of blur.
  99323. *
  99324. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99325. * texture twice.
  99326. */
  99327. reflectionBlur: float;
  99328. protected _diffuseTexture: Nullable<BaseTexture>;
  99329. /**
  99330. * Diffuse Texture used in the material.
  99331. * Should be author in a specific way for the best result (refer to the documentation).
  99332. */
  99333. diffuseTexture: Nullable<BaseTexture>;
  99334. protected _shadowLights: Nullable<IShadowLight[]>;
  99335. /**
  99336. * Specify the list of lights casting shadow on the material.
  99337. * All scene shadow lights will be included if null.
  99338. */
  99339. shadowLights: Nullable<IShadowLight[]>;
  99340. protected _shadowLevel: float;
  99341. /**
  99342. * Helps adjusting the shadow to a softer level if required.
  99343. * 0 means black shadows and 1 means no shadows.
  99344. */
  99345. shadowLevel: float;
  99346. protected _sceneCenter: Vector3;
  99347. /**
  99348. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  99349. * It is usually zero but might be interesting to modify according to your setup.
  99350. */
  99351. sceneCenter: Vector3;
  99352. protected _opacityFresnel: boolean;
  99353. /**
  99354. * This helps specifying that the material is falling off to the sky box at grazing angle.
  99355. * This helps ensuring a nice transition when the camera goes under the ground.
  99356. */
  99357. opacityFresnel: boolean;
  99358. protected _reflectionFresnel: boolean;
  99359. /**
  99360. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  99361. * This helps adding a mirror texture on the ground.
  99362. */
  99363. reflectionFresnel: boolean;
  99364. protected _reflectionFalloffDistance: number;
  99365. /**
  99366. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  99367. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  99368. */
  99369. reflectionFalloffDistance: number;
  99370. protected _reflectionAmount: number;
  99371. /**
  99372. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  99373. */
  99374. reflectionAmount: number;
  99375. protected _reflectionReflectance0: number;
  99376. /**
  99377. * This specifies the weight of the reflection at grazing angle.
  99378. */
  99379. reflectionReflectance0: number;
  99380. protected _reflectionReflectance90: number;
  99381. /**
  99382. * This specifies the weight of the reflection at a perpendicular point of view.
  99383. */
  99384. reflectionReflectance90: number;
  99385. /**
  99386. * Sets the reflection reflectance fresnel values according to the default standard
  99387. * empirically know to work well :-)
  99388. */
  99389. reflectionStandardFresnelWeight: number;
  99390. protected _useRGBColor: boolean;
  99391. /**
  99392. * Helps to directly use the maps channels instead of their level.
  99393. */
  99394. useRGBColor: boolean;
  99395. protected _enableNoise: boolean;
  99396. /**
  99397. * This helps reducing the banding effect that could occur on the background.
  99398. */
  99399. enableNoise: boolean;
  99400. /**
  99401. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99402. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  99403. * Recommended to be keep at 1.0 except for special cases.
  99404. */
  99405. fovMultiplier: number;
  99406. private _fovMultiplier;
  99407. /**
  99408. * Enable the FOV adjustment feature controlled by fovMultiplier.
  99409. */
  99410. useEquirectangularFOV: boolean;
  99411. private _maxSimultaneousLights;
  99412. /**
  99413. * Number of Simultaneous lights allowed on the material.
  99414. */
  99415. maxSimultaneousLights: int;
  99416. /**
  99417. * Default configuration related to image processing available in the Background Material.
  99418. */
  99419. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99420. /**
  99421. * Keep track of the image processing observer to allow dispose and replace.
  99422. */
  99423. private _imageProcessingObserver;
  99424. /**
  99425. * Attaches a new image processing configuration to the PBR Material.
  99426. * @param configuration (if null the scene configuration will be use)
  99427. */
  99428. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99429. /**
  99430. * Gets the image processing configuration used either in this material.
  99431. */
  99432. /**
  99433. * Sets the Default image processing configuration used either in the this material.
  99434. *
  99435. * If sets to null, the scene one is in use.
  99436. */
  99437. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99438. /**
  99439. * Gets wether the color curves effect is enabled.
  99440. */
  99441. /**
  99442. * Sets wether the color curves effect is enabled.
  99443. */
  99444. cameraColorCurvesEnabled: boolean;
  99445. /**
  99446. * Gets wether the color grading effect is enabled.
  99447. */
  99448. /**
  99449. * Gets wether the color grading effect is enabled.
  99450. */
  99451. cameraColorGradingEnabled: boolean;
  99452. /**
  99453. * Gets wether tonemapping is enabled or not.
  99454. */
  99455. /**
  99456. * Sets wether tonemapping is enabled or not
  99457. */
  99458. cameraToneMappingEnabled: boolean;
  99459. /**
  99460. * The camera exposure used on this material.
  99461. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99462. * This corresponds to a photographic exposure.
  99463. */
  99464. /**
  99465. * The camera exposure used on this material.
  99466. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99467. * This corresponds to a photographic exposure.
  99468. */
  99469. cameraExposure: float;
  99470. /**
  99471. * Gets The camera contrast used on this material.
  99472. */
  99473. /**
  99474. * Sets The camera contrast used on this material.
  99475. */
  99476. cameraContrast: float;
  99477. /**
  99478. * Gets the Color Grading 2D Lookup Texture.
  99479. */
  99480. /**
  99481. * Sets the Color Grading 2D Lookup Texture.
  99482. */
  99483. cameraColorGradingTexture: Nullable<BaseTexture>;
  99484. /**
  99485. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99486. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99487. * 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;
  99488. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99489. */
  99490. /**
  99491. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99492. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99493. * 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;
  99494. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99495. */
  99496. cameraColorCurves: Nullable<ColorCurves>;
  99497. /**
  99498. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  99499. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  99500. */
  99501. switchToBGR: boolean;
  99502. private _renderTargets;
  99503. private _reflectionControls;
  99504. private _white;
  99505. private _primaryShadowColor;
  99506. private _primaryHighlightColor;
  99507. /**
  99508. * Instantiates a Background Material in the given scene
  99509. * @param name The friendly name of the material
  99510. * @param scene The scene to add the material to
  99511. */
  99512. constructor(name: string, scene: Scene);
  99513. /**
  99514. * Gets a boolean indicating that current material needs to register RTT
  99515. */
  99516. readonly hasRenderTargetTextures: boolean;
  99517. /**
  99518. * The entire material has been created in order to prevent overdraw.
  99519. * @returns false
  99520. */
  99521. needAlphaTesting(): boolean;
  99522. /**
  99523. * The entire material has been created in order to prevent overdraw.
  99524. * @returns true if blending is enable
  99525. */
  99526. needAlphaBlending(): boolean;
  99527. /**
  99528. * Checks wether the material is ready to be rendered for a given mesh.
  99529. * @param mesh The mesh to render
  99530. * @param subMesh The submesh to check against
  99531. * @param useInstances Specify wether or not the material is used with instances
  99532. * @returns true if all the dependencies are ready (Textures, Effects...)
  99533. */
  99534. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99535. /**
  99536. * Compute the primary color according to the chosen perceptual color.
  99537. */
  99538. private _computePrimaryColorFromPerceptualColor;
  99539. /**
  99540. * Compute the highlights and shadow colors according to their chosen levels.
  99541. */
  99542. private _computePrimaryColors;
  99543. /**
  99544. * Build the uniform buffer used in the material.
  99545. */
  99546. buildUniformLayout(): void;
  99547. /**
  99548. * Unbind the material.
  99549. */
  99550. unbind(): void;
  99551. /**
  99552. * Bind only the world matrix to the material.
  99553. * @param world The world matrix to bind.
  99554. */
  99555. bindOnlyWorldMatrix(world: Matrix): void;
  99556. /**
  99557. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  99558. * @param world The world matrix to bind.
  99559. * @param subMesh The submesh to bind for.
  99560. */
  99561. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99562. /**
  99563. * Dispose the material.
  99564. * @param forceDisposeEffect Force disposal of the associated effect.
  99565. * @param forceDisposeTextures Force disposal of the associated textures.
  99566. */
  99567. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99568. /**
  99569. * Clones the material.
  99570. * @param name The cloned name.
  99571. * @returns The cloned material.
  99572. */
  99573. clone(name: string): BackgroundMaterial;
  99574. /**
  99575. * Serializes the current material to its JSON representation.
  99576. * @returns The JSON representation.
  99577. */
  99578. serialize(): any;
  99579. /**
  99580. * Gets the class name of the material
  99581. * @returns "BackgroundMaterial"
  99582. */
  99583. getClassName(): string;
  99584. /**
  99585. * Parse a JSON input to create back a background material.
  99586. * @param source The JSON data to parse
  99587. * @param scene The scene to create the parsed material in
  99588. * @param rootUrl The root url of the assets the material depends upon
  99589. * @returns the instantiated BackgroundMaterial.
  99590. */
  99591. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  99592. }
  99593. }
  99594. declare module BABYLON {
  99595. /**
  99596. * Represents the different options available during the creation of
  99597. * a Environment helper.
  99598. *
  99599. * This can control the default ground, skybox and image processing setup of your scene.
  99600. */
  99601. export interface IEnvironmentHelperOptions {
  99602. /**
  99603. * Specifies wether or not to create a ground.
  99604. * True by default.
  99605. */
  99606. createGround: boolean;
  99607. /**
  99608. * Specifies the ground size.
  99609. * 15 by default.
  99610. */
  99611. groundSize: number;
  99612. /**
  99613. * The texture used on the ground for the main color.
  99614. * Comes from the BabylonJS CDN by default.
  99615. *
  99616. * Remarks: Can be either a texture or a url.
  99617. */
  99618. groundTexture: string | BaseTexture;
  99619. /**
  99620. * The color mixed in the ground texture by default.
  99621. * BabylonJS clearColor by default.
  99622. */
  99623. groundColor: Color3;
  99624. /**
  99625. * Specifies the ground opacity.
  99626. * 1 by default.
  99627. */
  99628. groundOpacity: number;
  99629. /**
  99630. * Enables the ground to receive shadows.
  99631. * True by default.
  99632. */
  99633. enableGroundShadow: boolean;
  99634. /**
  99635. * Helps preventing the shadow to be fully black on the ground.
  99636. * 0.5 by default.
  99637. */
  99638. groundShadowLevel: number;
  99639. /**
  99640. * Creates a mirror texture attach to the ground.
  99641. * false by default.
  99642. */
  99643. enableGroundMirror: boolean;
  99644. /**
  99645. * Specifies the ground mirror size ratio.
  99646. * 0.3 by default as the default kernel is 64.
  99647. */
  99648. groundMirrorSizeRatio: number;
  99649. /**
  99650. * Specifies the ground mirror blur kernel size.
  99651. * 64 by default.
  99652. */
  99653. groundMirrorBlurKernel: number;
  99654. /**
  99655. * Specifies the ground mirror visibility amount.
  99656. * 1 by default
  99657. */
  99658. groundMirrorAmount: number;
  99659. /**
  99660. * Specifies the ground mirror reflectance weight.
  99661. * This uses the standard weight of the background material to setup the fresnel effect
  99662. * of the mirror.
  99663. * 1 by default.
  99664. */
  99665. groundMirrorFresnelWeight: number;
  99666. /**
  99667. * Specifies the ground mirror Falloff distance.
  99668. * This can helps reducing the size of the reflection.
  99669. * 0 by Default.
  99670. */
  99671. groundMirrorFallOffDistance: number;
  99672. /**
  99673. * Specifies the ground mirror texture type.
  99674. * Unsigned Int by Default.
  99675. */
  99676. groundMirrorTextureType: number;
  99677. /**
  99678. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  99679. * the shown objects.
  99680. */
  99681. groundYBias: number;
  99682. /**
  99683. * Specifies wether or not to create a skybox.
  99684. * True by default.
  99685. */
  99686. createSkybox: boolean;
  99687. /**
  99688. * Specifies the skybox size.
  99689. * 20 by default.
  99690. */
  99691. skyboxSize: number;
  99692. /**
  99693. * The texture used on the skybox for the main color.
  99694. * Comes from the BabylonJS CDN by default.
  99695. *
  99696. * Remarks: Can be either a texture or a url.
  99697. */
  99698. skyboxTexture: string | BaseTexture;
  99699. /**
  99700. * The color mixed in the skybox texture by default.
  99701. * BabylonJS clearColor by default.
  99702. */
  99703. skyboxColor: Color3;
  99704. /**
  99705. * The background rotation around the Y axis of the scene.
  99706. * This helps aligning the key lights of your scene with the background.
  99707. * 0 by default.
  99708. */
  99709. backgroundYRotation: number;
  99710. /**
  99711. * Compute automatically the size of the elements to best fit with the scene.
  99712. */
  99713. sizeAuto: boolean;
  99714. /**
  99715. * Default position of the rootMesh if autoSize is not true.
  99716. */
  99717. rootPosition: Vector3;
  99718. /**
  99719. * Sets up the image processing in the scene.
  99720. * true by default.
  99721. */
  99722. setupImageProcessing: boolean;
  99723. /**
  99724. * The texture used as your environment texture in the scene.
  99725. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  99726. *
  99727. * Remarks: Can be either a texture or a url.
  99728. */
  99729. environmentTexture: string | BaseTexture;
  99730. /**
  99731. * The value of the exposure to apply to the scene.
  99732. * 0.6 by default if setupImageProcessing is true.
  99733. */
  99734. cameraExposure: number;
  99735. /**
  99736. * The value of the contrast to apply to the scene.
  99737. * 1.6 by default if setupImageProcessing is true.
  99738. */
  99739. cameraContrast: number;
  99740. /**
  99741. * Specifies wether or not tonemapping should be enabled in the scene.
  99742. * true by default if setupImageProcessing is true.
  99743. */
  99744. toneMappingEnabled: boolean;
  99745. }
  99746. /**
  99747. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  99748. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  99749. * It also helps with the default setup of your imageProcessing configuration.
  99750. */
  99751. export class EnvironmentHelper {
  99752. /**
  99753. * Default ground texture URL.
  99754. */
  99755. private static _groundTextureCDNUrl;
  99756. /**
  99757. * Default skybox texture URL.
  99758. */
  99759. private static _skyboxTextureCDNUrl;
  99760. /**
  99761. * Default environment texture URL.
  99762. */
  99763. private static _environmentTextureCDNUrl;
  99764. /**
  99765. * Creates the default options for the helper.
  99766. */
  99767. private static _getDefaultOptions;
  99768. private _rootMesh;
  99769. /**
  99770. * Gets the root mesh created by the helper.
  99771. */
  99772. readonly rootMesh: Mesh;
  99773. private _skybox;
  99774. /**
  99775. * Gets the skybox created by the helper.
  99776. */
  99777. readonly skybox: Nullable<Mesh>;
  99778. private _skyboxTexture;
  99779. /**
  99780. * Gets the skybox texture created by the helper.
  99781. */
  99782. readonly skyboxTexture: Nullable<BaseTexture>;
  99783. private _skyboxMaterial;
  99784. /**
  99785. * Gets the skybox material created by the helper.
  99786. */
  99787. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  99788. private _ground;
  99789. /**
  99790. * Gets the ground mesh created by the helper.
  99791. */
  99792. readonly ground: Nullable<Mesh>;
  99793. private _groundTexture;
  99794. /**
  99795. * Gets the ground texture created by the helper.
  99796. */
  99797. readonly groundTexture: Nullable<BaseTexture>;
  99798. private _groundMirror;
  99799. /**
  99800. * Gets the ground mirror created by the helper.
  99801. */
  99802. readonly groundMirror: Nullable<MirrorTexture>;
  99803. /**
  99804. * Gets the ground mirror render list to helps pushing the meshes
  99805. * you wish in the ground reflection.
  99806. */
  99807. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  99808. private _groundMaterial;
  99809. /**
  99810. * Gets the ground material created by the helper.
  99811. */
  99812. readonly groundMaterial: Nullable<BackgroundMaterial>;
  99813. /**
  99814. * Stores the creation options.
  99815. */
  99816. private readonly _scene;
  99817. private _options;
  99818. /**
  99819. * This observable will be notified with any error during the creation of the environment,
  99820. * mainly texture creation errors.
  99821. */
  99822. onErrorObservable: Observable<{
  99823. message?: string;
  99824. exception?: any;
  99825. }>;
  99826. /**
  99827. * constructor
  99828. * @param options Defines the options we want to customize the helper
  99829. * @param scene The scene to add the material to
  99830. */
  99831. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  99832. /**
  99833. * Updates the background according to the new options
  99834. * @param options
  99835. */
  99836. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  99837. /**
  99838. * Sets the primary color of all the available elements.
  99839. * @param color the main color to affect to the ground and the background
  99840. */
  99841. setMainColor(color: Color3): void;
  99842. /**
  99843. * Setup the image processing according to the specified options.
  99844. */
  99845. private _setupImageProcessing;
  99846. /**
  99847. * Setup the environment texture according to the specified options.
  99848. */
  99849. private _setupEnvironmentTexture;
  99850. /**
  99851. * Setup the background according to the specified options.
  99852. */
  99853. private _setupBackground;
  99854. /**
  99855. * Get the scene sizes according to the setup.
  99856. */
  99857. private _getSceneSize;
  99858. /**
  99859. * Setup the ground according to the specified options.
  99860. */
  99861. private _setupGround;
  99862. /**
  99863. * Setup the ground material according to the specified options.
  99864. */
  99865. private _setupGroundMaterial;
  99866. /**
  99867. * Setup the ground diffuse texture according to the specified options.
  99868. */
  99869. private _setupGroundDiffuseTexture;
  99870. /**
  99871. * Setup the ground mirror texture according to the specified options.
  99872. */
  99873. private _setupGroundMirrorTexture;
  99874. /**
  99875. * Setup the ground to receive the mirror texture.
  99876. */
  99877. private _setupMirrorInGroundMaterial;
  99878. /**
  99879. * Setup the skybox according to the specified options.
  99880. */
  99881. private _setupSkybox;
  99882. /**
  99883. * Setup the skybox material according to the specified options.
  99884. */
  99885. private _setupSkyboxMaterial;
  99886. /**
  99887. * Setup the skybox reflection texture according to the specified options.
  99888. */
  99889. private _setupSkyboxReflectionTexture;
  99890. private _errorHandler;
  99891. /**
  99892. * Dispose all the elements created by the Helper.
  99893. */
  99894. dispose(): void;
  99895. }
  99896. }
  99897. declare module BABYLON {
  99898. /**
  99899. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  99900. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  99901. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  99902. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99903. */
  99904. export class PhotoDome extends TransformNode {
  99905. private _useDirectMapping;
  99906. /**
  99907. * The texture being displayed on the sphere
  99908. */
  99909. protected _photoTexture: Texture;
  99910. /**
  99911. * Gets or sets the texture being displayed on the sphere
  99912. */
  99913. photoTexture: Texture;
  99914. /**
  99915. * Observable raised when an error occured while loading the 360 image
  99916. */
  99917. onLoadErrorObservable: Observable<string>;
  99918. /**
  99919. * The skybox material
  99920. */
  99921. protected _material: BackgroundMaterial;
  99922. /**
  99923. * The surface used for the skybox
  99924. */
  99925. protected _mesh: Mesh;
  99926. /**
  99927. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99928. * Also see the options.resolution property.
  99929. */
  99930. fovMultiplier: number;
  99931. /**
  99932. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  99933. * @param name Element's name, child elements will append suffixes for their own names.
  99934. * @param urlsOfPhoto defines the url of the photo to display
  99935. * @param options defines an object containing optional or exposed sub element properties
  99936. * @param onError defines a callback called when an error occured while loading the texture
  99937. */
  99938. constructor(name: string, urlOfPhoto: string, options: {
  99939. resolution?: number;
  99940. size?: number;
  99941. useDirectMapping?: boolean;
  99942. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  99943. /**
  99944. * Releases resources associated with this node.
  99945. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99946. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99947. */
  99948. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99949. }
  99950. }
  99951. declare module BABYLON {
  99952. /**
  99953. * Class used to host texture specific utilities
  99954. */
  99955. export class TextureTools {
  99956. /**
  99957. * Uses the GPU to create a copy texture rescaled at a given size
  99958. * @param texture Texture to copy from
  99959. * @param width defines the desired width
  99960. * @param height defines the desired height
  99961. * @param useBilinearMode defines if bilinear mode has to be used
  99962. * @return the generated texture
  99963. */
  99964. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  99965. /**
  99966. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  99967. * @param scene defines the hosting scene
  99968. * @returns the environment BRDF texture
  99969. */
  99970. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  99971. private static _environmentBRDFBase64Texture;
  99972. }
  99973. }
  99974. declare module BABYLON {
  99975. /**
  99976. * @hidden
  99977. */
  99978. export interface IMaterialClearCoatDefines {
  99979. CLEARCOAT: boolean;
  99980. CLEARCOAT_DEFAULTIOR: boolean;
  99981. CLEARCOAT_TEXTURE: boolean;
  99982. CLEARCOAT_TEXTUREDIRECTUV: number;
  99983. CLEARCOAT_BUMP: boolean;
  99984. CLEARCOAT_BUMPDIRECTUV: number;
  99985. CLEARCOAT_TINT: boolean;
  99986. CLEARCOAT_TINT_TEXTURE: boolean;
  99987. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  99988. /** @hidden */
  99989. _areTexturesDirty: boolean;
  99990. }
  99991. /**
  99992. * Define the code related to the clear coat parameters of the pbr material.
  99993. */
  99994. export class PBRClearCoatConfiguration {
  99995. /**
  99996. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  99997. * The default fits with a polyurethane material.
  99998. */
  99999. private static readonly _DefaultIndiceOfRefraction;
  100000. private _isEnabled;
  100001. /**
  100002. * Defines if the clear coat is enabled in the material.
  100003. */
  100004. isEnabled: boolean;
  100005. /**
  100006. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100007. */
  100008. intensity: number;
  100009. /**
  100010. * Defines the clear coat layer roughness.
  100011. */
  100012. roughness: number;
  100013. private _indiceOfRefraction;
  100014. /**
  100015. * Defines the indice of refraction of the clear coat.
  100016. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100017. * The default fits with a polyurethane material.
  100018. * Changing the default value is more performance intensive.
  100019. */
  100020. indiceOfRefraction: number;
  100021. private _texture;
  100022. /**
  100023. * Stores the clear coat values in a texture.
  100024. */
  100025. texture: Nullable<BaseTexture>;
  100026. private _bumpTexture;
  100027. /**
  100028. * Define the clear coat specific bump texture.
  100029. */
  100030. bumpTexture: Nullable<BaseTexture>;
  100031. private _isTintEnabled;
  100032. /**
  100033. * Defines if the clear coat tint is enabled in the material.
  100034. */
  100035. isTintEnabled: boolean;
  100036. /**
  100037. * Defines if the clear coat tint is enabled in the material.
  100038. * This is only use if tint is enabled
  100039. */
  100040. tintColor: Color3;
  100041. /**
  100042. * Defines if the distance at which the tint color should be found in the
  100043. * clear coat media.
  100044. * This is only use if tint is enabled
  100045. */
  100046. tintColorAtDistance: number;
  100047. /**
  100048. * Defines the clear coat layer thickness.
  100049. * This is only use if tint is enabled
  100050. */
  100051. tintThickness: number;
  100052. private _tintTexture;
  100053. /**
  100054. * Stores the clear tint values in a texture.
  100055. * rgb is tint
  100056. * a is a thickness factor
  100057. */
  100058. tintTexture: Nullable<BaseTexture>;
  100059. /** @hidden */
  100060. private _internalMarkAllSubMeshesAsTexturesDirty;
  100061. /** @hidden */
  100062. _markAllSubMeshesAsTexturesDirty(): void;
  100063. /**
  100064. * Instantiate a new istance of clear coat configuration.
  100065. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100066. */
  100067. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100068. /**
  100069. * Specifies that the submesh is ready to be used.
  100070. * @param defines the list of "defines" to update.
  100071. * @param scene defines the scene the material belongs to.
  100072. * @param engine defines the engine the material belongs to.
  100073. * @param disableBumpMap defines wether the material disables bump or not.
  100074. * @returns - boolean indicating that the submesh is ready or not.
  100075. */
  100076. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100077. /**
  100078. * Checks to see if a texture is used in the material.
  100079. * @param defines the list of "defines" to update.
  100080. * @param scene defines the scene to the material belongs to.
  100081. */
  100082. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100083. /**
  100084. * Binds the material data.
  100085. * @param uniformBuffer defines the Uniform buffer to fill in.
  100086. * @param scene defines the scene the material belongs to.
  100087. * @param engine defines the engine the material belongs to.
  100088. * @param disableBumpMap defines wether the material disables bump or not.
  100089. * @param isFrozen defines wether the material is frozen or not.
  100090. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100091. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100092. */
  100093. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100094. /**
  100095. * Checks to see if a texture is used in the material.
  100096. * @param texture - Base texture to use.
  100097. * @returns - Boolean specifying if a texture is used in the material.
  100098. */
  100099. hasTexture(texture: BaseTexture): boolean;
  100100. /**
  100101. * Returns an array of the actively used textures.
  100102. * @param activeTextures Array of BaseTextures
  100103. */
  100104. getActiveTextures(activeTextures: BaseTexture[]): void;
  100105. /**
  100106. * Returns the animatable textures.
  100107. * @param animatables Array of animatable textures.
  100108. */
  100109. getAnimatables(animatables: IAnimatable[]): void;
  100110. /**
  100111. * Disposes the resources of the material.
  100112. * @param forceDisposeTextures - Forces the disposal of all textures.
  100113. */
  100114. dispose(forceDisposeTextures?: boolean): void;
  100115. /**
  100116. * Get the current class name of the texture useful for serialization or dynamic coding.
  100117. * @returns "PBRClearCoatConfiguration"
  100118. */
  100119. getClassName(): string;
  100120. /**
  100121. * Makes a duplicate of the current configuration into another one.
  100122. * @param clearCoatConfiguration define the config where to copy the info
  100123. */
  100124. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100125. /**
  100126. * Serializes this clear coat configuration.
  100127. * @returns - An object with the serialized config.
  100128. */
  100129. serialize(): any;
  100130. /**
  100131. * Parses a Clear Coat Configuration from a serialized object.
  100132. * @param source - Serialized object.
  100133. */
  100134. parse(source: any): void;
  100135. /**
  100136. * Add fallbacks to the effect fallbacks list.
  100137. * @param defines defines the Base texture to use.
  100138. * @param fallbacks defines the current fallback list.
  100139. * @param currentRank defines the current fallback rank.
  100140. * @returns the new fallback rank.
  100141. */
  100142. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100143. /**
  100144. * Add the required uniforms to the current list.
  100145. * @param uniforms defines the current uniform list.
  100146. */
  100147. static AddUniforms(uniforms: string[]): void;
  100148. /**
  100149. * Add the required samplers to the current list.
  100150. * @param samplers defines the current sampler list.
  100151. */
  100152. static AddSamplers(samplers: string[]): void;
  100153. /**
  100154. * Add the required uniforms to the current buffer.
  100155. * @param uniformBuffer defines the current uniform buffer.
  100156. */
  100157. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100158. }
  100159. }
  100160. declare module BABYLON {
  100161. /**
  100162. * @hidden
  100163. */
  100164. export interface IMaterialAnisotropicDefines {
  100165. ANISOTROPIC: boolean;
  100166. MAINUV1: boolean;
  100167. _areMiscDirty: boolean;
  100168. _needUVs: boolean;
  100169. }
  100170. /**
  100171. * Define the code related to the anisotropic parameters of the pbr material.
  100172. */
  100173. export class PBRAnisotropicConfiguration {
  100174. private _isEnabled;
  100175. /**
  100176. * Defines if the anisotropy is enabled in the material.
  100177. */
  100178. isEnabled: boolean;
  100179. /**
  100180. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100181. */
  100182. intensity: number;
  100183. /**
  100184. * Defines if the effect is along the tangents or bitangents.
  100185. * By default, the effect is "strectching" the highlights along the tangents.
  100186. */
  100187. followTangents: boolean;
  100188. /** @hidden */
  100189. private _internalMarkAllSubMeshesAsMiscDirty;
  100190. /** @hidden */
  100191. _markAllSubMeshesAsMiscDirty(): void;
  100192. /**
  100193. * Instantiate a new istance of clear coat configuration.
  100194. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100195. */
  100196. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100197. /**
  100198. * Checks to see if a texture is used in the material.
  100199. * @param defines the list of "defines" to update.
  100200. * @param mesh the mesh we are preparing the defines for.
  100201. */
  100202. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  100203. /**
  100204. * Binds the material data.
  100205. * @param uniformBuffer defines the Uniform buffer to fill in.
  100206. * @param isFrozen defines wether the material is frozen or not.
  100207. */
  100208. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  100209. /**
  100210. * Get the current class name of the texture useful for serialization or dynamic coding.
  100211. * @returns "PBRAnisotropicConfiguration"
  100212. */
  100213. getClassName(): string;
  100214. /**
  100215. * Makes a duplicate of the current configuration into another one.
  100216. * @param anisotropicConfiguration define the config where to copy the info
  100217. */
  100218. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100219. /**
  100220. * Serializes this clear coat configuration.
  100221. * @returns - An object with the serialized config.
  100222. */
  100223. serialize(): any;
  100224. /**
  100225. * Parses a Clear Coat Configuration from a serialized object.
  100226. * @param source - Serialized object.
  100227. */
  100228. parse(source: any): void;
  100229. /**
  100230. * Add fallbacks to the effect fallbacks list.
  100231. * @param defines defines the Base texture to use.
  100232. * @param fallbacks defines the current fallback list.
  100233. * @param currentRank defines the current fallback rank.
  100234. * @returns the new fallback rank.
  100235. */
  100236. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100237. /**
  100238. * Add the required uniforms to the current list.
  100239. * @param uniforms defines the current uniform list.
  100240. */
  100241. static AddUniforms(uniforms: string[]): void;
  100242. /**
  100243. * Add the required uniforms to the current buffer.
  100244. * @param uniformBuffer defines the current uniform buffer.
  100245. */
  100246. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100247. }
  100248. }
  100249. declare module BABYLON {
  100250. /**
  100251. * @hidden
  100252. */
  100253. export interface IMaterialBRDFDefines {
  100254. BRDF_V_HEIGHT_CORRELATED: boolean;
  100255. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100256. /** @hidden */
  100257. _areMiscDirty: boolean;
  100258. }
  100259. /**
  100260. * Define the code related to the BRDF parameters of the pbr material.
  100261. */
  100262. export class PBRBRDFConfiguration {
  100263. private _useEnergyConservation;
  100264. /**
  100265. * Defines if the material uses energy conservation.
  100266. */
  100267. useEnergyConservation: boolean;
  100268. private _useSmithVisibilityHeightCorrelated;
  100269. /**
  100270. * LEGACY Mode set to false
  100271. * Defines if the material uses height smith correlated visibility term.
  100272. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100273. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100274. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100275. * Not relying on height correlated will also disable energy conservation.
  100276. */
  100277. useSmithVisibilityHeightCorrelated: boolean;
  100278. /** @hidden */
  100279. private _internalMarkAllSubMeshesAsMiscDirty;
  100280. /** @hidden */
  100281. _markAllSubMeshesAsMiscDirty(): void;
  100282. /**
  100283. * Instantiate a new istance of clear coat configuration.
  100284. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100285. */
  100286. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100287. /**
  100288. * Checks to see if a texture is used in the material.
  100289. * @param defines the list of "defines" to update.
  100290. */
  100291. prepareDefines(defines: IMaterialBRDFDefines): void;
  100292. /**
  100293. * Get the current class name of the texture useful for serialization or dynamic coding.
  100294. * @returns "PBRClearCoatConfiguration"
  100295. */
  100296. getClassName(): string;
  100297. /**
  100298. * Makes a duplicate of the current configuration into another one.
  100299. * @param brdfConfiguration define the config where to copy the info
  100300. */
  100301. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  100302. /**
  100303. * Serializes this BRDF configuration.
  100304. * @returns - An object with the serialized config.
  100305. */
  100306. serialize(): any;
  100307. /**
  100308. * Parses a BRDF Configuration from a serialized object.
  100309. * @param source - Serialized object.
  100310. */
  100311. parse(source: any): void;
  100312. }
  100313. }
  100314. declare module BABYLON {
  100315. /** @hidden */
  100316. export var pbrFragmentDeclaration: {
  100317. name: string;
  100318. shader: string;
  100319. };
  100320. }
  100321. declare module BABYLON {
  100322. /** @hidden */
  100323. export var pbrUboDeclaration: {
  100324. name: string;
  100325. shader: string;
  100326. };
  100327. }
  100328. declare module BABYLON {
  100329. /** @hidden */
  100330. export var pbrFunctions: {
  100331. name: string;
  100332. shader: string;
  100333. };
  100334. }
  100335. declare module BABYLON {
  100336. /** @hidden */
  100337. export var harmonicsFunctions: {
  100338. name: string;
  100339. shader: string;
  100340. };
  100341. }
  100342. declare module BABYLON {
  100343. /** @hidden */
  100344. export var pbrPreLightingFunctions: {
  100345. name: string;
  100346. shader: string;
  100347. };
  100348. }
  100349. declare module BABYLON {
  100350. /** @hidden */
  100351. export var pbrFalloffLightingFunctions: {
  100352. name: string;
  100353. shader: string;
  100354. };
  100355. }
  100356. declare module BABYLON {
  100357. /** @hidden */
  100358. export var pbrLightingFunctions: {
  100359. name: string;
  100360. shader: string;
  100361. };
  100362. }
  100363. declare module BABYLON {
  100364. /** @hidden */
  100365. export var pbrDebug: {
  100366. name: string;
  100367. shader: string;
  100368. };
  100369. }
  100370. declare module BABYLON {
  100371. /** @hidden */
  100372. export var pbrPixelShader: {
  100373. name: string;
  100374. shader: string;
  100375. };
  100376. }
  100377. declare module BABYLON {
  100378. /** @hidden */
  100379. export var pbrVertexDeclaration: {
  100380. name: string;
  100381. shader: string;
  100382. };
  100383. }
  100384. declare module BABYLON {
  100385. /** @hidden */
  100386. export var pbrVertexShader: {
  100387. name: string;
  100388. shader: string;
  100389. };
  100390. }
  100391. declare module BABYLON {
  100392. /**
  100393. * The Physically based material base class of BJS.
  100394. *
  100395. * This offers the main features of a standard PBR material.
  100396. * For more information, please refer to the documentation :
  100397. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100398. */
  100399. export abstract class PBRBaseMaterial extends PushMaterial {
  100400. /**
  100401. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100402. */
  100403. static readonly PBRMATERIAL_OPAQUE: number;
  100404. /**
  100405. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100406. */
  100407. static readonly PBRMATERIAL_ALPHATEST: number;
  100408. /**
  100409. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100410. */
  100411. static readonly PBRMATERIAL_ALPHABLEND: number;
  100412. /**
  100413. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100414. * They are also discarded below the alpha cutoff threshold to improve performances.
  100415. */
  100416. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100417. /**
  100418. * Defines the default value of how much AO map is occluding the analytical lights
  100419. * (point spot...).
  100420. */
  100421. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100422. /**
  100423. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  100424. */
  100425. static readonly LIGHTFALLOFF_PHYSICAL: number;
  100426. /**
  100427. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  100428. * to enhance interoperability with other engines.
  100429. */
  100430. static readonly LIGHTFALLOFF_GLTF: number;
  100431. /**
  100432. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  100433. * to enhance interoperability with other materials.
  100434. */
  100435. static readonly LIGHTFALLOFF_STANDARD: number;
  100436. /**
  100437. * Intensity of the direct lights e.g. the four lights available in your scene.
  100438. * This impacts both the direct diffuse and specular highlights.
  100439. */
  100440. protected _directIntensity: number;
  100441. /**
  100442. * Intensity of the emissive part of the material.
  100443. * This helps controlling the emissive effect without modifying the emissive color.
  100444. */
  100445. protected _emissiveIntensity: number;
  100446. /**
  100447. * Intensity of the environment e.g. how much the environment will light the object
  100448. * either through harmonics for rough material or through the refelction for shiny ones.
  100449. */
  100450. protected _environmentIntensity: number;
  100451. /**
  100452. * This is a special control allowing the reduction of the specular highlights coming from the
  100453. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100454. */
  100455. protected _specularIntensity: number;
  100456. /**
  100457. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  100458. */
  100459. private _lightingInfos;
  100460. /**
  100461. * Debug Control allowing disabling the bump map on this material.
  100462. */
  100463. protected _disableBumpMap: boolean;
  100464. /**
  100465. * AKA Diffuse Texture in standard nomenclature.
  100466. */
  100467. protected _albedoTexture: BaseTexture;
  100468. /**
  100469. * AKA Occlusion Texture in other nomenclature.
  100470. */
  100471. protected _ambientTexture: BaseTexture;
  100472. /**
  100473. * AKA Occlusion Texture Intensity in other nomenclature.
  100474. */
  100475. protected _ambientTextureStrength: number;
  100476. /**
  100477. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100478. * 1 means it completely occludes it
  100479. * 0 mean it has no impact
  100480. */
  100481. protected _ambientTextureImpactOnAnalyticalLights: number;
  100482. /**
  100483. * Stores the alpha values in a texture.
  100484. */
  100485. protected _opacityTexture: BaseTexture;
  100486. /**
  100487. * Stores the reflection values in a texture.
  100488. */
  100489. protected _reflectionTexture: BaseTexture;
  100490. /**
  100491. * Stores the refraction values in a texture.
  100492. */
  100493. protected _refractionTexture: BaseTexture;
  100494. /**
  100495. * Stores the emissive values in a texture.
  100496. */
  100497. protected _emissiveTexture: BaseTexture;
  100498. /**
  100499. * AKA Specular texture in other nomenclature.
  100500. */
  100501. protected _reflectivityTexture: BaseTexture;
  100502. /**
  100503. * Used to switch from specular/glossiness to metallic/roughness workflow.
  100504. */
  100505. protected _metallicTexture: BaseTexture;
  100506. /**
  100507. * Specifies the metallic scalar of the metallic/roughness workflow.
  100508. * Can also be used to scale the metalness values of the metallic texture.
  100509. */
  100510. protected _metallic: Nullable<number>;
  100511. /**
  100512. * Specifies the roughness scalar of the metallic/roughness workflow.
  100513. * Can also be used to scale the roughness values of the metallic texture.
  100514. */
  100515. protected _roughness: Nullable<number>;
  100516. /**
  100517. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  100518. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  100519. */
  100520. protected _microSurfaceTexture: BaseTexture;
  100521. /**
  100522. * Stores surface normal data used to displace a mesh in a texture.
  100523. */
  100524. protected _bumpTexture: BaseTexture;
  100525. /**
  100526. * Stores the pre-calculated light information of a mesh in a texture.
  100527. */
  100528. protected _lightmapTexture: BaseTexture;
  100529. /**
  100530. * The color of a material in ambient lighting.
  100531. */
  100532. protected _ambientColor: Color3;
  100533. /**
  100534. * AKA Diffuse Color in other nomenclature.
  100535. */
  100536. protected _albedoColor: Color3;
  100537. /**
  100538. * AKA Specular Color in other nomenclature.
  100539. */
  100540. protected _reflectivityColor: Color3;
  100541. /**
  100542. * The color applied when light is reflected from a material.
  100543. */
  100544. protected _reflectionColor: Color3;
  100545. /**
  100546. * The color applied when light is emitted from a material.
  100547. */
  100548. protected _emissiveColor: Color3;
  100549. /**
  100550. * AKA Glossiness in other nomenclature.
  100551. */
  100552. protected _microSurface: number;
  100553. /**
  100554. * source material index of refraction (IOR)' / 'destination material IOR.
  100555. */
  100556. protected _indexOfRefraction: number;
  100557. /**
  100558. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100559. */
  100560. protected _invertRefractionY: boolean;
  100561. /**
  100562. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100563. * Materials half opaque for instance using refraction could benefit from this control.
  100564. */
  100565. protected _linkRefractionWithTransparency: boolean;
  100566. /**
  100567. * Specifies that the material will use the light map as a show map.
  100568. */
  100569. protected _useLightmapAsShadowmap: boolean;
  100570. /**
  100571. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  100572. * makes the reflect vector face the model (under horizon).
  100573. */
  100574. protected _useHorizonOcclusion: boolean;
  100575. /**
  100576. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  100577. * too much the area relying on ambient texture to define their ambient occlusion.
  100578. */
  100579. protected _useRadianceOcclusion: boolean;
  100580. /**
  100581. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  100582. */
  100583. protected _useAlphaFromAlbedoTexture: boolean;
  100584. /**
  100585. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  100586. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100587. */
  100588. protected _useSpecularOverAlpha: boolean;
  100589. /**
  100590. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  100591. */
  100592. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  100593. /**
  100594. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  100595. */
  100596. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  100597. /**
  100598. * Specifies if the metallic texture contains the roughness information in its green channel.
  100599. */
  100600. protected _useRoughnessFromMetallicTextureGreen: boolean;
  100601. /**
  100602. * Specifies if the metallic texture contains the metallness information in its blue channel.
  100603. */
  100604. protected _useMetallnessFromMetallicTextureBlue: boolean;
  100605. /**
  100606. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  100607. */
  100608. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  100609. /**
  100610. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  100611. */
  100612. protected _useAmbientInGrayScale: boolean;
  100613. /**
  100614. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  100615. * The material will try to infer what glossiness each pixel should be.
  100616. */
  100617. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  100618. /**
  100619. * Defines the falloff type used in this material.
  100620. * It by default is Physical.
  100621. */
  100622. protected _lightFalloff: number;
  100623. /**
  100624. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100625. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100626. */
  100627. protected _useRadianceOverAlpha: boolean;
  100628. /**
  100629. * Allows using an object space normal map (instead of tangent space).
  100630. */
  100631. protected _useObjectSpaceNormalMap: boolean;
  100632. /**
  100633. * Allows using the bump map in parallax mode.
  100634. */
  100635. protected _useParallax: boolean;
  100636. /**
  100637. * Allows using the bump map in parallax occlusion mode.
  100638. */
  100639. protected _useParallaxOcclusion: boolean;
  100640. /**
  100641. * Controls the scale bias of the parallax mode.
  100642. */
  100643. protected _parallaxScaleBias: number;
  100644. /**
  100645. * If sets to true, disables all the lights affecting the material.
  100646. */
  100647. protected _disableLighting: boolean;
  100648. /**
  100649. * Number of Simultaneous lights allowed on the material.
  100650. */
  100651. protected _maxSimultaneousLights: number;
  100652. /**
  100653. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100654. */
  100655. protected _invertNormalMapX: boolean;
  100656. /**
  100657. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100658. */
  100659. protected _invertNormalMapY: boolean;
  100660. /**
  100661. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100662. */
  100663. protected _twoSidedLighting: boolean;
  100664. /**
  100665. * Defines the alpha limits in alpha test mode.
  100666. */
  100667. protected _alphaCutOff: number;
  100668. /**
  100669. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  100670. */
  100671. protected _forceAlphaTest: boolean;
  100672. /**
  100673. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100674. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  100675. */
  100676. protected _useAlphaFresnel: boolean;
  100677. /**
  100678. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100679. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  100680. */
  100681. protected _useLinearAlphaFresnel: boolean;
  100682. /**
  100683. * The transparency mode of the material.
  100684. */
  100685. protected _transparencyMode: Nullable<number>;
  100686. /**
  100687. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  100688. * from cos thetav and roughness:
  100689. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  100690. */
  100691. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  100692. /**
  100693. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  100694. */
  100695. protected _forceIrradianceInFragment: boolean;
  100696. /**
  100697. * Force normal to face away from face.
  100698. */
  100699. protected _forceNormalForward: boolean;
  100700. /**
  100701. * Enables specular anti aliasing in the PBR shader.
  100702. * It will both interacts on the Geometry for analytical and IBL lighting.
  100703. * It also prefilter the roughness map based on the bump values.
  100704. */
  100705. protected _enableSpecularAntiAliasing: boolean;
  100706. /**
  100707. * Default configuration related to image processing available in the PBR Material.
  100708. */
  100709. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100710. /**
  100711. * Keep track of the image processing observer to allow dispose and replace.
  100712. */
  100713. private _imageProcessingObserver;
  100714. /**
  100715. * Attaches a new image processing configuration to the PBR Material.
  100716. * @param configuration
  100717. */
  100718. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100719. /**
  100720. * Stores the available render targets.
  100721. */
  100722. private _renderTargets;
  100723. /**
  100724. * Sets the global ambient color for the material used in lighting calculations.
  100725. */
  100726. private _globalAmbientColor;
  100727. /**
  100728. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  100729. */
  100730. private _useLogarithmicDepth;
  100731. /**
  100732. * If set to true, no lighting calculations will be applied.
  100733. */
  100734. private _unlit;
  100735. private _debugMode;
  100736. /**
  100737. * @hidden
  100738. * This is reserved for the inspector.
  100739. * Defines the material debug mode.
  100740. * It helps seeing only some components of the material while troubleshooting.
  100741. */
  100742. debugMode: number;
  100743. /**
  100744. * @hidden
  100745. * This is reserved for the inspector.
  100746. * Specify from where on screen the debug mode should start.
  100747. * The value goes from -1 (full screen) to 1 (not visible)
  100748. * It helps with side by side comparison against the final render
  100749. * This defaults to -1
  100750. */
  100751. private debugLimit;
  100752. /**
  100753. * @hidden
  100754. * This is reserved for the inspector.
  100755. * As the default viewing range might not be enough (if the ambient is really small for instance)
  100756. * You can use the factor to better multiply the final value.
  100757. */
  100758. private debugFactor;
  100759. /**
  100760. * Defines the clear coat layer parameters for the material.
  100761. */
  100762. readonly clearCoat: PBRClearCoatConfiguration;
  100763. /**
  100764. * Defines the anisotropic parameters for the material.
  100765. */
  100766. readonly anisotropy: PBRAnisotropicConfiguration;
  100767. /**
  100768. * Defines the BRDF parameters for the material.
  100769. */
  100770. readonly brdf: PBRBRDFConfiguration;
  100771. /**
  100772. * Instantiates a new PBRMaterial instance.
  100773. *
  100774. * @param name The material name
  100775. * @param scene The scene the material will be use in.
  100776. */
  100777. constructor(name: string, scene: Scene);
  100778. /**
  100779. * Gets a boolean indicating that current material needs to register RTT
  100780. */
  100781. readonly hasRenderTargetTextures: boolean;
  100782. /**
  100783. * Gets the name of the material class.
  100784. */
  100785. getClassName(): string;
  100786. /**
  100787. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  100788. */
  100789. /**
  100790. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  100791. */
  100792. useLogarithmicDepth: boolean;
  100793. /**
  100794. * Gets the current transparency mode.
  100795. */
  100796. /**
  100797. * Sets the transparency mode of the material.
  100798. *
  100799. * | Value | Type | Description |
  100800. * | ----- | ----------------------------------- | ----------- |
  100801. * | 0 | OPAQUE | |
  100802. * | 1 | ALPHATEST | |
  100803. * | 2 | ALPHABLEND | |
  100804. * | 3 | ALPHATESTANDBLEND | |
  100805. *
  100806. */
  100807. transparencyMode: Nullable<number>;
  100808. /**
  100809. * Returns true if alpha blending should be disabled.
  100810. */
  100811. private readonly _disableAlphaBlending;
  100812. /**
  100813. * Specifies whether or not this material should be rendered in alpha blend mode.
  100814. */
  100815. needAlphaBlending(): boolean;
  100816. /**
  100817. * Specifies if the mesh will require alpha blending.
  100818. * @param mesh - BJS mesh.
  100819. */
  100820. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  100821. /**
  100822. * Specifies whether or not this material should be rendered in alpha test mode.
  100823. */
  100824. needAlphaTesting(): boolean;
  100825. /**
  100826. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  100827. */
  100828. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  100829. /**
  100830. * Gets the texture used for the alpha test.
  100831. */
  100832. getAlphaTestTexture(): BaseTexture;
  100833. /**
  100834. * Specifies that the submesh is ready to be used.
  100835. * @param mesh - BJS mesh.
  100836. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  100837. * @param useInstances - Specifies that instances should be used.
  100838. * @returns - boolean indicating that the submesh is ready or not.
  100839. */
  100840. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100841. /**
  100842. * Specifies if the material uses metallic roughness workflow.
  100843. * @returns boolean specifiying if the material uses metallic roughness workflow.
  100844. */
  100845. isMetallicWorkflow(): boolean;
  100846. private _prepareEffect;
  100847. private _prepareDefines;
  100848. /**
  100849. * Force shader compilation
  100850. */
  100851. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  100852. clipPlane: boolean;
  100853. }>): void;
  100854. /**
  100855. * Initializes the uniform buffer layout for the shader.
  100856. */
  100857. buildUniformLayout(): void;
  100858. /**
  100859. * Unbinds the textures.
  100860. */
  100861. unbind(): void;
  100862. /**
  100863. * Binds the submesh data.
  100864. * @param world - The world matrix.
  100865. * @param mesh - The BJS mesh.
  100866. * @param subMesh - A submesh of the BJS mesh.
  100867. */
  100868. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100869. /**
  100870. * Returns the animatable textures.
  100871. * @returns - Array of animatable textures.
  100872. */
  100873. getAnimatables(): IAnimatable[];
  100874. /**
  100875. * Returns the texture used for reflections.
  100876. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  100877. */
  100878. private _getReflectionTexture;
  100879. /**
  100880. * Returns the texture used for refraction or null if none is used.
  100881. * @returns - Refection texture if present. If no refraction texture and refraction
  100882. * is linked with transparency, returns environment texture. Otherwise, returns null.
  100883. */
  100884. private _getRefractionTexture;
  100885. /**
  100886. * Returns an array of the actively used textures.
  100887. * @returns - Array of BaseTextures
  100888. */
  100889. getActiveTextures(): BaseTexture[];
  100890. /**
  100891. * Checks to see if a texture is used in the material.
  100892. * @param texture - Base texture to use.
  100893. * @returns - Boolean specifying if a texture is used in the material.
  100894. */
  100895. hasTexture(texture: BaseTexture): boolean;
  100896. /**
  100897. * Disposes the resources of the material.
  100898. * @param forceDisposeEffect - Forces the disposal of effects.
  100899. * @param forceDisposeTextures - Forces the disposal of all textures.
  100900. */
  100901. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100902. }
  100903. }
  100904. declare module BABYLON {
  100905. /**
  100906. * The Physically based material of BJS.
  100907. *
  100908. * This offers the main features of a standard PBR material.
  100909. * For more information, please refer to the documentation :
  100910. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100911. */
  100912. export class PBRMaterial extends PBRBaseMaterial {
  100913. /**
  100914. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100915. */
  100916. static readonly PBRMATERIAL_OPAQUE: number;
  100917. /**
  100918. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100919. */
  100920. static readonly PBRMATERIAL_ALPHATEST: number;
  100921. /**
  100922. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100923. */
  100924. static readonly PBRMATERIAL_ALPHABLEND: number;
  100925. /**
  100926. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100927. * They are also discarded below the alpha cutoff threshold to improve performances.
  100928. */
  100929. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100930. /**
  100931. * Defines the default value of how much AO map is occluding the analytical lights
  100932. * (point spot...).
  100933. */
  100934. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100935. /**
  100936. * Intensity of the direct lights e.g. the four lights available in your scene.
  100937. * This impacts both the direct diffuse and specular highlights.
  100938. */
  100939. directIntensity: number;
  100940. /**
  100941. * Intensity of the emissive part of the material.
  100942. * This helps controlling the emissive effect without modifying the emissive color.
  100943. */
  100944. emissiveIntensity: number;
  100945. /**
  100946. * Intensity of the environment e.g. how much the environment will light the object
  100947. * either through harmonics for rough material or through the refelction for shiny ones.
  100948. */
  100949. environmentIntensity: number;
  100950. /**
  100951. * This is a special control allowing the reduction of the specular highlights coming from the
  100952. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100953. */
  100954. specularIntensity: number;
  100955. /**
  100956. * Debug Control allowing disabling the bump map on this material.
  100957. */
  100958. disableBumpMap: boolean;
  100959. /**
  100960. * AKA Diffuse Texture in standard nomenclature.
  100961. */
  100962. albedoTexture: BaseTexture;
  100963. /**
  100964. * AKA Occlusion Texture in other nomenclature.
  100965. */
  100966. ambientTexture: BaseTexture;
  100967. /**
  100968. * AKA Occlusion Texture Intensity in other nomenclature.
  100969. */
  100970. ambientTextureStrength: number;
  100971. /**
  100972. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100973. * 1 means it completely occludes it
  100974. * 0 mean it has no impact
  100975. */
  100976. ambientTextureImpactOnAnalyticalLights: number;
  100977. /**
  100978. * Stores the alpha values in a texture.
  100979. */
  100980. opacityTexture: BaseTexture;
  100981. /**
  100982. * Stores the reflection values in a texture.
  100983. */
  100984. reflectionTexture: Nullable<BaseTexture>;
  100985. /**
  100986. * Stores the emissive values in a texture.
  100987. */
  100988. emissiveTexture: BaseTexture;
  100989. /**
  100990. * AKA Specular texture in other nomenclature.
  100991. */
  100992. reflectivityTexture: BaseTexture;
  100993. /**
  100994. * Used to switch from specular/glossiness to metallic/roughness workflow.
  100995. */
  100996. metallicTexture: BaseTexture;
  100997. /**
  100998. * Specifies the metallic scalar of the metallic/roughness workflow.
  100999. * Can also be used to scale the metalness values of the metallic texture.
  101000. */
  101001. metallic: Nullable<number>;
  101002. /**
  101003. * Specifies the roughness scalar of the metallic/roughness workflow.
  101004. * Can also be used to scale the roughness values of the metallic texture.
  101005. */
  101006. roughness: Nullable<number>;
  101007. /**
  101008. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101009. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101010. */
  101011. microSurfaceTexture: BaseTexture;
  101012. /**
  101013. * Stores surface normal data used to displace a mesh in a texture.
  101014. */
  101015. bumpTexture: BaseTexture;
  101016. /**
  101017. * Stores the pre-calculated light information of a mesh in a texture.
  101018. */
  101019. lightmapTexture: BaseTexture;
  101020. /**
  101021. * Stores the refracted light information in a texture.
  101022. */
  101023. refractionTexture: BaseTexture;
  101024. /**
  101025. * The color of a material in ambient lighting.
  101026. */
  101027. ambientColor: Color3;
  101028. /**
  101029. * AKA Diffuse Color in other nomenclature.
  101030. */
  101031. albedoColor: Color3;
  101032. /**
  101033. * AKA Specular Color in other nomenclature.
  101034. */
  101035. reflectivityColor: Color3;
  101036. /**
  101037. * The color reflected from the material.
  101038. */
  101039. reflectionColor: Color3;
  101040. /**
  101041. * The color emitted from the material.
  101042. */
  101043. emissiveColor: Color3;
  101044. /**
  101045. * AKA Glossiness in other nomenclature.
  101046. */
  101047. microSurface: number;
  101048. /**
  101049. * source material index of refraction (IOR)' / 'destination material IOR.
  101050. */
  101051. indexOfRefraction: number;
  101052. /**
  101053. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101054. */
  101055. invertRefractionY: boolean;
  101056. /**
  101057. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101058. * Materials half opaque for instance using refraction could benefit from this control.
  101059. */
  101060. linkRefractionWithTransparency: boolean;
  101061. /**
  101062. * If true, the light map contains occlusion information instead of lighting info.
  101063. */
  101064. useLightmapAsShadowmap: boolean;
  101065. /**
  101066. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101067. */
  101068. useAlphaFromAlbedoTexture: boolean;
  101069. /**
  101070. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101071. */
  101072. forceAlphaTest: boolean;
  101073. /**
  101074. * Defines the alpha limits in alpha test mode.
  101075. */
  101076. alphaCutOff: number;
  101077. /**
  101078. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101079. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101080. */
  101081. useSpecularOverAlpha: boolean;
  101082. /**
  101083. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101084. */
  101085. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101086. /**
  101087. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101088. */
  101089. useRoughnessFromMetallicTextureAlpha: boolean;
  101090. /**
  101091. * Specifies if the metallic texture contains the roughness information in its green channel.
  101092. */
  101093. useRoughnessFromMetallicTextureGreen: boolean;
  101094. /**
  101095. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101096. */
  101097. useMetallnessFromMetallicTextureBlue: boolean;
  101098. /**
  101099. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101100. */
  101101. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101102. /**
  101103. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101104. */
  101105. useAmbientInGrayScale: boolean;
  101106. /**
  101107. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101108. * The material will try to infer what glossiness each pixel should be.
  101109. */
  101110. useAutoMicroSurfaceFromReflectivityMap: boolean;
  101111. /**
  101112. * BJS is using an harcoded light falloff based on a manually sets up range.
  101113. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101114. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101115. */
  101116. /**
  101117. * BJS is using an harcoded light falloff based on a manually sets up range.
  101118. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101119. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101120. */
  101121. usePhysicalLightFalloff: boolean;
  101122. /**
  101123. * In order to support the falloff compatibility with gltf, a special mode has been added
  101124. * to reproduce the gltf light falloff.
  101125. */
  101126. /**
  101127. * In order to support the falloff compatibility with gltf, a special mode has been added
  101128. * to reproduce the gltf light falloff.
  101129. */
  101130. useGLTFLightFalloff: boolean;
  101131. /**
  101132. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101133. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101134. */
  101135. useRadianceOverAlpha: boolean;
  101136. /**
  101137. * Allows using an object space normal map (instead of tangent space).
  101138. */
  101139. useObjectSpaceNormalMap: boolean;
  101140. /**
  101141. * Allows using the bump map in parallax mode.
  101142. */
  101143. useParallax: boolean;
  101144. /**
  101145. * Allows using the bump map in parallax occlusion mode.
  101146. */
  101147. useParallaxOcclusion: boolean;
  101148. /**
  101149. * Controls the scale bias of the parallax mode.
  101150. */
  101151. parallaxScaleBias: number;
  101152. /**
  101153. * If sets to true, disables all the lights affecting the material.
  101154. */
  101155. disableLighting: boolean;
  101156. /**
  101157. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101158. */
  101159. forceIrradianceInFragment: boolean;
  101160. /**
  101161. * Number of Simultaneous lights allowed on the material.
  101162. */
  101163. maxSimultaneousLights: number;
  101164. /**
  101165. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101166. */
  101167. invertNormalMapX: boolean;
  101168. /**
  101169. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101170. */
  101171. invertNormalMapY: boolean;
  101172. /**
  101173. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101174. */
  101175. twoSidedLighting: boolean;
  101176. /**
  101177. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101178. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101179. */
  101180. useAlphaFresnel: boolean;
  101181. /**
  101182. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101183. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101184. */
  101185. useLinearAlphaFresnel: boolean;
  101186. /**
  101187. * Let user defines the brdf lookup texture used for IBL.
  101188. * A default 8bit version is embedded but you could point at :
  101189. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  101190. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101191. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101192. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101193. */
  101194. environmentBRDFTexture: Nullable<BaseTexture>;
  101195. /**
  101196. * Force normal to face away from face.
  101197. */
  101198. forceNormalForward: boolean;
  101199. /**
  101200. * Enables specular anti aliasing in the PBR shader.
  101201. * It will both interacts on the Geometry for analytical and IBL lighting.
  101202. * It also prefilter the roughness map based on the bump values.
  101203. */
  101204. enableSpecularAntiAliasing: boolean;
  101205. /**
  101206. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101207. * makes the reflect vector face the model (under horizon).
  101208. */
  101209. useHorizonOcclusion: boolean;
  101210. /**
  101211. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101212. * too much the area relying on ambient texture to define their ambient occlusion.
  101213. */
  101214. useRadianceOcclusion: boolean;
  101215. /**
  101216. * If set to true, no lighting calculations will be applied.
  101217. */
  101218. unlit: boolean;
  101219. /**
  101220. * Gets the image processing configuration used either in this material.
  101221. */
  101222. /**
  101223. * Sets the Default image processing configuration used either in the this material.
  101224. *
  101225. * If sets to null, the scene one is in use.
  101226. */
  101227. imageProcessingConfiguration: ImageProcessingConfiguration;
  101228. /**
  101229. * Gets wether the color curves effect is enabled.
  101230. */
  101231. /**
  101232. * Sets wether the color curves effect is enabled.
  101233. */
  101234. cameraColorCurvesEnabled: boolean;
  101235. /**
  101236. * Gets wether the color grading effect is enabled.
  101237. */
  101238. /**
  101239. * Gets wether the color grading effect is enabled.
  101240. */
  101241. cameraColorGradingEnabled: boolean;
  101242. /**
  101243. * Gets wether tonemapping is enabled or not.
  101244. */
  101245. /**
  101246. * Sets wether tonemapping is enabled or not
  101247. */
  101248. cameraToneMappingEnabled: boolean;
  101249. /**
  101250. * The camera exposure used on this material.
  101251. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101252. * This corresponds to a photographic exposure.
  101253. */
  101254. /**
  101255. * The camera exposure used on this material.
  101256. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101257. * This corresponds to a photographic exposure.
  101258. */
  101259. cameraExposure: number;
  101260. /**
  101261. * Gets The camera contrast used on this material.
  101262. */
  101263. /**
  101264. * Sets The camera contrast used on this material.
  101265. */
  101266. cameraContrast: number;
  101267. /**
  101268. * Gets the Color Grading 2D Lookup Texture.
  101269. */
  101270. /**
  101271. * Sets the Color Grading 2D Lookup Texture.
  101272. */
  101273. cameraColorGradingTexture: Nullable<BaseTexture>;
  101274. /**
  101275. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101276. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101277. * 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;
  101278. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101279. */
  101280. /**
  101281. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101282. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101283. * 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;
  101284. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101285. */
  101286. cameraColorCurves: Nullable<ColorCurves>;
  101287. /**
  101288. * Instantiates a new PBRMaterial instance.
  101289. *
  101290. * @param name The material name
  101291. * @param scene The scene the material will be use in.
  101292. */
  101293. constructor(name: string, scene: Scene);
  101294. /**
  101295. * Returns the name of this material class.
  101296. */
  101297. getClassName(): string;
  101298. /**
  101299. * Makes a duplicate of the current material.
  101300. * @param name - name to use for the new material.
  101301. */
  101302. clone(name: string): PBRMaterial;
  101303. /**
  101304. * Serializes this PBR Material.
  101305. * @returns - An object with the serialized material.
  101306. */
  101307. serialize(): any;
  101308. /**
  101309. * Parses a PBR Material from a serialized object.
  101310. * @param source - Serialized object.
  101311. * @param scene - BJS scene instance.
  101312. * @param rootUrl - url for the scene object
  101313. * @returns - PBRMaterial
  101314. */
  101315. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  101316. }
  101317. }
  101318. declare module BABYLON {
  101319. /** @hidden */
  101320. export var _forceSceneHelpersToBundle: boolean;
  101321. interface Scene {
  101322. /**
  101323. * Creates a default light for the scene.
  101324. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  101325. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  101326. */
  101327. createDefaultLight(replace?: boolean): void;
  101328. /**
  101329. * Creates a default camera for the scene.
  101330. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  101331. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  101332. * @param replace has default false, when true replaces the active camera in the scene
  101333. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  101334. */
  101335. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  101336. /**
  101337. * Creates a default camera and a default light.
  101338. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  101339. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  101340. * @param replace has the default false, when true replaces the active camera/light in the scene
  101341. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  101342. */
  101343. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  101344. /**
  101345. * Creates a new sky box
  101346. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  101347. * @param environmentTexture defines the texture to use as environment texture
  101348. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  101349. * @param scale defines the overall scale of the skybox
  101350. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  101351. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  101352. * @returns a new mesh holding the sky box
  101353. */
  101354. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  101355. /**
  101356. * Creates a new environment
  101357. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  101358. * @param options defines the options you can use to configure the environment
  101359. * @returns the new EnvironmentHelper
  101360. */
  101361. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  101362. /**
  101363. * Creates a new VREXperienceHelper
  101364. * @see http://doc.babylonjs.com/how_to/webvr_helper
  101365. * @param webVROptions defines the options used to create the new VREXperienceHelper
  101366. * @returns a new VREXperienceHelper
  101367. */
  101368. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  101369. /**
  101370. * Creates a new XREXperienceHelper
  101371. * @see http://doc.babylonjs.com/how_to/webxr
  101372. * @returns a promise for a new XREXperienceHelper
  101373. */
  101374. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  101375. }
  101376. }
  101377. declare module BABYLON {
  101378. /**
  101379. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  101380. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  101381. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  101382. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  101383. */
  101384. export class VideoDome extends TransformNode {
  101385. /**
  101386. * Define the video source as a Monoscopic panoramic 360 video.
  101387. */
  101388. static readonly MODE_MONOSCOPIC: number;
  101389. /**
  101390. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  101391. */
  101392. static readonly MODE_TOPBOTTOM: number;
  101393. /**
  101394. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  101395. */
  101396. static readonly MODE_SIDEBYSIDE: number;
  101397. private _useDirectMapping;
  101398. /**
  101399. * The video texture being displayed on the sphere
  101400. */
  101401. protected _videoTexture: VideoTexture;
  101402. /**
  101403. * Gets the video texture being displayed on the sphere
  101404. */
  101405. readonly videoTexture: VideoTexture;
  101406. /**
  101407. * The skybox material
  101408. */
  101409. protected _material: BackgroundMaterial;
  101410. /**
  101411. * The surface used for the skybox
  101412. */
  101413. protected _mesh: Mesh;
  101414. /**
  101415. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101416. * Also see the options.resolution property.
  101417. */
  101418. fovMultiplier: number;
  101419. private _videoMode;
  101420. /**
  101421. * Gets or set the current video mode for the video. It can be:
  101422. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  101423. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  101424. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  101425. */
  101426. videoMode: number;
  101427. /**
  101428. * Oberserver used in Stereoscopic VR Mode.
  101429. */
  101430. private _onBeforeCameraRenderObserver;
  101431. /**
  101432. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  101433. * @param name Element's name, child elements will append suffixes for their own names.
  101434. * @param urlsOrVideo defines the url(s) or the video element to use
  101435. * @param options An object containing optional or exposed sub element properties
  101436. */
  101437. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  101438. resolution?: number;
  101439. clickToPlay?: boolean;
  101440. autoPlay?: boolean;
  101441. loop?: boolean;
  101442. size?: number;
  101443. poster?: string;
  101444. useDirectMapping?: boolean;
  101445. }, scene: Scene);
  101446. private _changeVideoMode;
  101447. /**
  101448. * Releases resources associated with this node.
  101449. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101450. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101451. */
  101452. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101453. }
  101454. }
  101455. declare module BABYLON {
  101456. /**
  101457. * This class can be used to get instrumentation data from a Babylon engine
  101458. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101459. */
  101460. export class EngineInstrumentation implements IDisposable {
  101461. /**
  101462. * Define the instrumented engine.
  101463. */
  101464. engine: Engine;
  101465. private _captureGPUFrameTime;
  101466. private _gpuFrameTimeToken;
  101467. private _gpuFrameTime;
  101468. private _captureShaderCompilationTime;
  101469. private _shaderCompilationTime;
  101470. private _onBeginFrameObserver;
  101471. private _onEndFrameObserver;
  101472. private _onBeforeShaderCompilationObserver;
  101473. private _onAfterShaderCompilationObserver;
  101474. /**
  101475. * Gets the perf counter used for GPU frame time
  101476. */
  101477. readonly gpuFrameTimeCounter: PerfCounter;
  101478. /**
  101479. * Gets the GPU frame time capture status
  101480. */
  101481. /**
  101482. * Enable or disable the GPU frame time capture
  101483. */
  101484. captureGPUFrameTime: boolean;
  101485. /**
  101486. * Gets the perf counter used for shader compilation time
  101487. */
  101488. readonly shaderCompilationTimeCounter: PerfCounter;
  101489. /**
  101490. * Gets the shader compilation time capture status
  101491. */
  101492. /**
  101493. * Enable or disable the shader compilation time capture
  101494. */
  101495. captureShaderCompilationTime: boolean;
  101496. /**
  101497. * Instantiates a new engine instrumentation.
  101498. * This class can be used to get instrumentation data from a Babylon engine
  101499. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101500. * @param engine Defines the engine to instrument
  101501. */
  101502. constructor(
  101503. /**
  101504. * Define the instrumented engine.
  101505. */
  101506. engine: Engine);
  101507. /**
  101508. * Dispose and release associated resources.
  101509. */
  101510. dispose(): void;
  101511. }
  101512. }
  101513. declare module BABYLON {
  101514. /**
  101515. * This class can be used to get instrumentation data from a Babylon engine
  101516. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  101517. */
  101518. export class SceneInstrumentation implements IDisposable {
  101519. /**
  101520. * Defines the scene to instrument
  101521. */
  101522. scene: Scene;
  101523. private _captureActiveMeshesEvaluationTime;
  101524. private _activeMeshesEvaluationTime;
  101525. private _captureRenderTargetsRenderTime;
  101526. private _renderTargetsRenderTime;
  101527. private _captureFrameTime;
  101528. private _frameTime;
  101529. private _captureRenderTime;
  101530. private _renderTime;
  101531. private _captureInterFrameTime;
  101532. private _interFrameTime;
  101533. private _captureParticlesRenderTime;
  101534. private _particlesRenderTime;
  101535. private _captureSpritesRenderTime;
  101536. private _spritesRenderTime;
  101537. private _capturePhysicsTime;
  101538. private _physicsTime;
  101539. private _captureAnimationsTime;
  101540. private _animationsTime;
  101541. private _captureCameraRenderTime;
  101542. private _cameraRenderTime;
  101543. private _onBeforeActiveMeshesEvaluationObserver;
  101544. private _onAfterActiveMeshesEvaluationObserver;
  101545. private _onBeforeRenderTargetsRenderObserver;
  101546. private _onAfterRenderTargetsRenderObserver;
  101547. private _onAfterRenderObserver;
  101548. private _onBeforeDrawPhaseObserver;
  101549. private _onAfterDrawPhaseObserver;
  101550. private _onBeforeAnimationsObserver;
  101551. private _onBeforeParticlesRenderingObserver;
  101552. private _onAfterParticlesRenderingObserver;
  101553. private _onBeforeSpritesRenderingObserver;
  101554. private _onAfterSpritesRenderingObserver;
  101555. private _onBeforePhysicsObserver;
  101556. private _onAfterPhysicsObserver;
  101557. private _onAfterAnimationsObserver;
  101558. private _onBeforeCameraRenderObserver;
  101559. private _onAfterCameraRenderObserver;
  101560. /**
  101561. * Gets the perf counter used for active meshes evaluation time
  101562. */
  101563. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  101564. /**
  101565. * Gets the active meshes evaluation time capture status
  101566. */
  101567. /**
  101568. * Enable or disable the active meshes evaluation time capture
  101569. */
  101570. captureActiveMeshesEvaluationTime: boolean;
  101571. /**
  101572. * Gets the perf counter used for render targets render time
  101573. */
  101574. readonly renderTargetsRenderTimeCounter: PerfCounter;
  101575. /**
  101576. * Gets the render targets render time capture status
  101577. */
  101578. /**
  101579. * Enable or disable the render targets render time capture
  101580. */
  101581. captureRenderTargetsRenderTime: boolean;
  101582. /**
  101583. * Gets the perf counter used for particles render time
  101584. */
  101585. readonly particlesRenderTimeCounter: PerfCounter;
  101586. /**
  101587. * Gets the particles render time capture status
  101588. */
  101589. /**
  101590. * Enable or disable the particles render time capture
  101591. */
  101592. captureParticlesRenderTime: boolean;
  101593. /**
  101594. * Gets the perf counter used for sprites render time
  101595. */
  101596. readonly spritesRenderTimeCounter: PerfCounter;
  101597. /**
  101598. * Gets the sprites render time capture status
  101599. */
  101600. /**
  101601. * Enable or disable the sprites render time capture
  101602. */
  101603. captureSpritesRenderTime: boolean;
  101604. /**
  101605. * Gets the perf counter used for physics time
  101606. */
  101607. readonly physicsTimeCounter: PerfCounter;
  101608. /**
  101609. * Gets the physics time capture status
  101610. */
  101611. /**
  101612. * Enable or disable the physics time capture
  101613. */
  101614. capturePhysicsTime: boolean;
  101615. /**
  101616. * Gets the perf counter used for animations time
  101617. */
  101618. readonly animationsTimeCounter: PerfCounter;
  101619. /**
  101620. * Gets the animations time capture status
  101621. */
  101622. /**
  101623. * Enable or disable the animations time capture
  101624. */
  101625. captureAnimationsTime: boolean;
  101626. /**
  101627. * Gets the perf counter used for frame time capture
  101628. */
  101629. readonly frameTimeCounter: PerfCounter;
  101630. /**
  101631. * Gets the frame time capture status
  101632. */
  101633. /**
  101634. * Enable or disable the frame time capture
  101635. */
  101636. captureFrameTime: boolean;
  101637. /**
  101638. * Gets the perf counter used for inter-frames time capture
  101639. */
  101640. readonly interFrameTimeCounter: PerfCounter;
  101641. /**
  101642. * Gets the inter-frames time capture status
  101643. */
  101644. /**
  101645. * Enable or disable the inter-frames time capture
  101646. */
  101647. captureInterFrameTime: boolean;
  101648. /**
  101649. * Gets the perf counter used for render time capture
  101650. */
  101651. readonly renderTimeCounter: PerfCounter;
  101652. /**
  101653. * Gets the render time capture status
  101654. */
  101655. /**
  101656. * Enable or disable the render time capture
  101657. */
  101658. captureRenderTime: boolean;
  101659. /**
  101660. * Gets the perf counter used for camera render time capture
  101661. */
  101662. readonly cameraRenderTimeCounter: PerfCounter;
  101663. /**
  101664. * Gets the camera render time capture status
  101665. */
  101666. /**
  101667. * Enable or disable the camera render time capture
  101668. */
  101669. captureCameraRenderTime: boolean;
  101670. /**
  101671. * Gets the perf counter used for draw calls
  101672. */
  101673. readonly drawCallsCounter: PerfCounter;
  101674. /**
  101675. * Gets the perf counter used for texture collisions
  101676. */
  101677. readonly textureCollisionsCounter: PerfCounter;
  101678. /**
  101679. * Instantiates a new scene instrumentation.
  101680. * This class can be used to get instrumentation data from a Babylon engine
  101681. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  101682. * @param scene Defines the scene to instrument
  101683. */
  101684. constructor(
  101685. /**
  101686. * Defines the scene to instrument
  101687. */
  101688. scene: Scene);
  101689. /**
  101690. * Dispose and release associated resources.
  101691. */
  101692. dispose(): void;
  101693. }
  101694. }
  101695. declare module BABYLON {
  101696. /** @hidden */
  101697. export var glowMapGenerationPixelShader: {
  101698. name: string;
  101699. shader: string;
  101700. };
  101701. }
  101702. declare module BABYLON {
  101703. /** @hidden */
  101704. export var glowMapGenerationVertexShader: {
  101705. name: string;
  101706. shader: string;
  101707. };
  101708. }
  101709. declare module BABYLON {
  101710. /**
  101711. * Effect layer options. This helps customizing the behaviour
  101712. * of the effect layer.
  101713. */
  101714. export interface IEffectLayerOptions {
  101715. /**
  101716. * Multiplication factor apply to the canvas size to compute the render target size
  101717. * used to generated the objects (the smaller the faster).
  101718. */
  101719. mainTextureRatio: number;
  101720. /**
  101721. * Enforces a fixed size texture to ensure effect stability across devices.
  101722. */
  101723. mainTextureFixedSize?: number;
  101724. /**
  101725. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  101726. */
  101727. alphaBlendingMode: number;
  101728. /**
  101729. * The camera attached to the layer.
  101730. */
  101731. camera: Nullable<Camera>;
  101732. /**
  101733. * The rendering group to draw the layer in.
  101734. */
  101735. renderingGroupId: number;
  101736. }
  101737. /**
  101738. * The effect layer Helps adding post process effect blended with the main pass.
  101739. *
  101740. * This can be for instance use to generate glow or higlight effects on the scene.
  101741. *
  101742. * The effect layer class can not be used directly and is intented to inherited from to be
  101743. * customized per effects.
  101744. */
  101745. export abstract class EffectLayer {
  101746. private _vertexBuffers;
  101747. private _indexBuffer;
  101748. private _cachedDefines;
  101749. private _effectLayerMapGenerationEffect;
  101750. private _effectLayerOptions;
  101751. private _mergeEffect;
  101752. protected _scene: Scene;
  101753. protected _engine: Engine;
  101754. protected _maxSize: number;
  101755. protected _mainTextureDesiredSize: ISize;
  101756. protected _mainTexture: RenderTargetTexture;
  101757. protected _shouldRender: boolean;
  101758. protected _postProcesses: PostProcess[];
  101759. protected _textures: BaseTexture[];
  101760. protected _emissiveTextureAndColor: {
  101761. texture: Nullable<BaseTexture>;
  101762. color: Color4;
  101763. };
  101764. /**
  101765. * The name of the layer
  101766. */
  101767. name: string;
  101768. /**
  101769. * The clear color of the texture used to generate the glow map.
  101770. */
  101771. neutralColor: Color4;
  101772. /**
  101773. * Specifies wether the highlight layer is enabled or not.
  101774. */
  101775. isEnabled: boolean;
  101776. /**
  101777. * Gets the camera attached to the layer.
  101778. */
  101779. readonly camera: Nullable<Camera>;
  101780. /**
  101781. * Gets the rendering group id the layer should render in.
  101782. */
  101783. readonly renderingGroupId: number;
  101784. /**
  101785. * An event triggered when the effect layer has been disposed.
  101786. */
  101787. onDisposeObservable: Observable<EffectLayer>;
  101788. /**
  101789. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  101790. */
  101791. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  101792. /**
  101793. * An event triggered when the generated texture is being merged in the scene.
  101794. */
  101795. onBeforeComposeObservable: Observable<EffectLayer>;
  101796. /**
  101797. * An event triggered when the generated texture has been merged in the scene.
  101798. */
  101799. onAfterComposeObservable: Observable<EffectLayer>;
  101800. /**
  101801. * An event triggered when the efffect layer changes its size.
  101802. */
  101803. onSizeChangedObservable: Observable<EffectLayer>;
  101804. /** @hidden */
  101805. static _SceneComponentInitialization: (scene: Scene) => void;
  101806. /**
  101807. * Instantiates a new effect Layer and references it in the scene.
  101808. * @param name The name of the layer
  101809. * @param scene The scene to use the layer in
  101810. */
  101811. constructor(
  101812. /** The Friendly of the effect in the scene */
  101813. name: string, scene: Scene);
  101814. /**
  101815. * Get the effect name of the layer.
  101816. * @return The effect name
  101817. */
  101818. abstract getEffectName(): string;
  101819. /**
  101820. * Checks for the readiness of the element composing the layer.
  101821. * @param subMesh the mesh to check for
  101822. * @param useInstances specify wether or not to use instances to render the mesh
  101823. * @return true if ready otherwise, false
  101824. */
  101825. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  101826. /**
  101827. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  101828. * @returns true if the effect requires stencil during the main canvas render pass.
  101829. */
  101830. abstract needStencil(): boolean;
  101831. /**
  101832. * Create the merge effect. This is the shader use to blit the information back
  101833. * to the main canvas at the end of the scene rendering.
  101834. * @returns The effect containing the shader used to merge the effect on the main canvas
  101835. */
  101836. protected abstract _createMergeEffect(): Effect;
  101837. /**
  101838. * Creates the render target textures and post processes used in the effect layer.
  101839. */
  101840. protected abstract _createTextureAndPostProcesses(): void;
  101841. /**
  101842. * Implementation specific of rendering the generating effect on the main canvas.
  101843. * @param effect The effect used to render through
  101844. */
  101845. protected abstract _internalRender(effect: Effect): void;
  101846. /**
  101847. * Sets the required values for both the emissive texture and and the main color.
  101848. */
  101849. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  101850. /**
  101851. * Free any resources and references associated to a mesh.
  101852. * Internal use
  101853. * @param mesh The mesh to free.
  101854. */
  101855. abstract _disposeMesh(mesh: Mesh): void;
  101856. /**
  101857. * Serializes this layer (Glow or Highlight for example)
  101858. * @returns a serialized layer object
  101859. */
  101860. abstract serialize?(): any;
  101861. /**
  101862. * Initializes the effect layer with the required options.
  101863. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  101864. */
  101865. protected _init(options: Partial<IEffectLayerOptions>): void;
  101866. /**
  101867. * Generates the index buffer of the full screen quad blending to the main canvas.
  101868. */
  101869. private _generateIndexBuffer;
  101870. /**
  101871. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  101872. */
  101873. private _genrateVertexBuffer;
  101874. /**
  101875. * Sets the main texture desired size which is the closest power of two
  101876. * of the engine canvas size.
  101877. */
  101878. private _setMainTextureSize;
  101879. /**
  101880. * Creates the main texture for the effect layer.
  101881. */
  101882. protected _createMainTexture(): void;
  101883. /**
  101884. * Adds specific effects defines.
  101885. * @param defines The defines to add specifics to.
  101886. */
  101887. protected _addCustomEffectDefines(defines: string[]): void;
  101888. /**
  101889. * Checks for the readiness of the element composing the layer.
  101890. * @param subMesh the mesh to check for
  101891. * @param useInstances specify wether or not to use instances to render the mesh
  101892. * @param emissiveTexture the associated emissive texture used to generate the glow
  101893. * @return true if ready otherwise, false
  101894. */
  101895. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  101896. /**
  101897. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  101898. */
  101899. render(): void;
  101900. /**
  101901. * Determine if a given mesh will be used in the current effect.
  101902. * @param mesh mesh to test
  101903. * @returns true if the mesh will be used
  101904. */
  101905. hasMesh(mesh: AbstractMesh): boolean;
  101906. /**
  101907. * Returns true if the layer contains information to display, otherwise false.
  101908. * @returns true if the glow layer should be rendered
  101909. */
  101910. shouldRender(): boolean;
  101911. /**
  101912. * Returns true if the mesh should render, otherwise false.
  101913. * @param mesh The mesh to render
  101914. * @returns true if it should render otherwise false
  101915. */
  101916. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  101917. /**
  101918. * Returns true if the mesh can be rendered, otherwise false.
  101919. * @param mesh The mesh to render
  101920. * @param material The material used on the mesh
  101921. * @returns true if it can be rendered otherwise false
  101922. */
  101923. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  101924. /**
  101925. * Returns true if the mesh should render, otherwise false.
  101926. * @param mesh The mesh to render
  101927. * @returns true if it should render otherwise false
  101928. */
  101929. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  101930. /**
  101931. * Renders the submesh passed in parameter to the generation map.
  101932. */
  101933. protected _renderSubMesh(subMesh: SubMesh): void;
  101934. /**
  101935. * Rebuild the required buffers.
  101936. * @hidden Internal use only.
  101937. */
  101938. _rebuild(): void;
  101939. /**
  101940. * Dispose only the render target textures and post process.
  101941. */
  101942. private _disposeTextureAndPostProcesses;
  101943. /**
  101944. * Dispose the highlight layer and free resources.
  101945. */
  101946. dispose(): void;
  101947. /**
  101948. * Gets the class name of the effect layer
  101949. * @returns the string with the class name of the effect layer
  101950. */
  101951. getClassName(): string;
  101952. /**
  101953. * Creates an effect layer from parsed effect layer data
  101954. * @param parsedEffectLayer defines effect layer data
  101955. * @param scene defines the current scene
  101956. * @param rootUrl defines the root URL containing the effect layer information
  101957. * @returns a parsed effect Layer
  101958. */
  101959. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  101960. }
  101961. }
  101962. declare module BABYLON {
  101963. interface AbstractScene {
  101964. /**
  101965. * The list of effect layers (highlights/glow) added to the scene
  101966. * @see http://doc.babylonjs.com/how_to/highlight_layer
  101967. * @see http://doc.babylonjs.com/how_to/glow_layer
  101968. */
  101969. effectLayers: Array<EffectLayer>;
  101970. /**
  101971. * Removes the given effect layer from this scene.
  101972. * @param toRemove defines the effect layer to remove
  101973. * @returns the index of the removed effect layer
  101974. */
  101975. removeEffectLayer(toRemove: EffectLayer): number;
  101976. /**
  101977. * Adds the given effect layer to this scene
  101978. * @param newEffectLayer defines the effect layer to add
  101979. */
  101980. addEffectLayer(newEffectLayer: EffectLayer): void;
  101981. }
  101982. /**
  101983. * Defines the layer scene component responsible to manage any effect layers
  101984. * in a given scene.
  101985. */
  101986. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  101987. /**
  101988. * The component name helpfull to identify the component in the list of scene components.
  101989. */
  101990. readonly name: string;
  101991. /**
  101992. * The scene the component belongs to.
  101993. */
  101994. scene: Scene;
  101995. private _engine;
  101996. private _renderEffects;
  101997. private _needStencil;
  101998. private _previousStencilState;
  101999. /**
  102000. * Creates a new instance of the component for the given scene
  102001. * @param scene Defines the scene to register the component in
  102002. */
  102003. constructor(scene: Scene);
  102004. /**
  102005. * Registers the component in a given scene
  102006. */
  102007. register(): void;
  102008. /**
  102009. * Rebuilds the elements related to this component in case of
  102010. * context lost for instance.
  102011. */
  102012. rebuild(): void;
  102013. /**
  102014. * Serializes the component data to the specified json object
  102015. * @param serializationObject The object to serialize to
  102016. */
  102017. serialize(serializationObject: any): void;
  102018. /**
  102019. * Adds all the element from the container to the scene
  102020. * @param container the container holding the elements
  102021. */
  102022. addFromContainer(container: AbstractScene): void;
  102023. /**
  102024. * Removes all the elements in the container from the scene
  102025. * @param container contains the elements to remove
  102026. */
  102027. removeFromContainer(container: AbstractScene): void;
  102028. /**
  102029. * Disposes the component and the associated ressources.
  102030. */
  102031. dispose(): void;
  102032. private _isReadyForMesh;
  102033. private _renderMainTexture;
  102034. private _setStencil;
  102035. private _setStencilBack;
  102036. private _draw;
  102037. private _drawCamera;
  102038. private _drawRenderingGroup;
  102039. }
  102040. }
  102041. declare module BABYLON {
  102042. /** @hidden */
  102043. export var glowMapMergePixelShader: {
  102044. name: string;
  102045. shader: string;
  102046. };
  102047. }
  102048. declare module BABYLON {
  102049. /** @hidden */
  102050. export var glowMapMergeVertexShader: {
  102051. name: string;
  102052. shader: string;
  102053. };
  102054. }
  102055. declare module BABYLON {
  102056. interface AbstractScene {
  102057. /**
  102058. * Return a the first highlight layer of the scene with a given name.
  102059. * @param name The name of the highlight layer to look for.
  102060. * @return The highlight layer if found otherwise null.
  102061. */
  102062. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  102063. }
  102064. /**
  102065. * Glow layer options. This helps customizing the behaviour
  102066. * of the glow layer.
  102067. */
  102068. export interface IGlowLayerOptions {
  102069. /**
  102070. * Multiplication factor apply to the canvas size to compute the render target size
  102071. * used to generated the glowing objects (the smaller the faster).
  102072. */
  102073. mainTextureRatio: number;
  102074. /**
  102075. * Enforces a fixed size texture to ensure resize independant blur.
  102076. */
  102077. mainTextureFixedSize?: number;
  102078. /**
  102079. * How big is the kernel of the blur texture.
  102080. */
  102081. blurKernelSize: number;
  102082. /**
  102083. * The camera attached to the layer.
  102084. */
  102085. camera: Nullable<Camera>;
  102086. /**
  102087. * Enable MSAA by chosing the number of samples.
  102088. */
  102089. mainTextureSamples?: number;
  102090. /**
  102091. * The rendering group to draw the layer in.
  102092. */
  102093. renderingGroupId: number;
  102094. }
  102095. /**
  102096. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  102097. *
  102098. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  102099. * glowy meshes to your scene.
  102100. *
  102101. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  102102. */
  102103. export class GlowLayer extends EffectLayer {
  102104. /**
  102105. * Effect Name of the layer.
  102106. */
  102107. static readonly EffectName: string;
  102108. /**
  102109. * The default blur kernel size used for the glow.
  102110. */
  102111. static DefaultBlurKernelSize: number;
  102112. /**
  102113. * The default texture size ratio used for the glow.
  102114. */
  102115. static DefaultTextureRatio: number;
  102116. /**
  102117. * Sets the kernel size of the blur.
  102118. */
  102119. /**
  102120. * Gets the kernel size of the blur.
  102121. */
  102122. blurKernelSize: number;
  102123. /**
  102124. * Sets the glow intensity.
  102125. */
  102126. /**
  102127. * Gets the glow intensity.
  102128. */
  102129. intensity: number;
  102130. private _options;
  102131. private _intensity;
  102132. private _horizontalBlurPostprocess1;
  102133. private _verticalBlurPostprocess1;
  102134. private _horizontalBlurPostprocess2;
  102135. private _verticalBlurPostprocess2;
  102136. private _blurTexture1;
  102137. private _blurTexture2;
  102138. private _postProcesses1;
  102139. private _postProcesses2;
  102140. private _includedOnlyMeshes;
  102141. private _excludedMeshes;
  102142. /**
  102143. * Callback used to let the user override the color selection on a per mesh basis
  102144. */
  102145. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  102146. /**
  102147. * Callback used to let the user override the texture selection on a per mesh basis
  102148. */
  102149. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  102150. /**
  102151. * Instantiates a new glow Layer and references it to the scene.
  102152. * @param name The name of the layer
  102153. * @param scene The scene to use the layer in
  102154. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  102155. */
  102156. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  102157. /**
  102158. * Get the effect name of the layer.
  102159. * @return The effect name
  102160. */
  102161. getEffectName(): string;
  102162. /**
  102163. * Create the merge effect. This is the shader use to blit the information back
  102164. * to the main canvas at the end of the scene rendering.
  102165. */
  102166. protected _createMergeEffect(): Effect;
  102167. /**
  102168. * Creates the render target textures and post processes used in the glow layer.
  102169. */
  102170. protected _createTextureAndPostProcesses(): void;
  102171. /**
  102172. * Checks for the readiness of the element composing the layer.
  102173. * @param subMesh the mesh to check for
  102174. * @param useInstances specify wether or not to use instances to render the mesh
  102175. * @param emissiveTexture the associated emissive texture used to generate the glow
  102176. * @return true if ready otherwise, false
  102177. */
  102178. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102179. /**
  102180. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102181. */
  102182. needStencil(): boolean;
  102183. /**
  102184. * Returns true if the mesh can be rendered, otherwise false.
  102185. * @param mesh The mesh to render
  102186. * @param material The material used on the mesh
  102187. * @returns true if it can be rendered otherwise false
  102188. */
  102189. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  102190. /**
  102191. * Implementation specific of rendering the generating effect on the main canvas.
  102192. * @param effect The effect used to render through
  102193. */
  102194. protected _internalRender(effect: Effect): void;
  102195. /**
  102196. * Sets the required values for both the emissive texture and and the main color.
  102197. */
  102198. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102199. /**
  102200. * Returns true if the mesh should render, otherwise false.
  102201. * @param mesh The mesh to render
  102202. * @returns true if it should render otherwise false
  102203. */
  102204. protected _shouldRenderMesh(mesh: Mesh): boolean;
  102205. /**
  102206. * Adds specific effects defines.
  102207. * @param defines The defines to add specifics to.
  102208. */
  102209. protected _addCustomEffectDefines(defines: string[]): void;
  102210. /**
  102211. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  102212. * @param mesh The mesh to exclude from the glow layer
  102213. */
  102214. addExcludedMesh(mesh: Mesh): void;
  102215. /**
  102216. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  102217. * @param mesh The mesh to remove
  102218. */
  102219. removeExcludedMesh(mesh: Mesh): void;
  102220. /**
  102221. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  102222. * @param mesh The mesh to include in the glow layer
  102223. */
  102224. addIncludedOnlyMesh(mesh: Mesh): void;
  102225. /**
  102226. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  102227. * @param mesh The mesh to remove
  102228. */
  102229. removeIncludedOnlyMesh(mesh: Mesh): void;
  102230. /**
  102231. * Determine if a given mesh will be used in the glow layer
  102232. * @param mesh The mesh to test
  102233. * @returns true if the mesh will be highlighted by the current glow layer
  102234. */
  102235. hasMesh(mesh: AbstractMesh): boolean;
  102236. /**
  102237. * Free any resources and references associated to a mesh.
  102238. * Internal use
  102239. * @param mesh The mesh to free.
  102240. * @hidden
  102241. */
  102242. _disposeMesh(mesh: Mesh): void;
  102243. /**
  102244. * Gets the class name of the effect layer
  102245. * @returns the string with the class name of the effect layer
  102246. */
  102247. getClassName(): string;
  102248. /**
  102249. * Serializes this glow layer
  102250. * @returns a serialized glow layer object
  102251. */
  102252. serialize(): any;
  102253. /**
  102254. * Creates a Glow Layer from parsed glow layer data
  102255. * @param parsedGlowLayer defines glow layer data
  102256. * @param scene defines the current scene
  102257. * @param rootUrl defines the root URL containing the glow layer information
  102258. * @returns a parsed Glow Layer
  102259. */
  102260. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  102261. }
  102262. }
  102263. declare module BABYLON {
  102264. /** @hidden */
  102265. export var glowBlurPostProcessPixelShader: {
  102266. name: string;
  102267. shader: string;
  102268. };
  102269. }
  102270. declare module BABYLON {
  102271. interface AbstractScene {
  102272. /**
  102273. * Return a the first highlight layer of the scene with a given name.
  102274. * @param name The name of the highlight layer to look for.
  102275. * @return The highlight layer if found otherwise null.
  102276. */
  102277. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  102278. }
  102279. /**
  102280. * Highlight layer options. This helps customizing the behaviour
  102281. * of the highlight layer.
  102282. */
  102283. export interface IHighlightLayerOptions {
  102284. /**
  102285. * Multiplication factor apply to the canvas size to compute the render target size
  102286. * used to generated the glowing objects (the smaller the faster).
  102287. */
  102288. mainTextureRatio: number;
  102289. /**
  102290. * Enforces a fixed size texture to ensure resize independant blur.
  102291. */
  102292. mainTextureFixedSize?: number;
  102293. /**
  102294. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  102295. * of the picture to blur (the smaller the faster).
  102296. */
  102297. blurTextureSizeRatio: number;
  102298. /**
  102299. * How big in texel of the blur texture is the vertical blur.
  102300. */
  102301. blurVerticalSize: number;
  102302. /**
  102303. * How big in texel of the blur texture is the horizontal blur.
  102304. */
  102305. blurHorizontalSize: number;
  102306. /**
  102307. * Alpha blending mode used to apply the blur. Default is combine.
  102308. */
  102309. alphaBlendingMode: number;
  102310. /**
  102311. * The camera attached to the layer.
  102312. */
  102313. camera: Nullable<Camera>;
  102314. /**
  102315. * Should we display highlight as a solid stroke?
  102316. */
  102317. isStroke?: boolean;
  102318. /**
  102319. * The rendering group to draw the layer in.
  102320. */
  102321. renderingGroupId: number;
  102322. }
  102323. /**
  102324. * The highlight layer Helps adding a glow effect around a mesh.
  102325. *
  102326. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  102327. * glowy meshes to your scene.
  102328. *
  102329. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  102330. */
  102331. export class HighlightLayer extends EffectLayer {
  102332. name: string;
  102333. /**
  102334. * Effect Name of the highlight layer.
  102335. */
  102336. static readonly EffectName: string;
  102337. /**
  102338. * The neutral color used during the preparation of the glow effect.
  102339. * This is black by default as the blend operation is a blend operation.
  102340. */
  102341. static NeutralColor: Color4;
  102342. /**
  102343. * Stencil value used for glowing meshes.
  102344. */
  102345. static GlowingMeshStencilReference: number;
  102346. /**
  102347. * Stencil value used for the other meshes in the scene.
  102348. */
  102349. static NormalMeshStencilReference: number;
  102350. /**
  102351. * Specifies whether or not the inner glow is ACTIVE in the layer.
  102352. */
  102353. innerGlow: boolean;
  102354. /**
  102355. * Specifies whether or not the outer glow is ACTIVE in the layer.
  102356. */
  102357. outerGlow: boolean;
  102358. /**
  102359. * Specifies the horizontal size of the blur.
  102360. */
  102361. /**
  102362. * Gets the horizontal size of the blur.
  102363. */
  102364. blurHorizontalSize: number;
  102365. /**
  102366. * Specifies the vertical size of the blur.
  102367. */
  102368. /**
  102369. * Gets the vertical size of the blur.
  102370. */
  102371. blurVerticalSize: number;
  102372. /**
  102373. * An event triggered when the highlight layer is being blurred.
  102374. */
  102375. onBeforeBlurObservable: Observable<HighlightLayer>;
  102376. /**
  102377. * An event triggered when the highlight layer has been blurred.
  102378. */
  102379. onAfterBlurObservable: Observable<HighlightLayer>;
  102380. private _instanceGlowingMeshStencilReference;
  102381. private _options;
  102382. private _downSamplePostprocess;
  102383. private _horizontalBlurPostprocess;
  102384. private _verticalBlurPostprocess;
  102385. private _blurTexture;
  102386. private _meshes;
  102387. private _excludedMeshes;
  102388. /**
  102389. * Instantiates a new highlight Layer and references it to the scene..
  102390. * @param name The name of the layer
  102391. * @param scene The scene to use the layer in
  102392. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  102393. */
  102394. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  102395. /**
  102396. * Get the effect name of the layer.
  102397. * @return The effect name
  102398. */
  102399. getEffectName(): string;
  102400. /**
  102401. * Create the merge effect. This is the shader use to blit the information back
  102402. * to the main canvas at the end of the scene rendering.
  102403. */
  102404. protected _createMergeEffect(): Effect;
  102405. /**
  102406. * Creates the render target textures and post processes used in the highlight layer.
  102407. */
  102408. protected _createTextureAndPostProcesses(): void;
  102409. /**
  102410. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102411. */
  102412. needStencil(): boolean;
  102413. /**
  102414. * Checks for the readiness of the element composing the layer.
  102415. * @param subMesh the mesh to check for
  102416. * @param useInstances specify wether or not to use instances to render the mesh
  102417. * @param emissiveTexture the associated emissive texture used to generate the glow
  102418. * @return true if ready otherwise, false
  102419. */
  102420. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102421. /**
  102422. * Implementation specific of rendering the generating effect on the main canvas.
  102423. * @param effect The effect used to render through
  102424. */
  102425. protected _internalRender(effect: Effect): void;
  102426. /**
  102427. * Returns true if the layer contains information to display, otherwise false.
  102428. */
  102429. shouldRender(): boolean;
  102430. /**
  102431. * Returns true if the mesh should render, otherwise false.
  102432. * @param mesh The mesh to render
  102433. * @returns true if it should render otherwise false
  102434. */
  102435. protected _shouldRenderMesh(mesh: Mesh): boolean;
  102436. /**
  102437. * Sets the required values for both the emissive texture and and the main color.
  102438. */
  102439. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102440. /**
  102441. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  102442. * @param mesh The mesh to exclude from the highlight layer
  102443. */
  102444. addExcludedMesh(mesh: Mesh): void;
  102445. /**
  102446. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  102447. * @param mesh The mesh to highlight
  102448. */
  102449. removeExcludedMesh(mesh: Mesh): void;
  102450. /**
  102451. * Determine if a given mesh will be highlighted by the current HighlightLayer
  102452. * @param mesh mesh to test
  102453. * @returns true if the mesh will be highlighted by the current HighlightLayer
  102454. */
  102455. hasMesh(mesh: AbstractMesh): boolean;
  102456. /**
  102457. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  102458. * @param mesh The mesh to highlight
  102459. * @param color The color of the highlight
  102460. * @param glowEmissiveOnly Extract the glow from the emissive texture
  102461. */
  102462. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  102463. /**
  102464. * Remove a mesh from the highlight layer in order to make it stop glowing.
  102465. * @param mesh The mesh to highlight
  102466. */
  102467. removeMesh(mesh: Mesh): void;
  102468. /**
  102469. * Force the stencil to the normal expected value for none glowing parts
  102470. */
  102471. private _defaultStencilReference;
  102472. /**
  102473. * Free any resources and references associated to a mesh.
  102474. * Internal use
  102475. * @param mesh The mesh to free.
  102476. * @hidden
  102477. */
  102478. _disposeMesh(mesh: Mesh): void;
  102479. /**
  102480. * Dispose the highlight layer and free resources.
  102481. */
  102482. dispose(): void;
  102483. /**
  102484. * Gets the class name of the effect layer
  102485. * @returns the string with the class name of the effect layer
  102486. */
  102487. getClassName(): string;
  102488. /**
  102489. * Serializes this Highlight layer
  102490. * @returns a serialized Highlight layer object
  102491. */
  102492. serialize(): any;
  102493. /**
  102494. * Creates a Highlight layer from parsed Highlight layer data
  102495. * @param parsedHightlightLayer defines the Highlight layer data
  102496. * @param scene defines the current scene
  102497. * @param rootUrl defines the root URL containing the Highlight layer information
  102498. * @returns a parsed Highlight layer
  102499. */
  102500. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  102501. }
  102502. }
  102503. declare module BABYLON {
  102504. /** @hidden */
  102505. export var lensFlarePixelShader: {
  102506. name: string;
  102507. shader: string;
  102508. };
  102509. }
  102510. declare module BABYLON {
  102511. /** @hidden */
  102512. export var lensFlareVertexShader: {
  102513. name: string;
  102514. shader: string;
  102515. };
  102516. }
  102517. declare module BABYLON {
  102518. /**
  102519. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  102520. * It is usually composed of several `lensFlare`.
  102521. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102522. */
  102523. export class LensFlareSystem {
  102524. /**
  102525. * Define the name of the lens flare system
  102526. */
  102527. name: string;
  102528. /**
  102529. * List of lens flares used in this system.
  102530. */
  102531. lensFlares: LensFlare[];
  102532. /**
  102533. * Define a limit from the border the lens flare can be visible.
  102534. */
  102535. borderLimit: number;
  102536. /**
  102537. * Define a viewport border we do not want to see the lens flare in.
  102538. */
  102539. viewportBorder: number;
  102540. /**
  102541. * Define a predicate which could limit the list of meshes able to occlude the effect.
  102542. */
  102543. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102544. /**
  102545. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  102546. */
  102547. layerMask: number;
  102548. /**
  102549. * Define the id of the lens flare system in the scene.
  102550. * (equal to name by default)
  102551. */
  102552. id: string;
  102553. private _scene;
  102554. private _emitter;
  102555. private _vertexBuffers;
  102556. private _indexBuffer;
  102557. private _effect;
  102558. private _positionX;
  102559. private _positionY;
  102560. private _isEnabled;
  102561. /** @hidden */
  102562. static _SceneComponentInitialization: (scene: Scene) => void;
  102563. /**
  102564. * Instantiates a lens flare system.
  102565. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  102566. * It is usually composed of several `lensFlare`.
  102567. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102568. * @param name Define the name of the lens flare system in the scene
  102569. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  102570. * @param scene Define the scene the lens flare system belongs to
  102571. */
  102572. constructor(
  102573. /**
  102574. * Define the name of the lens flare system
  102575. */
  102576. name: string, emitter: any, scene: Scene);
  102577. /**
  102578. * Define if the lens flare system is enabled.
  102579. */
  102580. isEnabled: boolean;
  102581. /**
  102582. * Get the scene the effects belongs to.
  102583. * @returns the scene holding the lens flare system
  102584. */
  102585. getScene(): Scene;
  102586. /**
  102587. * Get the emitter of the lens flare system.
  102588. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  102589. * @returns the emitter of the lens flare system
  102590. */
  102591. getEmitter(): any;
  102592. /**
  102593. * Set the emitter of the lens flare system.
  102594. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  102595. * @param newEmitter Define the new emitter of the system
  102596. */
  102597. setEmitter(newEmitter: any): void;
  102598. /**
  102599. * Get the lens flare system emitter position.
  102600. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  102601. * @returns the position
  102602. */
  102603. getEmitterPosition(): Vector3;
  102604. /**
  102605. * @hidden
  102606. */
  102607. computeEffectivePosition(globalViewport: Viewport): boolean;
  102608. /** @hidden */
  102609. _isVisible(): boolean;
  102610. /**
  102611. * @hidden
  102612. */
  102613. render(): boolean;
  102614. /**
  102615. * Dispose and release the lens flare with its associated resources.
  102616. */
  102617. dispose(): void;
  102618. /**
  102619. * Parse a lens flare system from a JSON repressentation
  102620. * @param parsedLensFlareSystem Define the JSON to parse
  102621. * @param scene Define the scene the parsed system should be instantiated in
  102622. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  102623. * @returns the parsed system
  102624. */
  102625. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  102626. /**
  102627. * Serialize the current Lens Flare System into a JSON representation.
  102628. * @returns the serialized JSON
  102629. */
  102630. serialize(): any;
  102631. }
  102632. }
  102633. declare module BABYLON {
  102634. /**
  102635. * This represents one of the lens effect in a `lensFlareSystem`.
  102636. * It controls one of the indiviual texture used in the effect.
  102637. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102638. */
  102639. export class LensFlare {
  102640. /**
  102641. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  102642. */
  102643. size: number;
  102644. /**
  102645. * 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.
  102646. */
  102647. position: number;
  102648. /**
  102649. * Define the lens color.
  102650. */
  102651. color: Color3;
  102652. /**
  102653. * Define the lens texture.
  102654. */
  102655. texture: Nullable<Texture>;
  102656. /**
  102657. * Define the alpha mode to render this particular lens.
  102658. */
  102659. alphaMode: number;
  102660. private _system;
  102661. /**
  102662. * Creates a new Lens Flare.
  102663. * This represents one of the lens effect in a `lensFlareSystem`.
  102664. * It controls one of the indiviual texture used in the effect.
  102665. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102666. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  102667. * @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.
  102668. * @param color Define the lens color
  102669. * @param imgUrl Define the lens texture url
  102670. * @param system Define the `lensFlareSystem` this flare is part of
  102671. * @returns The newly created Lens Flare
  102672. */
  102673. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  102674. /**
  102675. * Instantiates a new Lens Flare.
  102676. * This represents one of the lens effect in a `lensFlareSystem`.
  102677. * It controls one of the indiviual texture used in the effect.
  102678. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102679. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  102680. * @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.
  102681. * @param color Define the lens color
  102682. * @param imgUrl Define the lens texture url
  102683. * @param system Define the `lensFlareSystem` this flare is part of
  102684. */
  102685. constructor(
  102686. /**
  102687. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  102688. */
  102689. size: number,
  102690. /**
  102691. * 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.
  102692. */
  102693. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  102694. /**
  102695. * Dispose and release the lens flare with its associated resources.
  102696. */
  102697. dispose(): void;
  102698. }
  102699. }
  102700. declare module BABYLON {
  102701. interface AbstractScene {
  102702. /**
  102703. * The list of lens flare system added to the scene
  102704. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102705. */
  102706. lensFlareSystems: Array<LensFlareSystem>;
  102707. /**
  102708. * Removes the given lens flare system from this scene.
  102709. * @param toRemove The lens flare system to remove
  102710. * @returns The index of the removed lens flare system
  102711. */
  102712. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  102713. /**
  102714. * Adds the given lens flare system to this scene
  102715. * @param newLensFlareSystem The lens flare system to add
  102716. */
  102717. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  102718. /**
  102719. * Gets a lens flare system using its name
  102720. * @param name defines the name to look for
  102721. * @returns the lens flare system or null if not found
  102722. */
  102723. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  102724. /**
  102725. * Gets a lens flare system using its id
  102726. * @param id defines the id to look for
  102727. * @returns the lens flare system or null if not found
  102728. */
  102729. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  102730. }
  102731. /**
  102732. * Defines the lens flare scene component responsible to manage any lens flares
  102733. * in a given scene.
  102734. */
  102735. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  102736. /**
  102737. * The component name helpfull to identify the component in the list of scene components.
  102738. */
  102739. readonly name: string;
  102740. /**
  102741. * The scene the component belongs to.
  102742. */
  102743. scene: Scene;
  102744. /**
  102745. * Creates a new instance of the component for the given scene
  102746. * @param scene Defines the scene to register the component in
  102747. */
  102748. constructor(scene: Scene);
  102749. /**
  102750. * Registers the component in a given scene
  102751. */
  102752. register(): void;
  102753. /**
  102754. * Rebuilds the elements related to this component in case of
  102755. * context lost for instance.
  102756. */
  102757. rebuild(): void;
  102758. /**
  102759. * Adds all the element from the container to the scene
  102760. * @param container the container holding the elements
  102761. */
  102762. addFromContainer(container: AbstractScene): void;
  102763. /**
  102764. * Removes all the elements in the container from the scene
  102765. * @param container contains the elements to remove
  102766. */
  102767. removeFromContainer(container: AbstractScene): void;
  102768. /**
  102769. * Serializes the component data to the specified json object
  102770. * @param serializationObject The object to serialize to
  102771. */
  102772. serialize(serializationObject: any): void;
  102773. /**
  102774. * Disposes the component and the associated ressources.
  102775. */
  102776. dispose(): void;
  102777. private _draw;
  102778. }
  102779. }
  102780. declare module BABYLON {
  102781. /**
  102782. * Defines the shadow generator component responsible to manage any shadow generators
  102783. * in a given scene.
  102784. */
  102785. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  102786. /**
  102787. * The component name helpfull to identify the component in the list of scene components.
  102788. */
  102789. readonly name: string;
  102790. /**
  102791. * The scene the component belongs to.
  102792. */
  102793. scene: Scene;
  102794. /**
  102795. * Creates a new instance of the component for the given scene
  102796. * @param scene Defines the scene to register the component in
  102797. */
  102798. constructor(scene: Scene);
  102799. /**
  102800. * Registers the component in a given scene
  102801. */
  102802. register(): void;
  102803. /**
  102804. * Rebuilds the elements related to this component in case of
  102805. * context lost for instance.
  102806. */
  102807. rebuild(): void;
  102808. /**
  102809. * Serializes the component data to the specified json object
  102810. * @param serializationObject The object to serialize to
  102811. */
  102812. serialize(serializationObject: any): void;
  102813. /**
  102814. * Adds all the element from the container to the scene
  102815. * @param container the container holding the elements
  102816. */
  102817. addFromContainer(container: AbstractScene): void;
  102818. /**
  102819. * Removes all the elements in the container from the scene
  102820. * @param container contains the elements to remove
  102821. */
  102822. removeFromContainer(container: AbstractScene): void;
  102823. /**
  102824. * Rebuilds the elements related to this component in case of
  102825. * context lost for instance.
  102826. */
  102827. dispose(): void;
  102828. private _gatherRenderTargets;
  102829. }
  102830. }
  102831. declare module BABYLON {
  102832. /**
  102833. * A directional light is defined by a direction (what a surprise!).
  102834. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102835. * 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.
  102836. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102837. */
  102838. export class DirectionalLight extends ShadowLight {
  102839. private _shadowFrustumSize;
  102840. /**
  102841. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102842. */
  102843. /**
  102844. * Specifies a fix frustum size for the shadow generation.
  102845. */
  102846. shadowFrustumSize: number;
  102847. private _shadowOrthoScale;
  102848. /**
  102849. * Gets the shadow projection scale against the optimal computed one.
  102850. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102851. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102852. */
  102853. /**
  102854. * Sets the shadow projection scale against the optimal computed one.
  102855. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102856. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102857. */
  102858. shadowOrthoScale: number;
  102859. /**
  102860. * Automatically compute the projection matrix to best fit (including all the casters)
  102861. * on each frame.
  102862. */
  102863. autoUpdateExtends: boolean;
  102864. private _orthoLeft;
  102865. private _orthoRight;
  102866. private _orthoTop;
  102867. private _orthoBottom;
  102868. /**
  102869. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102870. * The directional light is emitted from everywhere in the given direction.
  102871. * It can cast shadows.
  102872. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102873. * @param name The friendly name of the light
  102874. * @param direction The direction of the light
  102875. * @param scene The scene the light belongs to
  102876. */
  102877. constructor(name: string, direction: Vector3, scene: Scene);
  102878. /**
  102879. * Returns the string "DirectionalLight".
  102880. * @return The class name
  102881. */
  102882. getClassName(): string;
  102883. /**
  102884. * Returns the integer 1.
  102885. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102886. */
  102887. getTypeID(): number;
  102888. /**
  102889. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102890. * Returns the DirectionalLight Shadow projection matrix.
  102891. */
  102892. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102893. /**
  102894. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102895. * Returns the DirectionalLight Shadow projection matrix.
  102896. */
  102897. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102898. /**
  102899. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102900. * Returns the DirectionalLight Shadow projection matrix.
  102901. */
  102902. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102903. protected _buildUniformLayout(): void;
  102904. /**
  102905. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102906. * @param effect The effect to update
  102907. * @param lightIndex The index of the light in the effect to update
  102908. * @returns The directional light
  102909. */
  102910. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102911. /**
  102912. * Gets the minZ used for shadow according to both the scene and the light.
  102913. *
  102914. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102915. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102916. * @param activeCamera The camera we are returning the min for
  102917. * @returns the depth min z
  102918. */
  102919. getDepthMinZ(activeCamera: Camera): number;
  102920. /**
  102921. * Gets the maxZ used for shadow according to both the scene and the light.
  102922. *
  102923. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102924. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102925. * @param activeCamera The camera we are returning the max for
  102926. * @returns the depth max z
  102927. */
  102928. getDepthMaxZ(activeCamera: Camera): number;
  102929. /**
  102930. * Prepares the list of defines specific to the light type.
  102931. * @param defines the list of defines
  102932. * @param lightIndex defines the index of the light for the effect
  102933. */
  102934. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102935. }
  102936. }
  102937. declare module BABYLON {
  102938. /**
  102939. * A point light is a light defined by an unique point in world space.
  102940. * The light is emitted in every direction from this point.
  102941. * A good example of a point light is a standard light bulb.
  102942. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102943. */
  102944. export class PointLight extends ShadowLight {
  102945. private _shadowAngle;
  102946. /**
  102947. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102948. * This specifies what angle the shadow will use to be created.
  102949. *
  102950. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  102951. */
  102952. /**
  102953. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102954. * This specifies what angle the shadow will use to be created.
  102955. *
  102956. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  102957. */
  102958. shadowAngle: number;
  102959. /**
  102960. * Gets the direction if it has been set.
  102961. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102962. */
  102963. /**
  102964. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102965. */
  102966. direction: Vector3;
  102967. /**
  102968. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  102969. * A PointLight emits the light in every direction.
  102970. * It can cast shadows.
  102971. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  102972. * ```javascript
  102973. * var pointLight = new PointLight("pl", camera.position, scene);
  102974. * ```
  102975. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102976. * @param name The light friendly name
  102977. * @param position The position of the point light in the scene
  102978. * @param scene The scene the lights belongs to
  102979. */
  102980. constructor(name: string, position: Vector3, scene: Scene);
  102981. /**
  102982. * Returns the string "PointLight"
  102983. * @returns the class name
  102984. */
  102985. getClassName(): string;
  102986. /**
  102987. * Returns the integer 0.
  102988. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102989. */
  102990. getTypeID(): number;
  102991. /**
  102992. * Specifies wether or not the shadowmap should be a cube texture.
  102993. * @returns true if the shadowmap needs to be a cube texture.
  102994. */
  102995. needCube(): boolean;
  102996. /**
  102997. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  102998. * @param faceIndex The index of the face we are computed the direction to generate shadow
  102999. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  103000. */
  103001. getShadowDirection(faceIndex?: number): Vector3;
  103002. /**
  103003. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  103004. * - fov = PI / 2
  103005. * - aspect ratio : 1.0
  103006. * - z-near and far equal to the active camera minZ and maxZ.
  103007. * Returns the PointLight.
  103008. */
  103009. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103010. protected _buildUniformLayout(): void;
  103011. /**
  103012. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  103013. * @param effect The effect to update
  103014. * @param lightIndex The index of the light in the effect to update
  103015. * @returns The point light
  103016. */
  103017. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  103018. /**
  103019. * Prepares the list of defines specific to the light type.
  103020. * @param defines the list of defines
  103021. * @param lightIndex defines the index of the light for the effect
  103022. */
  103023. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103024. }
  103025. }
  103026. declare module BABYLON {
  103027. /**
  103028. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103029. * These values define a cone of light starting from the position, emitting toward the direction.
  103030. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103031. * and the exponent defines the speed of the decay of the light with distance (reach).
  103032. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103033. */
  103034. export class SpotLight extends ShadowLight {
  103035. private _angle;
  103036. private _innerAngle;
  103037. private _cosHalfAngle;
  103038. private _lightAngleScale;
  103039. private _lightAngleOffset;
  103040. /**
  103041. * Gets the cone angle of the spot light in Radians.
  103042. */
  103043. /**
  103044. * Sets the cone angle of the spot light in Radians.
  103045. */
  103046. angle: number;
  103047. /**
  103048. * Only used in gltf falloff mode, this defines the angle where
  103049. * the directional falloff will start before cutting at angle which could be seen
  103050. * as outer angle.
  103051. */
  103052. /**
  103053. * Only used in gltf falloff mode, this defines the angle where
  103054. * the directional falloff will start before cutting at angle which could be seen
  103055. * as outer angle.
  103056. */
  103057. innerAngle: number;
  103058. private _shadowAngleScale;
  103059. /**
  103060. * Allows scaling the angle of the light for shadow generation only.
  103061. */
  103062. /**
  103063. * Allows scaling the angle of the light for shadow generation only.
  103064. */
  103065. shadowAngleScale: number;
  103066. /**
  103067. * The light decay speed with the distance from the emission spot.
  103068. */
  103069. exponent: number;
  103070. private _projectionTextureMatrix;
  103071. /**
  103072. * Allows reading the projecton texture
  103073. */
  103074. readonly projectionTextureMatrix: Matrix;
  103075. protected _projectionTextureLightNear: number;
  103076. /**
  103077. * Gets the near clip of the Spotlight for texture projection.
  103078. */
  103079. /**
  103080. * Sets the near clip of the Spotlight for texture projection.
  103081. */
  103082. projectionTextureLightNear: number;
  103083. protected _projectionTextureLightFar: number;
  103084. /**
  103085. * Gets the far clip of the Spotlight for texture projection.
  103086. */
  103087. /**
  103088. * Sets the far clip of the Spotlight for texture projection.
  103089. */
  103090. projectionTextureLightFar: number;
  103091. protected _projectionTextureUpDirection: Vector3;
  103092. /**
  103093. * Gets the Up vector of the Spotlight for texture projection.
  103094. */
  103095. /**
  103096. * Sets the Up vector of the Spotlight for texture projection.
  103097. */
  103098. projectionTextureUpDirection: Vector3;
  103099. private _projectionTexture;
  103100. /**
  103101. * Gets the projection texture of the light.
  103102. */
  103103. /**
  103104. * Sets the projection texture of the light.
  103105. */
  103106. projectionTexture: Nullable<BaseTexture>;
  103107. private _projectionTextureViewLightDirty;
  103108. private _projectionTextureProjectionLightDirty;
  103109. private _projectionTextureDirty;
  103110. private _projectionTextureViewTargetVector;
  103111. private _projectionTextureViewLightMatrix;
  103112. private _projectionTextureProjectionLightMatrix;
  103113. private _projectionTextureScalingMatrix;
  103114. /**
  103115. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103116. * It can cast shadows.
  103117. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103118. * @param name The light friendly name
  103119. * @param position The position of the spot light in the scene
  103120. * @param direction The direction of the light in the scene
  103121. * @param angle The cone angle of the light in Radians
  103122. * @param exponent The light decay speed with the distance from the emission spot
  103123. * @param scene The scene the lights belongs to
  103124. */
  103125. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103126. /**
  103127. * Returns the string "SpotLight".
  103128. * @returns the class name
  103129. */
  103130. getClassName(): string;
  103131. /**
  103132. * Returns the integer 2.
  103133. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103134. */
  103135. getTypeID(): number;
  103136. /**
  103137. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103138. */
  103139. protected _setDirection(value: Vector3): void;
  103140. /**
  103141. * Overrides the position setter to recompute the projection texture view light Matrix.
  103142. */
  103143. protected _setPosition(value: Vector3): void;
  103144. /**
  103145. * 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.
  103146. * Returns the SpotLight.
  103147. */
  103148. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103149. protected _computeProjectionTextureViewLightMatrix(): void;
  103150. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103151. /**
  103152. * Main function for light texture projection matrix computing.
  103153. */
  103154. protected _computeProjectionTextureMatrix(): void;
  103155. protected _buildUniformLayout(): void;
  103156. private _computeAngleValues;
  103157. /**
  103158. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103159. * @param effect The effect to update
  103160. * @param lightIndex The index of the light in the effect to update
  103161. * @returns The spot light
  103162. */
  103163. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103164. /**
  103165. * Disposes the light and the associated resources.
  103166. */
  103167. dispose(): void;
  103168. /**
  103169. * Prepares the list of defines specific to the light type.
  103170. * @param defines the list of defines
  103171. * @param lightIndex defines the index of the light for the effect
  103172. */
  103173. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103174. }
  103175. }
  103176. declare module BABYLON {
  103177. /**
  103178. * Header information of HDR texture files.
  103179. */
  103180. export interface HDRInfo {
  103181. /**
  103182. * The height of the texture in pixels.
  103183. */
  103184. height: number;
  103185. /**
  103186. * The width of the texture in pixels.
  103187. */
  103188. width: number;
  103189. /**
  103190. * The index of the beginning of the data in the binary file.
  103191. */
  103192. dataPosition: number;
  103193. }
  103194. /**
  103195. * This groups tools to convert HDR texture to native colors array.
  103196. */
  103197. export class HDRTools {
  103198. private static Ldexp;
  103199. private static Rgbe2float;
  103200. private static readStringLine;
  103201. /**
  103202. * Reads header information from an RGBE texture stored in a native array.
  103203. * More information on this format are available here:
  103204. * https://en.wikipedia.org/wiki/RGBE_image_format
  103205. *
  103206. * @param uint8array The binary file stored in native array.
  103207. * @return The header information.
  103208. */
  103209. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  103210. /**
  103211. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  103212. * This RGBE texture needs to store the information as a panorama.
  103213. *
  103214. * More information on this format are available here:
  103215. * https://en.wikipedia.org/wiki/RGBE_image_format
  103216. *
  103217. * @param buffer The binary file stored in an array buffer.
  103218. * @param size The expected size of the extracted cubemap.
  103219. * @return The Cube Map information.
  103220. */
  103221. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  103222. /**
  103223. * Returns the pixels data extracted from an RGBE texture.
  103224. * This pixels will be stored left to right up to down in the R G B order in one array.
  103225. *
  103226. * More information on this format are available here:
  103227. * https://en.wikipedia.org/wiki/RGBE_image_format
  103228. *
  103229. * @param uint8array The binary file stored in an array buffer.
  103230. * @param hdrInfo The header information of the file.
  103231. * @return The pixels data in RGB right to left up to down order.
  103232. */
  103233. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  103234. private static RGBE_ReadPixels_RLE;
  103235. }
  103236. }
  103237. declare module BABYLON {
  103238. /**
  103239. * This represents a texture coming from an HDR input.
  103240. *
  103241. * The only supported format is currently panorama picture stored in RGBE format.
  103242. * Example of such files can be found on HDRLib: http://hdrlib.com/
  103243. */
  103244. export class HDRCubeTexture extends BaseTexture {
  103245. private static _facesMapping;
  103246. private _generateHarmonics;
  103247. private _noMipmap;
  103248. private _textureMatrix;
  103249. private _size;
  103250. private _onLoad;
  103251. private _onError;
  103252. /**
  103253. * The texture URL.
  103254. */
  103255. url: string;
  103256. /**
  103257. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  103258. */
  103259. coordinatesMode: number;
  103260. protected _isBlocking: boolean;
  103261. /**
  103262. * Sets wether or not the texture is blocking during loading.
  103263. */
  103264. /**
  103265. * Gets wether or not the texture is blocking during loading.
  103266. */
  103267. isBlocking: boolean;
  103268. protected _rotationY: number;
  103269. /**
  103270. * Sets texture matrix rotation angle around Y axis in radians.
  103271. */
  103272. /**
  103273. * Gets texture matrix rotation angle around Y axis radians.
  103274. */
  103275. rotationY: number;
  103276. /**
  103277. * Gets or sets the center of the bounding box associated with the cube texture
  103278. * It must define where the camera used to render the texture was set
  103279. */
  103280. boundingBoxPosition: Vector3;
  103281. private _boundingBoxSize;
  103282. /**
  103283. * Gets or sets the size of the bounding box associated with the cube texture
  103284. * When defined, the cubemap will switch to local mode
  103285. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  103286. * @example https://www.babylonjs-playground.com/#RNASML
  103287. */
  103288. boundingBoxSize: Vector3;
  103289. /**
  103290. * Instantiates an HDRTexture from the following parameters.
  103291. *
  103292. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  103293. * @param scene The scene the texture will be used in
  103294. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  103295. * @param noMipmap Forces to not generate the mipmap if true
  103296. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  103297. * @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)
  103298. * @param reserved Reserved flag for internal use.
  103299. */
  103300. 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>);
  103301. /**
  103302. * Get the current class name of the texture useful for serialization or dynamic coding.
  103303. * @returns "HDRCubeTexture"
  103304. */
  103305. getClassName(): string;
  103306. /**
  103307. * Occurs when the file is raw .hdr file.
  103308. */
  103309. private loadTexture;
  103310. clone(): HDRCubeTexture;
  103311. delayLoad(): void;
  103312. /**
  103313. * Get the texture reflection matrix used to rotate/transform the reflection.
  103314. * @returns the reflection matrix
  103315. */
  103316. getReflectionTextureMatrix(): Matrix;
  103317. /**
  103318. * Set the texture reflection matrix used to rotate/transform the reflection.
  103319. * @param value Define the reflection matrix to set
  103320. */
  103321. setReflectionTextureMatrix(value: Matrix): void;
  103322. /**
  103323. * Parses a JSON representation of an HDR Texture in order to create the texture
  103324. * @param parsedTexture Define the JSON representation
  103325. * @param scene Define the scene the texture should be created in
  103326. * @param rootUrl Define the root url in case we need to load relative dependencies
  103327. * @returns the newly created texture after parsing
  103328. */
  103329. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  103330. serialize(): any;
  103331. }
  103332. }
  103333. declare module BABYLON {
  103334. /**
  103335. * Class used to control physics engine
  103336. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  103337. */
  103338. export class PhysicsEngine implements IPhysicsEngine {
  103339. private _physicsPlugin;
  103340. /**
  103341. * Global value used to control the smallest number supported by the simulation
  103342. */
  103343. static Epsilon: number;
  103344. private _impostors;
  103345. private _joints;
  103346. /**
  103347. * Gets the gravity vector used by the simulation
  103348. */
  103349. gravity: Vector3;
  103350. /**
  103351. * Factory used to create the default physics plugin.
  103352. * @returns The default physics plugin
  103353. */
  103354. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  103355. /**
  103356. * Creates a new Physics Engine
  103357. * @param gravity defines the gravity vector used by the simulation
  103358. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  103359. */
  103360. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  103361. /**
  103362. * Sets the gravity vector used by the simulation
  103363. * @param gravity defines the gravity vector to use
  103364. */
  103365. setGravity(gravity: Vector3): void;
  103366. /**
  103367. * Set the time step of the physics engine.
  103368. * Default is 1/60.
  103369. * To slow it down, enter 1/600 for example.
  103370. * To speed it up, 1/30
  103371. * @param newTimeStep defines the new timestep to apply to this world.
  103372. */
  103373. setTimeStep(newTimeStep?: number): void;
  103374. /**
  103375. * Get the time step of the physics engine.
  103376. * @returns the current time step
  103377. */
  103378. getTimeStep(): number;
  103379. /**
  103380. * Release all resources
  103381. */
  103382. dispose(): void;
  103383. /**
  103384. * Gets the name of the current physics plugin
  103385. * @returns the name of the plugin
  103386. */
  103387. getPhysicsPluginName(): string;
  103388. /**
  103389. * Adding a new impostor for the impostor tracking.
  103390. * This will be done by the impostor itself.
  103391. * @param impostor the impostor to add
  103392. */
  103393. addImpostor(impostor: PhysicsImpostor): void;
  103394. /**
  103395. * Remove an impostor from the engine.
  103396. * This impostor and its mesh will not longer be updated by the physics engine.
  103397. * @param impostor the impostor to remove
  103398. */
  103399. removeImpostor(impostor: PhysicsImpostor): void;
  103400. /**
  103401. * Add a joint to the physics engine
  103402. * @param mainImpostor defines the main impostor to which the joint is added.
  103403. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  103404. * @param joint defines the joint that will connect both impostors.
  103405. */
  103406. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103407. /**
  103408. * Removes a joint from the simulation
  103409. * @param mainImpostor defines the impostor used with the joint
  103410. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  103411. * @param joint defines the joint to remove
  103412. */
  103413. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103414. /**
  103415. * Called by the scene. No need to call it.
  103416. * @param delta defines the timespam between frames
  103417. */
  103418. _step(delta: number): void;
  103419. /**
  103420. * Gets the current plugin used to run the simulation
  103421. * @returns current plugin
  103422. */
  103423. getPhysicsPlugin(): IPhysicsEnginePlugin;
  103424. /**
  103425. * Gets the list of physic impostors
  103426. * @returns an array of PhysicsImpostor
  103427. */
  103428. getImpostors(): Array<PhysicsImpostor>;
  103429. /**
  103430. * Gets the impostor for a physics enabled object
  103431. * @param object defines the object impersonated by the impostor
  103432. * @returns the PhysicsImpostor or null if not found
  103433. */
  103434. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  103435. /**
  103436. * Gets the impostor for a physics body object
  103437. * @param body defines physics body used by the impostor
  103438. * @returns the PhysicsImpostor or null if not found
  103439. */
  103440. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  103441. }
  103442. }
  103443. declare module BABYLON {
  103444. /** @hidden */
  103445. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  103446. private _useDeltaForWorldStep;
  103447. world: any;
  103448. name: string;
  103449. private _physicsMaterials;
  103450. private _fixedTimeStep;
  103451. BJSCANNON: any;
  103452. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  103453. setGravity(gravity: Vector3): void;
  103454. setTimeStep(timeStep: number): void;
  103455. getTimeStep(): number;
  103456. executeStep(delta: number): void;
  103457. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103458. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103459. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103460. private _processChildMeshes;
  103461. removePhysicsBody(impostor: PhysicsImpostor): void;
  103462. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  103463. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  103464. private _addMaterial;
  103465. private _checkWithEpsilon;
  103466. private _createShape;
  103467. private _createHeightmap;
  103468. private _minus90X;
  103469. private _plus90X;
  103470. private _tmpPosition;
  103471. private _tmpDeltaPosition;
  103472. private _tmpUnityRotation;
  103473. private _updatePhysicsBodyTransformation;
  103474. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103475. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103476. isSupported(): boolean;
  103477. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103478. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103479. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103480. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103481. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103482. getBodyMass(impostor: PhysicsImpostor): number;
  103483. getBodyFriction(impostor: PhysicsImpostor): number;
  103484. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103485. getBodyRestitution(impostor: PhysicsImpostor): number;
  103486. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103487. sleepBody(impostor: PhysicsImpostor): void;
  103488. wakeUpBody(impostor: PhysicsImpostor): void;
  103489. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  103490. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  103491. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  103492. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103493. getRadius(impostor: PhysicsImpostor): number;
  103494. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103495. dispose(): void;
  103496. private _extendNamespace;
  103497. }
  103498. }
  103499. declare module BABYLON {
  103500. /** @hidden */
  103501. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  103502. world: any;
  103503. name: string;
  103504. BJSOIMO: any;
  103505. constructor(iterations?: number, oimoInjection?: any);
  103506. setGravity(gravity: Vector3): void;
  103507. setTimeStep(timeStep: number): void;
  103508. getTimeStep(): number;
  103509. private _tmpImpostorsArray;
  103510. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  103511. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103512. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103513. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103514. private _tmpPositionVector;
  103515. removePhysicsBody(impostor: PhysicsImpostor): void;
  103516. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  103517. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  103518. isSupported(): boolean;
  103519. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103520. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103521. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103522. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103523. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103524. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103525. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103526. getBodyMass(impostor: PhysicsImpostor): number;
  103527. getBodyFriction(impostor: PhysicsImpostor): number;
  103528. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103529. getBodyRestitution(impostor: PhysicsImpostor): number;
  103530. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103531. sleepBody(impostor: PhysicsImpostor): void;
  103532. wakeUpBody(impostor: PhysicsImpostor): void;
  103533. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  103534. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  103535. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103536. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103537. getRadius(impostor: PhysicsImpostor): number;
  103538. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103539. dispose(): void;
  103540. }
  103541. }
  103542. declare module BABYLON {
  103543. interface AbstractScene {
  103544. /**
  103545. * The list of reflection probes added to the scene
  103546. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  103547. */
  103548. reflectionProbes: Array<ReflectionProbe>;
  103549. /**
  103550. * Removes the given reflection probe from this scene.
  103551. * @param toRemove The reflection probe to remove
  103552. * @returns The index of the removed reflection probe
  103553. */
  103554. removeReflectionProbe(toRemove: ReflectionProbe): number;
  103555. /**
  103556. * Adds the given reflection probe to this scene.
  103557. * @param newReflectionProbe The reflection probe to add
  103558. */
  103559. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  103560. }
  103561. /**
  103562. * Class used to generate realtime reflection / refraction cube textures
  103563. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  103564. */
  103565. export class ReflectionProbe {
  103566. /** defines the name of the probe */
  103567. name: string;
  103568. private _scene;
  103569. private _renderTargetTexture;
  103570. private _projectionMatrix;
  103571. private _viewMatrix;
  103572. private _target;
  103573. private _add;
  103574. private _attachedMesh;
  103575. private _invertYAxis;
  103576. /** Gets or sets probe position (center of the cube map) */
  103577. position: Vector3;
  103578. /**
  103579. * Creates a new reflection probe
  103580. * @param name defines the name of the probe
  103581. * @param size defines the texture resolution (for each face)
  103582. * @param scene defines the hosting scene
  103583. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  103584. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  103585. */
  103586. constructor(
  103587. /** defines the name of the probe */
  103588. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  103589. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  103590. samples: number;
  103591. /** Gets or sets the refresh rate to use (on every frame by default) */
  103592. refreshRate: number;
  103593. /**
  103594. * Gets the hosting scene
  103595. * @returns a Scene
  103596. */
  103597. getScene(): Scene;
  103598. /** Gets the internal CubeTexture used to render to */
  103599. readonly cubeTexture: RenderTargetTexture;
  103600. /** Gets the list of meshes to render */
  103601. readonly renderList: Nullable<AbstractMesh[]>;
  103602. /**
  103603. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  103604. * @param mesh defines the mesh to attach to
  103605. */
  103606. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  103607. /**
  103608. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  103609. * @param renderingGroupId The rendering group id corresponding to its index
  103610. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103611. */
  103612. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  103613. /**
  103614. * Clean all associated resources
  103615. */
  103616. dispose(): void;
  103617. /**
  103618. * Converts the reflection probe information to a readable string for debug purpose.
  103619. * @param fullDetails Supports for multiple levels of logging within scene loading
  103620. * @returns the human readable reflection probe info
  103621. */
  103622. toString(fullDetails?: boolean): string;
  103623. /**
  103624. * Get the class name of the relfection probe.
  103625. * @returns "ReflectionProbe"
  103626. */
  103627. getClassName(): string;
  103628. /**
  103629. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  103630. * @returns The JSON representation of the texture
  103631. */
  103632. serialize(): any;
  103633. /**
  103634. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  103635. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  103636. * @param scene Define the scene the parsed reflection probe should be instantiated in
  103637. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103638. * @returns The parsed reflection probe if successful
  103639. */
  103640. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  103641. }
  103642. }
  103643. declare module BABYLON {
  103644. /** @hidden */
  103645. export var _BabylonLoaderRegistered: boolean;
  103646. }
  103647. declare module BABYLON {
  103648. /**
  103649. * The Physically based simple base material of BJS.
  103650. *
  103651. * This enables better naming and convention enforcements on top of the pbrMaterial.
  103652. * It is used as the base class for both the specGloss and metalRough conventions.
  103653. */
  103654. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  103655. /**
  103656. * Number of Simultaneous lights allowed on the material.
  103657. */
  103658. maxSimultaneousLights: number;
  103659. /**
  103660. * If sets to true, disables all the lights affecting the material.
  103661. */
  103662. disableLighting: boolean;
  103663. /**
  103664. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  103665. */
  103666. environmentTexture: BaseTexture;
  103667. /**
  103668. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103669. */
  103670. invertNormalMapX: boolean;
  103671. /**
  103672. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103673. */
  103674. invertNormalMapY: boolean;
  103675. /**
  103676. * Normal map used in the model.
  103677. */
  103678. normalTexture: BaseTexture;
  103679. /**
  103680. * Emissivie color used to self-illuminate the model.
  103681. */
  103682. emissiveColor: Color3;
  103683. /**
  103684. * Emissivie texture used to self-illuminate the model.
  103685. */
  103686. emissiveTexture: BaseTexture;
  103687. /**
  103688. * Occlusion Channel Strenght.
  103689. */
  103690. occlusionStrength: number;
  103691. /**
  103692. * Occlusion Texture of the material (adding extra occlusion effects).
  103693. */
  103694. occlusionTexture: BaseTexture;
  103695. /**
  103696. * Defines the alpha limits in alpha test mode.
  103697. */
  103698. alphaCutOff: number;
  103699. /**
  103700. * Gets the current double sided mode.
  103701. */
  103702. /**
  103703. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103704. */
  103705. doubleSided: boolean;
  103706. /**
  103707. * Stores the pre-calculated light information of a mesh in a texture.
  103708. */
  103709. lightmapTexture: BaseTexture;
  103710. /**
  103711. * If true, the light map contains occlusion information instead of lighting info.
  103712. */
  103713. useLightmapAsShadowmap: boolean;
  103714. /**
  103715. * Instantiates a new PBRMaterial instance.
  103716. *
  103717. * @param name The material name
  103718. * @param scene The scene the material will be use in.
  103719. */
  103720. constructor(name: string, scene: Scene);
  103721. getClassName(): string;
  103722. }
  103723. }
  103724. declare module BABYLON {
  103725. /**
  103726. * The PBR material of BJS following the metal roughness convention.
  103727. *
  103728. * This fits to the PBR convention in the GLTF definition:
  103729. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  103730. */
  103731. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  103732. /**
  103733. * The base color has two different interpretations depending on the value of metalness.
  103734. * When the material is a metal, the base color is the specific measured reflectance value
  103735. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  103736. * of the material.
  103737. */
  103738. baseColor: Color3;
  103739. /**
  103740. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  103741. * well as opacity information in the alpha channel.
  103742. */
  103743. baseTexture: BaseTexture;
  103744. /**
  103745. * Specifies the metallic scalar value of the material.
  103746. * Can also be used to scale the metalness values of the metallic texture.
  103747. */
  103748. metallic: number;
  103749. /**
  103750. * Specifies the roughness scalar value of the material.
  103751. * Can also be used to scale the roughness values of the metallic texture.
  103752. */
  103753. roughness: number;
  103754. /**
  103755. * Texture containing both the metallic value in the B channel and the
  103756. * roughness value in the G channel to keep better precision.
  103757. */
  103758. metallicRoughnessTexture: BaseTexture;
  103759. /**
  103760. * Instantiates a new PBRMetalRoughnessMaterial instance.
  103761. *
  103762. * @param name The material name
  103763. * @param scene The scene the material will be use in.
  103764. */
  103765. constructor(name: string, scene: Scene);
  103766. /**
  103767. * Return the currrent class name of the material.
  103768. */
  103769. getClassName(): string;
  103770. /**
  103771. * Makes a duplicate of the current material.
  103772. * @param name - name to use for the new material.
  103773. */
  103774. clone(name: string): PBRMetallicRoughnessMaterial;
  103775. /**
  103776. * Serialize the material to a parsable JSON object.
  103777. */
  103778. serialize(): any;
  103779. /**
  103780. * Parses a JSON object correponding to the serialize function.
  103781. */
  103782. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  103783. }
  103784. }
  103785. declare module BABYLON {
  103786. /**
  103787. * The PBR material of BJS following the specular glossiness convention.
  103788. *
  103789. * This fits to the PBR convention in the GLTF definition:
  103790. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  103791. */
  103792. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  103793. /**
  103794. * Specifies the diffuse color of the material.
  103795. */
  103796. diffuseColor: Color3;
  103797. /**
  103798. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  103799. * channel.
  103800. */
  103801. diffuseTexture: BaseTexture;
  103802. /**
  103803. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  103804. */
  103805. specularColor: Color3;
  103806. /**
  103807. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  103808. */
  103809. glossiness: number;
  103810. /**
  103811. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  103812. */
  103813. specularGlossinessTexture: BaseTexture;
  103814. /**
  103815. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  103816. *
  103817. * @param name The material name
  103818. * @param scene The scene the material will be use in.
  103819. */
  103820. constructor(name: string, scene: Scene);
  103821. /**
  103822. * Return the currrent class name of the material.
  103823. */
  103824. getClassName(): string;
  103825. /**
  103826. * Makes a duplicate of the current material.
  103827. * @param name - name to use for the new material.
  103828. */
  103829. clone(name: string): PBRSpecularGlossinessMaterial;
  103830. /**
  103831. * Serialize the material to a parsable JSON object.
  103832. */
  103833. serialize(): any;
  103834. /**
  103835. * Parses a JSON object correponding to the serialize function.
  103836. */
  103837. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  103838. }
  103839. }
  103840. declare module BABYLON {
  103841. /**
  103842. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  103843. * It can help converting any input color in a desired output one. This can then be used to create effects
  103844. * from sepia, black and white to sixties or futuristic rendering...
  103845. *
  103846. * The only supported format is currently 3dl.
  103847. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  103848. */
  103849. export class ColorGradingTexture extends BaseTexture {
  103850. /**
  103851. * The current texture matrix. (will always be identity in color grading texture)
  103852. */
  103853. private _textureMatrix;
  103854. /**
  103855. * The texture URL.
  103856. */
  103857. url: string;
  103858. /**
  103859. * Empty line regex stored for GC.
  103860. */
  103861. private static _noneEmptyLineRegex;
  103862. private _engine;
  103863. /**
  103864. * Instantiates a ColorGradingTexture from the following parameters.
  103865. *
  103866. * @param url The location of the color gradind data (currently only supporting 3dl)
  103867. * @param scene The scene the texture will be used in
  103868. */
  103869. constructor(url: string, scene: Scene);
  103870. /**
  103871. * Returns the texture matrix used in most of the material.
  103872. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  103873. */
  103874. getTextureMatrix(): Matrix;
  103875. /**
  103876. * Occurs when the file being loaded is a .3dl LUT file.
  103877. */
  103878. private load3dlTexture;
  103879. /**
  103880. * Starts the loading process of the texture.
  103881. */
  103882. private loadTexture;
  103883. /**
  103884. * Clones the color gradind texture.
  103885. */
  103886. clone(): ColorGradingTexture;
  103887. /**
  103888. * Called during delayed load for textures.
  103889. */
  103890. delayLoad(): void;
  103891. /**
  103892. * Parses a color grading texture serialized by Babylon.
  103893. * @param parsedTexture The texture information being parsedTexture
  103894. * @param scene The scene to load the texture in
  103895. * @param rootUrl The root url of the data assets to load
  103896. * @return A color gradind texture
  103897. */
  103898. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  103899. /**
  103900. * Serializes the LUT texture to json format.
  103901. */
  103902. serialize(): any;
  103903. }
  103904. }
  103905. declare module BABYLON {
  103906. /**
  103907. * Direct draw surface info
  103908. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  103909. */
  103910. export interface DDSInfo {
  103911. /**
  103912. * Width of the texture
  103913. */
  103914. width: number;
  103915. /**
  103916. * Width of the texture
  103917. */
  103918. height: number;
  103919. /**
  103920. * Number of Mipmaps for the texture
  103921. * @see https://en.wikipedia.org/wiki/Mipmap
  103922. */
  103923. mipmapCount: number;
  103924. /**
  103925. * If the textures format is a known fourCC format
  103926. * @see https://www.fourcc.org/
  103927. */
  103928. isFourCC: boolean;
  103929. /**
  103930. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  103931. */
  103932. isRGB: boolean;
  103933. /**
  103934. * If the texture is a lumincance format
  103935. */
  103936. isLuminance: boolean;
  103937. /**
  103938. * If this is a cube texture
  103939. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  103940. */
  103941. isCube: boolean;
  103942. /**
  103943. * If the texture is a compressed format eg. FOURCC_DXT1
  103944. */
  103945. isCompressed: boolean;
  103946. /**
  103947. * The dxgiFormat of the texture
  103948. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  103949. */
  103950. dxgiFormat: number;
  103951. /**
  103952. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  103953. */
  103954. textureType: number;
  103955. /**
  103956. * Sphericle polynomial created for the dds texture
  103957. */
  103958. sphericalPolynomial?: SphericalPolynomial;
  103959. }
  103960. /**
  103961. * Class used to provide DDS decompression tools
  103962. */
  103963. export class DDSTools {
  103964. /**
  103965. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  103966. */
  103967. static StoreLODInAlphaChannel: boolean;
  103968. /**
  103969. * Gets DDS information from an array buffer
  103970. * @param arrayBuffer defines the array buffer to read data from
  103971. * @returns the DDS information
  103972. */
  103973. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  103974. private static _FloatView;
  103975. private static _Int32View;
  103976. private static _ToHalfFloat;
  103977. private static _FromHalfFloat;
  103978. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  103979. private static _GetHalfFloatRGBAArrayBuffer;
  103980. private static _GetFloatRGBAArrayBuffer;
  103981. private static _GetFloatAsUIntRGBAArrayBuffer;
  103982. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  103983. private static _GetRGBAArrayBuffer;
  103984. private static _ExtractLongWordOrder;
  103985. private static _GetRGBArrayBuffer;
  103986. private static _GetLuminanceArrayBuffer;
  103987. /**
  103988. * Uploads DDS Levels to a Babylon Texture
  103989. * @hidden
  103990. */
  103991. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  103992. }
  103993. interface Engine {
  103994. /**
  103995. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  103996. * @param rootUrl defines the url where the file to load is located
  103997. * @param scene defines the current scene
  103998. * @param lodScale defines scale to apply to the mip map selection
  103999. * @param lodOffset defines offset to apply to the mip map selection
  104000. * @param onLoad defines an optional callback raised when the texture is loaded
  104001. * @param onError defines an optional callback raised if there is an issue to load the texture
  104002. * @param format defines the format of the data
  104003. * @param forcedExtension defines the extension to use to pick the right loader
  104004. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  104005. * @returns the cube texture as an InternalTexture
  104006. */
  104007. 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;
  104008. }
  104009. }
  104010. declare module BABYLON {
  104011. /**
  104012. * Implementation of the DDS Texture Loader.
  104013. * @hidden
  104014. */
  104015. export class _DDSTextureLoader implements IInternalTextureLoader {
  104016. /**
  104017. * Defines wether the loader supports cascade loading the different faces.
  104018. */
  104019. readonly supportCascades: boolean;
  104020. /**
  104021. * This returns if the loader support the current file information.
  104022. * @param extension defines the file extension of the file being loaded
  104023. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104024. * @param fallback defines the fallback internal texture if any
  104025. * @param isBase64 defines whether the texture is encoded as a base64
  104026. * @param isBuffer defines whether the texture data are stored as a buffer
  104027. * @returns true if the loader can load the specified file
  104028. */
  104029. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104030. /**
  104031. * Transform the url before loading if required.
  104032. * @param rootUrl the url of the texture
  104033. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104034. * @returns the transformed texture
  104035. */
  104036. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104037. /**
  104038. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104039. * @param rootUrl the url of the texture
  104040. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104041. * @returns the fallback texture
  104042. */
  104043. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104044. /**
  104045. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104046. * @param data contains the texture data
  104047. * @param texture defines the BabylonJS internal texture
  104048. * @param createPolynomials will be true if polynomials have been requested
  104049. * @param onLoad defines the callback to trigger once the texture is ready
  104050. * @param onError defines the callback to trigger in case of error
  104051. */
  104052. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104053. /**
  104054. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104055. * @param data contains the texture data
  104056. * @param texture defines the BabylonJS internal texture
  104057. * @param callback defines the method to call once ready to upload
  104058. */
  104059. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104060. }
  104061. }
  104062. declare module BABYLON {
  104063. /** @hidden */
  104064. export var rgbdEncodePixelShader: {
  104065. name: string;
  104066. shader: string;
  104067. };
  104068. }
  104069. declare module BABYLON {
  104070. /** @hidden */
  104071. export var rgbdDecodePixelShader: {
  104072. name: string;
  104073. shader: string;
  104074. };
  104075. }
  104076. declare module BABYLON {
  104077. /**
  104078. * Raw texture data and descriptor sufficient for WebGL texture upload
  104079. */
  104080. export interface EnvironmentTextureInfo {
  104081. /**
  104082. * Version of the environment map
  104083. */
  104084. version: number;
  104085. /**
  104086. * Width of image
  104087. */
  104088. width: number;
  104089. /**
  104090. * Irradiance information stored in the file.
  104091. */
  104092. irradiance: any;
  104093. /**
  104094. * Specular information stored in the file.
  104095. */
  104096. specular: any;
  104097. }
  104098. /**
  104099. * Sets of helpers addressing the serialization and deserialization of environment texture
  104100. * stored in a BabylonJS env file.
  104101. * Those files are usually stored as .env files.
  104102. */
  104103. export class EnvironmentTextureTools {
  104104. /**
  104105. * Magic number identifying the env file.
  104106. */
  104107. private static _MagicBytes;
  104108. /**
  104109. * Gets the environment info from an env file.
  104110. * @param data The array buffer containing the .env bytes.
  104111. * @returns the environment file info (the json header) if successfully parsed.
  104112. */
  104113. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  104114. /**
  104115. * Creates an environment texture from a loaded cube texture.
  104116. * @param texture defines the cube texture to convert in env file
  104117. * @return a promise containing the environment data if succesfull.
  104118. */
  104119. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  104120. /**
  104121. * Creates a JSON representation of the spherical data.
  104122. * @param texture defines the texture containing the polynomials
  104123. * @return the JSON representation of the spherical info
  104124. */
  104125. private static _CreateEnvTextureIrradiance;
  104126. /**
  104127. * Uploads the texture info contained in the env file to the GPU.
  104128. * @param texture defines the internal texture to upload to
  104129. * @param arrayBuffer defines the buffer cotaining the data to load
  104130. * @param info defines the texture info retrieved through the GetEnvInfo method
  104131. * @returns a promise
  104132. */
  104133. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  104134. /**
  104135. * Uploads the levels of image data to the GPU.
  104136. * @param texture defines the internal texture to upload to
  104137. * @param imageData defines the array buffer views of image data [mipmap][face]
  104138. * @returns a promise
  104139. */
  104140. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  104141. /**
  104142. * Uploads spherical polynomials information to the texture.
  104143. * @param texture defines the texture we are trying to upload the information to
  104144. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  104145. */
  104146. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  104147. /** @hidden */
  104148. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  104149. }
  104150. }
  104151. declare module BABYLON {
  104152. /**
  104153. * Implementation of the ENV Texture Loader.
  104154. * @hidden
  104155. */
  104156. export class _ENVTextureLoader implements IInternalTextureLoader {
  104157. /**
  104158. * Defines wether the loader supports cascade loading the different faces.
  104159. */
  104160. readonly supportCascades: boolean;
  104161. /**
  104162. * This returns if the loader support the current file information.
  104163. * @param extension defines the file extension of the file being loaded
  104164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104165. * @param fallback defines the fallback internal texture if any
  104166. * @param isBase64 defines whether the texture is encoded as a base64
  104167. * @param isBuffer defines whether the texture data are stored as a buffer
  104168. * @returns true if the loader can load the specified file
  104169. */
  104170. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104171. /**
  104172. * Transform the url before loading if required.
  104173. * @param rootUrl the url of the texture
  104174. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104175. * @returns the transformed texture
  104176. */
  104177. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104178. /**
  104179. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104180. * @param rootUrl the url of the texture
  104181. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104182. * @returns the fallback texture
  104183. */
  104184. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104185. /**
  104186. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104187. * @param data contains the texture data
  104188. * @param texture defines the BabylonJS internal texture
  104189. * @param createPolynomials will be true if polynomials have been requested
  104190. * @param onLoad defines the callback to trigger once the texture is ready
  104191. * @param onError defines the callback to trigger in case of error
  104192. */
  104193. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104194. /**
  104195. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104196. * @param data contains the texture data
  104197. * @param texture defines the BabylonJS internal texture
  104198. * @param callback defines the method to call once ready to upload
  104199. */
  104200. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104201. }
  104202. }
  104203. declare module BABYLON {
  104204. /**
  104205. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104206. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104207. */
  104208. export class KhronosTextureContainer {
  104209. /** contents of the KTX container file */
  104210. arrayBuffer: any;
  104211. private static HEADER_LEN;
  104212. private static COMPRESSED_2D;
  104213. private static COMPRESSED_3D;
  104214. private static TEX_2D;
  104215. private static TEX_3D;
  104216. /**
  104217. * Gets the openGL type
  104218. */
  104219. glType: number;
  104220. /**
  104221. * Gets the openGL type size
  104222. */
  104223. glTypeSize: number;
  104224. /**
  104225. * Gets the openGL format
  104226. */
  104227. glFormat: number;
  104228. /**
  104229. * Gets the openGL internal format
  104230. */
  104231. glInternalFormat: number;
  104232. /**
  104233. * Gets the base internal format
  104234. */
  104235. glBaseInternalFormat: number;
  104236. /**
  104237. * Gets image width in pixel
  104238. */
  104239. pixelWidth: number;
  104240. /**
  104241. * Gets image height in pixel
  104242. */
  104243. pixelHeight: number;
  104244. /**
  104245. * Gets image depth in pixels
  104246. */
  104247. pixelDepth: number;
  104248. /**
  104249. * Gets the number of array elements
  104250. */
  104251. numberOfArrayElements: number;
  104252. /**
  104253. * Gets the number of faces
  104254. */
  104255. numberOfFaces: number;
  104256. /**
  104257. * Gets the number of mipmap levels
  104258. */
  104259. numberOfMipmapLevels: number;
  104260. /**
  104261. * Gets the bytes of key value data
  104262. */
  104263. bytesOfKeyValueData: number;
  104264. /**
  104265. * Gets the load type
  104266. */
  104267. loadType: number;
  104268. /**
  104269. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  104270. */
  104271. isInvalid: boolean;
  104272. /**
  104273. * Creates a new KhronosTextureContainer
  104274. * @param arrayBuffer contents of the KTX container file
  104275. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  104276. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  104277. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  104278. */
  104279. constructor(
  104280. /** contents of the KTX container file */
  104281. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  104282. /**
  104283. * Uploads KTX content to a Babylon Texture.
  104284. * It is assumed that the texture has already been created & is currently bound
  104285. * @hidden
  104286. */
  104287. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  104288. private _upload2DCompressedLevels;
  104289. }
  104290. }
  104291. declare module BABYLON {
  104292. /**
  104293. * Implementation of the KTX Texture Loader.
  104294. * @hidden
  104295. */
  104296. export class _KTXTextureLoader implements IInternalTextureLoader {
  104297. /**
  104298. * Defines wether the loader supports cascade loading the different faces.
  104299. */
  104300. readonly supportCascades: boolean;
  104301. /**
  104302. * This returns if the loader support the current file information.
  104303. * @param extension defines the file extension of the file being loaded
  104304. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104305. * @param fallback defines the fallback internal texture if any
  104306. * @param isBase64 defines whether the texture is encoded as a base64
  104307. * @param isBuffer defines whether the texture data are stored as a buffer
  104308. * @returns true if the loader can load the specified file
  104309. */
  104310. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104311. /**
  104312. * Transform the url before loading if required.
  104313. * @param rootUrl the url of the texture
  104314. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104315. * @returns the transformed texture
  104316. */
  104317. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104318. /**
  104319. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104320. * @param rootUrl the url of the texture
  104321. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104322. * @returns the fallback texture
  104323. */
  104324. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104325. /**
  104326. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104327. * @param data contains the texture data
  104328. * @param texture defines the BabylonJS internal texture
  104329. * @param createPolynomials will be true if polynomials have been requested
  104330. * @param onLoad defines the callback to trigger once the texture is ready
  104331. * @param onError defines the callback to trigger in case of error
  104332. */
  104333. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104334. /**
  104335. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104336. * @param data contains the texture data
  104337. * @param texture defines the BabylonJS internal texture
  104338. * @param callback defines the method to call once ready to upload
  104339. */
  104340. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  104341. }
  104342. }
  104343. declare module BABYLON {
  104344. /**
  104345. * Based on jsTGALoader - Javascript loader for TGA file
  104346. * By Vincent Thibault
  104347. * @see http://blog.robrowser.com/javascript-tga-loader.html
  104348. */
  104349. export class TGATools {
  104350. private static _TYPE_INDEXED;
  104351. private static _TYPE_RGB;
  104352. private static _TYPE_GREY;
  104353. private static _TYPE_RLE_INDEXED;
  104354. private static _TYPE_RLE_RGB;
  104355. private static _TYPE_RLE_GREY;
  104356. private static _ORIGIN_MASK;
  104357. private static _ORIGIN_SHIFT;
  104358. private static _ORIGIN_BL;
  104359. private static _ORIGIN_BR;
  104360. private static _ORIGIN_UL;
  104361. private static _ORIGIN_UR;
  104362. /**
  104363. * Gets the header of a TGA file
  104364. * @param data defines the TGA data
  104365. * @returns the header
  104366. */
  104367. static GetTGAHeader(data: Uint8Array): any;
  104368. /**
  104369. * Uploads TGA content to a Babylon Texture
  104370. * @hidden
  104371. */
  104372. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  104373. /** @hidden */
  104374. 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;
  104375. /** @hidden */
  104376. 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;
  104377. /** @hidden */
  104378. 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;
  104379. /** @hidden */
  104380. 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;
  104381. /** @hidden */
  104382. 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;
  104383. /** @hidden */
  104384. 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;
  104385. }
  104386. }
  104387. declare module BABYLON {
  104388. /**
  104389. * Implementation of the TGA Texture Loader.
  104390. * @hidden
  104391. */
  104392. export class _TGATextureLoader implements IInternalTextureLoader {
  104393. /**
  104394. * Defines wether the loader supports cascade loading the different faces.
  104395. */
  104396. readonly supportCascades: boolean;
  104397. /**
  104398. * This returns if the loader support the current file information.
  104399. * @param extension defines the file extension of the file being loaded
  104400. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104401. * @param fallback defines the fallback internal texture if any
  104402. * @param isBase64 defines whether the texture is encoded as a base64
  104403. * @param isBuffer defines whether the texture data are stored as a buffer
  104404. * @returns true if the loader can load the specified file
  104405. */
  104406. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104407. /**
  104408. * Transform the url before loading if required.
  104409. * @param rootUrl the url of the texture
  104410. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104411. * @returns the transformed texture
  104412. */
  104413. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104414. /**
  104415. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104416. * @param rootUrl the url of the texture
  104417. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104418. * @returns the fallback texture
  104419. */
  104420. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104421. /**
  104422. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104423. * @param data contains the texture data
  104424. * @param texture defines the BabylonJS internal texture
  104425. * @param createPolynomials will be true if polynomials have been requested
  104426. * @param onLoad defines the callback to trigger once the texture is ready
  104427. * @param onError defines the callback to trigger in case of error
  104428. */
  104429. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104430. /**
  104431. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104432. * @param data contains the texture data
  104433. * @param texture defines the BabylonJS internal texture
  104434. * @param callback defines the method to call once ready to upload
  104435. */
  104436. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104437. }
  104438. }
  104439. declare module BABYLON {
  104440. /**
  104441. * 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.
  104442. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104443. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104444. */
  104445. export class CustomProceduralTexture extends ProceduralTexture {
  104446. private _animate;
  104447. private _time;
  104448. private _config;
  104449. private _texturePath;
  104450. /**
  104451. * Instantiates a new Custom Procedural Texture.
  104452. * 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.
  104453. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104454. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104455. * @param name Define the name of the texture
  104456. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  104457. * @param size Define the size of the texture to create
  104458. * @param scene Define the scene the texture belongs to
  104459. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  104460. * @param generateMipMaps Define if the texture should creates mip maps or not
  104461. */
  104462. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104463. private _loadJson;
  104464. /**
  104465. * Is the texture ready to be used ? (rendered at least once)
  104466. * @returns true if ready, otherwise, false.
  104467. */
  104468. isReady(): boolean;
  104469. /**
  104470. * Render the texture to its associated render target.
  104471. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  104472. */
  104473. render(useCameraPostProcess?: boolean): void;
  104474. /**
  104475. * Update the list of dependant textures samplers in the shader.
  104476. */
  104477. updateTextures(): void;
  104478. /**
  104479. * Update the uniform values of the procedural texture in the shader.
  104480. */
  104481. updateShaderUniforms(): void;
  104482. /**
  104483. * Define if the texture animates or not.
  104484. */
  104485. animate: boolean;
  104486. }
  104487. }
  104488. declare module BABYLON {
  104489. /** @hidden */
  104490. export var noisePixelShader: {
  104491. name: string;
  104492. shader: string;
  104493. };
  104494. }
  104495. declare module BABYLON {
  104496. /**
  104497. * Class used to generate noise procedural textures
  104498. */
  104499. export class NoiseProceduralTexture extends ProceduralTexture {
  104500. private _time;
  104501. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  104502. brightness: number;
  104503. /** Defines the number of octaves to process */
  104504. octaves: number;
  104505. /** Defines the level of persistence (0.8 by default) */
  104506. persistence: number;
  104507. /** Gets or sets animation speed factor (default is 1) */
  104508. animationSpeedFactor: number;
  104509. /**
  104510. * Creates a new NoiseProceduralTexture
  104511. * @param name defines the name fo the texture
  104512. * @param size defines the size of the texture (default is 256)
  104513. * @param scene defines the hosting scene
  104514. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  104515. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  104516. */
  104517. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104518. private _updateShaderUniforms;
  104519. protected _getDefines(): string;
  104520. /** Generate the current state of the procedural texture */
  104521. render(useCameraPostProcess?: boolean): void;
  104522. /**
  104523. * Serializes this noise procedural texture
  104524. * @returns a serialized noise procedural texture object
  104525. */
  104526. serialize(): any;
  104527. /**
  104528. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  104529. * @param parsedTexture defines parsed texture data
  104530. * @param scene defines the current scene
  104531. * @param rootUrl defines the root URL containing noise procedural texture information
  104532. * @returns a parsed NoiseProceduralTexture
  104533. */
  104534. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  104535. }
  104536. }
  104537. declare module BABYLON {
  104538. /**
  104539. * Raw cube texture where the raw buffers are passed in
  104540. */
  104541. export class RawCubeTexture extends CubeTexture {
  104542. /**
  104543. * Creates a cube texture where the raw buffers are passed in.
  104544. * @param scene defines the scene the texture is attached to
  104545. * @param data defines the array of data to use to create each face
  104546. * @param size defines the size of the textures
  104547. * @param format defines the format of the data
  104548. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104549. * @param generateMipMaps defines if the engine should generate the mip levels
  104550. * @param invertY defines if data must be stored with Y axis inverted
  104551. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104552. * @param compression defines the compression used (null by default)
  104553. */
  104554. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  104555. /**
  104556. * Updates the raw cube texture.
  104557. * @param data defines the data to store
  104558. * @param format defines the data format
  104559. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104560. * @param invertY defines if data must be stored with Y axis inverted
  104561. * @param compression defines the compression used (null by default)
  104562. * @param level defines which level of the texture to update
  104563. */
  104564. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  104565. /**
  104566. * Updates a raw cube texture with RGBD encoded data.
  104567. * @param data defines the array of data [mipmap][face] to use to create each face
  104568. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  104569. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  104570. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  104571. * @returns a promsie that resolves when the operation is complete
  104572. */
  104573. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  104574. /**
  104575. * Clones the raw cube texture.
  104576. * @return a new cube texture
  104577. */
  104578. clone(): CubeTexture;
  104579. /** @hidden */
  104580. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  104581. }
  104582. }
  104583. declare module BABYLON {
  104584. /**
  104585. * Class used to store 3D textures containing user data
  104586. */
  104587. export class RawTexture3D extends Texture {
  104588. /** Gets or sets the texture format to use */
  104589. format: number;
  104590. private _engine;
  104591. /**
  104592. * Create a new RawTexture3D
  104593. * @param data defines the data of the texture
  104594. * @param width defines the width of the texture
  104595. * @param height defines the height of the texture
  104596. * @param depth defines the depth of the texture
  104597. * @param format defines the texture format to use
  104598. * @param scene defines the hosting scene
  104599. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  104600. * @param invertY defines if texture must be stored with Y axis inverted
  104601. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  104602. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  104603. */
  104604. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  104605. /** Gets or sets the texture format to use */
  104606. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  104607. /**
  104608. * Update the texture with new data
  104609. * @param data defines the data to store in the texture
  104610. */
  104611. update(data: ArrayBufferView): void;
  104612. }
  104613. }
  104614. declare module BABYLON {
  104615. /**
  104616. * Creates a refraction texture used by refraction channel of the standard material.
  104617. * It is like a mirror but to see through a material.
  104618. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104619. */
  104620. export class RefractionTexture extends RenderTargetTexture {
  104621. /**
  104622. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  104623. * 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.
  104624. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104625. */
  104626. refractionPlane: Plane;
  104627. /**
  104628. * Define how deep under the surface we should see.
  104629. */
  104630. depth: number;
  104631. /**
  104632. * Creates a refraction texture used by refraction channel of the standard material.
  104633. * It is like a mirror but to see through a material.
  104634. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104635. * @param name Define the texture name
  104636. * @param size Define the size of the underlying texture
  104637. * @param scene Define the scene the refraction belongs to
  104638. * @param generateMipMaps Define if we need to generate mips level for the refraction
  104639. */
  104640. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  104641. /**
  104642. * Clone the refraction texture.
  104643. * @returns the cloned texture
  104644. */
  104645. clone(): RefractionTexture;
  104646. /**
  104647. * Serialize the texture to a JSON representation you could use in Parse later on
  104648. * @returns the serialized JSON representation
  104649. */
  104650. serialize(): any;
  104651. }
  104652. }
  104653. declare module BABYLON {
  104654. /**
  104655. * Configuration for Draco compression
  104656. */
  104657. export interface IDracoCompressionConfiguration {
  104658. /**
  104659. * Configuration for the decoder.
  104660. */
  104661. decoder?: {
  104662. /**
  104663. * The url to the WebAssembly module.
  104664. */
  104665. wasmUrl?: string;
  104666. /**
  104667. * The url to the WebAssembly binary.
  104668. */
  104669. wasmBinaryUrl?: string;
  104670. /**
  104671. * The url to the fallback JavaScript module.
  104672. */
  104673. fallbackUrl?: string;
  104674. };
  104675. }
  104676. /**
  104677. * Draco compression (https://google.github.io/draco/)
  104678. *
  104679. * This class wraps the Draco module.
  104680. *
  104681. * **Encoder**
  104682. *
  104683. * The encoder is not currently implemented.
  104684. *
  104685. * **Decoder**
  104686. *
  104687. * 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.
  104688. *
  104689. * To update the configuration, use the following code:
  104690. * ```javascript
  104691. * DracoCompression.Configuration = {
  104692. * decoder: {
  104693. * wasmUrl: "<url to the WebAssembly library>",
  104694. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  104695. * fallbackUrl: "<url to the fallback JavaScript library>",
  104696. * }
  104697. * };
  104698. * ```
  104699. *
  104700. * 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.
  104701. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  104702. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  104703. *
  104704. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  104705. * ```javascript
  104706. * var dracoCompression = new DracoCompression();
  104707. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  104708. * [VertexBuffer.PositionKind]: 0
  104709. * });
  104710. * ```
  104711. *
  104712. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  104713. */
  104714. export class DracoCompression implements IDisposable {
  104715. private static _DecoderModulePromise;
  104716. /**
  104717. * The configuration. Defaults to the following urls:
  104718. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  104719. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  104720. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  104721. */
  104722. static Configuration: IDracoCompressionConfiguration;
  104723. /**
  104724. * Returns true if the decoder is available.
  104725. */
  104726. static readonly DecoderAvailable: boolean;
  104727. /**
  104728. * Constructor
  104729. */
  104730. constructor();
  104731. /**
  104732. * Stop all async operations and release resources.
  104733. */
  104734. dispose(): void;
  104735. /**
  104736. * Decode Draco compressed mesh data to vertex data.
  104737. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  104738. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  104739. * @returns A promise that resolves with the decoded vertex data
  104740. */
  104741. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  104742. [kind: string]: number;
  104743. }): Promise<VertexData>;
  104744. private static _GetDecoderModule;
  104745. private static _LoadScriptAsync;
  104746. private static _LoadFileAsync;
  104747. }
  104748. }
  104749. declare module BABYLON {
  104750. /**
  104751. * Class for building Constructive Solid Geometry
  104752. */
  104753. export class CSG {
  104754. private polygons;
  104755. /**
  104756. * The world matrix
  104757. */
  104758. matrix: Matrix;
  104759. /**
  104760. * Stores the position
  104761. */
  104762. position: Vector3;
  104763. /**
  104764. * Stores the rotation
  104765. */
  104766. rotation: Vector3;
  104767. /**
  104768. * Stores the rotation quaternion
  104769. */
  104770. rotationQuaternion: Nullable<Quaternion>;
  104771. /**
  104772. * Stores the scaling vector
  104773. */
  104774. scaling: Vector3;
  104775. /**
  104776. * Convert the Mesh to CSG
  104777. * @param mesh The Mesh to convert to CSG
  104778. * @returns A new CSG from the Mesh
  104779. */
  104780. static FromMesh(mesh: Mesh): CSG;
  104781. /**
  104782. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  104783. * @param polygons Polygons used to construct a CSG solid
  104784. */
  104785. private static FromPolygons;
  104786. /**
  104787. * Clones, or makes a deep copy, of the CSG
  104788. * @returns A new CSG
  104789. */
  104790. clone(): CSG;
  104791. /**
  104792. * Unions this CSG with another CSG
  104793. * @param csg The CSG to union against this CSG
  104794. * @returns The unioned CSG
  104795. */
  104796. union(csg: CSG): CSG;
  104797. /**
  104798. * Unions this CSG with another CSG in place
  104799. * @param csg The CSG to union against this CSG
  104800. */
  104801. unionInPlace(csg: CSG): void;
  104802. /**
  104803. * Subtracts this CSG with another CSG
  104804. * @param csg The CSG to subtract against this CSG
  104805. * @returns A new CSG
  104806. */
  104807. subtract(csg: CSG): CSG;
  104808. /**
  104809. * Subtracts this CSG with another CSG in place
  104810. * @param csg The CSG to subtact against this CSG
  104811. */
  104812. subtractInPlace(csg: CSG): void;
  104813. /**
  104814. * Intersect this CSG with another CSG
  104815. * @param csg The CSG to intersect against this CSG
  104816. * @returns A new CSG
  104817. */
  104818. intersect(csg: CSG): CSG;
  104819. /**
  104820. * Intersects this CSG with another CSG in place
  104821. * @param csg The CSG to intersect against this CSG
  104822. */
  104823. intersectInPlace(csg: CSG): void;
  104824. /**
  104825. * Return a new CSG solid with solid and empty space switched. This solid is
  104826. * not modified.
  104827. * @returns A new CSG solid with solid and empty space switched
  104828. */
  104829. inverse(): CSG;
  104830. /**
  104831. * Inverses the CSG in place
  104832. */
  104833. inverseInPlace(): void;
  104834. /**
  104835. * This is used to keep meshes transformations so they can be restored
  104836. * when we build back a Babylon Mesh
  104837. * NB : All CSG operations are performed in world coordinates
  104838. * @param csg The CSG to copy the transform attributes from
  104839. * @returns This CSG
  104840. */
  104841. copyTransformAttributes(csg: CSG): CSG;
  104842. /**
  104843. * Build Raw mesh from CSG
  104844. * Coordinates here are in world space
  104845. * @param name The name of the mesh geometry
  104846. * @param scene The Scene
  104847. * @param keepSubMeshes Specifies if the submeshes should be kept
  104848. * @returns A new Mesh
  104849. */
  104850. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  104851. /**
  104852. * Build Mesh from CSG taking material and transforms into account
  104853. * @param name The name of the Mesh
  104854. * @param material The material of the Mesh
  104855. * @param scene The Scene
  104856. * @param keepSubMeshes Specifies if submeshes should be kept
  104857. * @returns The new Mesh
  104858. */
  104859. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  104860. }
  104861. }
  104862. declare module BABYLON {
  104863. /**
  104864. * Class used to create a trail following a mesh
  104865. */
  104866. export class TrailMesh extends Mesh {
  104867. private _generator;
  104868. private _autoStart;
  104869. private _running;
  104870. private _diameter;
  104871. private _length;
  104872. private _sectionPolygonPointsCount;
  104873. private _sectionVectors;
  104874. private _sectionNormalVectors;
  104875. private _beforeRenderObserver;
  104876. /**
  104877. * @constructor
  104878. * @param name The value used by scene.getMeshByName() to do a lookup.
  104879. * @param generator The mesh to generate a trail.
  104880. * @param scene The scene to add this mesh to.
  104881. * @param diameter Diameter of trailing mesh. Default is 1.
  104882. * @param length Length of trailing mesh. Default is 60.
  104883. * @param autoStart Automatically start trailing mesh. Default true.
  104884. */
  104885. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  104886. /**
  104887. * "TrailMesh"
  104888. * @returns "TrailMesh"
  104889. */
  104890. getClassName(): string;
  104891. private _createMesh;
  104892. /**
  104893. * Start trailing mesh.
  104894. */
  104895. start(): void;
  104896. /**
  104897. * Stop trailing mesh.
  104898. */
  104899. stop(): void;
  104900. /**
  104901. * Update trailing mesh geometry.
  104902. */
  104903. update(): void;
  104904. /**
  104905. * Returns a new TrailMesh object.
  104906. * @param name is a string, the name given to the new mesh
  104907. * @param newGenerator use new generator object for cloned trail mesh
  104908. * @returns a new mesh
  104909. */
  104910. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  104911. /**
  104912. * Serializes this trail mesh
  104913. * @param serializationObject object to write serialization to
  104914. */
  104915. serialize(serializationObject: any): void;
  104916. /**
  104917. * Parses a serialized trail mesh
  104918. * @param parsedMesh the serialized mesh
  104919. * @param scene the scene to create the trail mesh in
  104920. * @returns the created trail mesh
  104921. */
  104922. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  104923. }
  104924. }
  104925. declare module BABYLON {
  104926. /**
  104927. * Class containing static functions to help procedurally build meshes
  104928. */
  104929. export class RibbonBuilder {
  104930. /**
  104931. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104932. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  104933. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  104934. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  104935. * * 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
  104936. * * 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
  104937. * * 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
  104938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104940. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104941. * * 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
  104942. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  104943. * * 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
  104944. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  104945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104946. * @param name defines the name of the mesh
  104947. * @param options defines the options used to create the mesh
  104948. * @param scene defines the hosting scene
  104949. * @returns the ribbon mesh
  104950. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  104951. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104952. */
  104953. static CreateRibbon(name: string, options: {
  104954. pathArray: Vector3[][];
  104955. closeArray?: boolean;
  104956. closePath?: boolean;
  104957. offset?: number;
  104958. updatable?: boolean;
  104959. sideOrientation?: number;
  104960. frontUVs?: Vector4;
  104961. backUVs?: Vector4;
  104962. instance?: Mesh;
  104963. invertUV?: boolean;
  104964. uvs?: Vector2[];
  104965. colors?: Color4[];
  104966. }, scene?: Nullable<Scene>): Mesh;
  104967. }
  104968. }
  104969. declare module BABYLON {
  104970. /**
  104971. * Class containing static functions to help procedurally build meshes
  104972. */
  104973. export class TorusKnotBuilder {
  104974. /**
  104975. * Creates a torus knot mesh
  104976. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  104977. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  104978. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  104979. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  104980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104981. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104983. * @param name defines the name of the mesh
  104984. * @param options defines the options used to create the mesh
  104985. * @param scene defines the hosting scene
  104986. * @returns the torus knot mesh
  104987. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  104988. */
  104989. static CreateTorusKnot(name: string, options: {
  104990. radius?: number;
  104991. tube?: number;
  104992. radialSegments?: number;
  104993. tubularSegments?: number;
  104994. p?: number;
  104995. q?: number;
  104996. updatable?: boolean;
  104997. sideOrientation?: number;
  104998. frontUVs?: Vector4;
  104999. backUVs?: Vector4;
  105000. }, scene: any): Mesh;
  105001. }
  105002. }
  105003. declare module BABYLON {
  105004. /**
  105005. * Polygon
  105006. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105007. */
  105008. export class Polygon {
  105009. /**
  105010. * Creates a rectangle
  105011. * @param xmin bottom X coord
  105012. * @param ymin bottom Y coord
  105013. * @param xmax top X coord
  105014. * @param ymax top Y coord
  105015. * @returns points that make the resulting rectation
  105016. */
  105017. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  105018. /**
  105019. * Creates a circle
  105020. * @param radius radius of circle
  105021. * @param cx scale in x
  105022. * @param cy scale in y
  105023. * @param numberOfSides number of sides that make up the circle
  105024. * @returns points that make the resulting circle
  105025. */
  105026. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  105027. /**
  105028. * Creates a polygon from input string
  105029. * @param input Input polygon data
  105030. * @returns the parsed points
  105031. */
  105032. static Parse(input: string): Vector2[];
  105033. /**
  105034. * Starts building a polygon from x and y coordinates
  105035. * @param x x coordinate
  105036. * @param y y coordinate
  105037. * @returns the started path2
  105038. */
  105039. static StartingAt(x: number, y: number): Path2;
  105040. }
  105041. /**
  105042. * Builds a polygon
  105043. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  105044. */
  105045. export class PolygonMeshBuilder {
  105046. private _points;
  105047. private _outlinepoints;
  105048. private _holes;
  105049. private _name;
  105050. private _scene;
  105051. private _epoints;
  105052. private _eholes;
  105053. private _addToepoint;
  105054. /**
  105055. * Babylon reference to the earcut plugin.
  105056. */
  105057. bjsEarcut: any;
  105058. /**
  105059. * Creates a PolygonMeshBuilder
  105060. * @param name name of the builder
  105061. * @param contours Path of the polygon
  105062. * @param scene scene to add to
  105063. * @param earcutInjection can be used to inject your own earcut reference
  105064. */
  105065. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  105066. /**
  105067. * Adds a whole within the polygon
  105068. * @param hole Array of points defining the hole
  105069. * @returns this
  105070. */
  105071. addHole(hole: Vector2[]): PolygonMeshBuilder;
  105072. /**
  105073. * Creates the polygon
  105074. * @param updatable If the mesh should be updatable
  105075. * @param depth The depth of the mesh created
  105076. * @returns the created mesh
  105077. */
  105078. build(updatable?: boolean, depth?: number): Mesh;
  105079. /**
  105080. * Adds a side to the polygon
  105081. * @param positions points that make the polygon
  105082. * @param normals normals of the polygon
  105083. * @param uvs uvs of the polygon
  105084. * @param indices indices of the polygon
  105085. * @param bounds bounds of the polygon
  105086. * @param points points of the polygon
  105087. * @param depth depth of the polygon
  105088. * @param flip flip of the polygon
  105089. */
  105090. private addSide;
  105091. }
  105092. }
  105093. declare module BABYLON {
  105094. /**
  105095. * Class containing static functions to help procedurally build meshes
  105096. */
  105097. export class PolygonBuilder {
  105098. /**
  105099. * Creates a polygon mesh
  105100. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105101. * * 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
  105102. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105105. * * Remember you can only change the shape positions, not their number when updating a polygon
  105106. * @param name defines the name of the mesh
  105107. * @param options defines the options used to create the mesh
  105108. * @param scene defines the hosting scene
  105109. * @param earcutInjection can be used to inject your own earcut reference
  105110. * @returns the polygon mesh
  105111. */
  105112. static CreatePolygon(name: string, options: {
  105113. shape: Vector3[];
  105114. holes?: Vector3[][];
  105115. depth?: number;
  105116. faceUV?: Vector4[];
  105117. faceColors?: Color4[];
  105118. updatable?: boolean;
  105119. sideOrientation?: number;
  105120. frontUVs?: Vector4;
  105121. backUVs?: Vector4;
  105122. }, scene: Scene, earcutInjection?: any): Mesh;
  105123. /**
  105124. * Creates an extruded polygon mesh, with depth in the Y direction.
  105125. * * 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)
  105126. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105127. * @param name defines the name of the mesh
  105128. * @param options defines the options used to create the mesh
  105129. * @param scene defines the hosting scene
  105130. * @param earcutInjection can be used to inject your own earcut reference
  105131. * @returns the polygon mesh
  105132. */
  105133. static ExtrudePolygon(name: string, options: {
  105134. shape: Vector3[];
  105135. holes?: Vector3[][];
  105136. depth?: number;
  105137. faceUV?: Vector4[];
  105138. faceColors?: Color4[];
  105139. updatable?: boolean;
  105140. sideOrientation?: number;
  105141. frontUVs?: Vector4;
  105142. backUVs?: Vector4;
  105143. }, scene: Scene, earcutInjection?: any): Mesh;
  105144. }
  105145. }
  105146. declare module BABYLON {
  105147. /**
  105148. * Class containing static functions to help procedurally build meshes
  105149. */
  105150. export class ShapeBuilder {
  105151. /**
  105152. * 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.
  105153. * * 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.
  105154. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105155. * * 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.
  105156. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105157. * * 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
  105158. * * 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
  105159. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105162. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105164. * @param name defines the name of the mesh
  105165. * @param options defines the options used to create the mesh
  105166. * @param scene defines the hosting scene
  105167. * @returns the extruded shape mesh
  105168. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105170. */
  105171. static ExtrudeShape(name: string, options: {
  105172. shape: Vector3[];
  105173. path: Vector3[];
  105174. scale?: number;
  105175. rotation?: number;
  105176. cap?: number;
  105177. updatable?: boolean;
  105178. sideOrientation?: number;
  105179. frontUVs?: Vector4;
  105180. backUVs?: Vector4;
  105181. instance?: Mesh;
  105182. invertUV?: boolean;
  105183. }, scene?: Nullable<Scene>): Mesh;
  105184. /**
  105185. * Creates an custom extruded shape mesh.
  105186. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105187. * * 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.
  105188. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105189. * * 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
  105190. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105191. * * 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
  105192. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105193. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105194. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105195. * * 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
  105196. * * 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
  105197. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105199. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105200. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105202. * @param name defines the name of the mesh
  105203. * @param options defines the options used to create the mesh
  105204. * @param scene defines the hosting scene
  105205. * @returns the custom extruded shape mesh
  105206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105207. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105209. */
  105210. static ExtrudeShapeCustom(name: string, options: {
  105211. shape: Vector3[];
  105212. path: Vector3[];
  105213. scaleFunction?: any;
  105214. rotationFunction?: any;
  105215. ribbonCloseArray?: boolean;
  105216. ribbonClosePath?: boolean;
  105217. cap?: number;
  105218. updatable?: boolean;
  105219. sideOrientation?: number;
  105220. frontUVs?: Vector4;
  105221. backUVs?: Vector4;
  105222. instance?: Mesh;
  105223. invertUV?: boolean;
  105224. }, scene: Scene): Mesh;
  105225. private static _ExtrudeShapeGeneric;
  105226. }
  105227. }
  105228. declare module BABYLON {
  105229. /**
  105230. * Class containing static functions to help procedurally build meshes
  105231. */
  105232. export class LatheBuilder {
  105233. /**
  105234. * Creates lathe mesh.
  105235. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105236. * * 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
  105237. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105238. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105239. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105240. * * 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
  105241. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105242. * * 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
  105243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105245. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105247. * @param name defines the name of the mesh
  105248. * @param options defines the options used to create the mesh
  105249. * @param scene defines the hosting scene
  105250. * @returns the lathe mesh
  105251. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105252. */
  105253. static CreateLathe(name: string, options: {
  105254. shape: Vector3[];
  105255. radius?: number;
  105256. tessellation?: number;
  105257. clip?: number;
  105258. arc?: number;
  105259. closed?: boolean;
  105260. updatable?: boolean;
  105261. sideOrientation?: number;
  105262. frontUVs?: Vector4;
  105263. backUVs?: Vector4;
  105264. cap?: number;
  105265. invertUV?: boolean;
  105266. }, scene: Scene): Mesh;
  105267. }
  105268. }
  105269. declare module BABYLON {
  105270. /**
  105271. * Class containing static functions to help procedurally build meshes
  105272. */
  105273. export class TubeBuilder {
  105274. /**
  105275. * Creates a tube mesh.
  105276. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105277. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105278. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105279. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105280. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105281. * * 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)
  105282. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105283. * * 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
  105284. * * 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
  105285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105286. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105287. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105289. * @param name defines the name of the mesh
  105290. * @param options defines the options used to create the mesh
  105291. * @param scene defines the hosting scene
  105292. * @returns the tube mesh
  105293. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105294. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105295. */
  105296. static CreateTube(name: string, options: {
  105297. path: Vector3[];
  105298. radius?: number;
  105299. tessellation?: number;
  105300. radiusFunction?: {
  105301. (i: number, distance: number): number;
  105302. };
  105303. cap?: number;
  105304. arc?: number;
  105305. updatable?: boolean;
  105306. sideOrientation?: number;
  105307. frontUVs?: Vector4;
  105308. backUVs?: Vector4;
  105309. instance?: Mesh;
  105310. invertUV?: boolean;
  105311. }, scene: Scene): Mesh;
  105312. }
  105313. }
  105314. declare module BABYLON {
  105315. /**
  105316. * Class containing static functions to help procedurally build meshes
  105317. */
  105318. export class IcoSphereBuilder {
  105319. /**
  105320. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105321. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105322. * * 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`)
  105323. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105324. * * 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
  105325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105326. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105328. * @param name defines the name of the mesh
  105329. * @param options defines the options used to create the mesh
  105330. * @param scene defines the hosting scene
  105331. * @returns the icosahedron mesh
  105332. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105333. */
  105334. static CreateIcoSphere(name: string, options: {
  105335. radius?: number;
  105336. radiusX?: number;
  105337. radiusY?: number;
  105338. radiusZ?: number;
  105339. flat?: boolean;
  105340. subdivisions?: number;
  105341. sideOrientation?: number;
  105342. frontUVs?: Vector4;
  105343. backUVs?: Vector4;
  105344. updatable?: boolean;
  105345. }, scene: Scene): Mesh;
  105346. }
  105347. }
  105348. declare module BABYLON {
  105349. /**
  105350. * Class containing static functions to help procedurally build meshes
  105351. */
  105352. export class DecalBuilder {
  105353. /**
  105354. * Creates a decal mesh.
  105355. * 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
  105356. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  105357. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  105358. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  105359. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  105360. * @param name defines the name of the mesh
  105361. * @param sourceMesh defines the mesh where the decal must be applied
  105362. * @param options defines the options used to create the mesh
  105363. * @param scene defines the hosting scene
  105364. * @returns the decal mesh
  105365. * @see https://doc.babylonjs.com/how_to/decals
  105366. */
  105367. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  105368. position?: Vector3;
  105369. normal?: Vector3;
  105370. size?: Vector3;
  105371. angle?: number;
  105372. }): Mesh;
  105373. }
  105374. }
  105375. declare module BABYLON {
  105376. /**
  105377. * Class containing static functions to help procedurally build meshes
  105378. */
  105379. export class MeshBuilder {
  105380. /**
  105381. * Creates a box mesh
  105382. * * The parameter `size` sets the size (float) of each box side (default 1)
  105383. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  105384. * * 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)
  105385. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105389. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  105390. * @param name defines the name of the mesh
  105391. * @param options defines the options used to create the mesh
  105392. * @param scene defines the hosting scene
  105393. * @returns the box mesh
  105394. */
  105395. static CreateBox(name: string, options: {
  105396. size?: number;
  105397. width?: number;
  105398. height?: number;
  105399. depth?: number;
  105400. faceUV?: Vector4[];
  105401. faceColors?: Color4[];
  105402. sideOrientation?: number;
  105403. frontUVs?: Vector4;
  105404. backUVs?: Vector4;
  105405. updatable?: boolean;
  105406. }, scene?: Nullable<Scene>): Mesh;
  105407. /**
  105408. * Creates a sphere mesh
  105409. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  105410. * * 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`)
  105411. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  105412. * * 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
  105413. * * 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)
  105414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105417. * @param name defines the name of the mesh
  105418. * @param options defines the options used to create the mesh
  105419. * @param scene defines the hosting scene
  105420. * @returns the sphere mesh
  105421. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  105422. */
  105423. static CreateSphere(name: string, options: {
  105424. segments?: number;
  105425. diameter?: number;
  105426. diameterX?: number;
  105427. diameterY?: number;
  105428. diameterZ?: number;
  105429. arc?: number;
  105430. slice?: number;
  105431. sideOrientation?: number;
  105432. frontUVs?: Vector4;
  105433. backUVs?: Vector4;
  105434. updatable?: boolean;
  105435. }, scene: any): Mesh;
  105436. /**
  105437. * Creates a plane polygonal mesh. By default, this is a disc
  105438. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  105439. * * 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
  105440. * * 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
  105441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105444. * @param name defines the name of the mesh
  105445. * @param options defines the options used to create the mesh
  105446. * @param scene defines the hosting scene
  105447. * @returns the plane polygonal mesh
  105448. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  105449. */
  105450. static CreateDisc(name: string, options: {
  105451. radius?: number;
  105452. tessellation?: number;
  105453. arc?: number;
  105454. updatable?: boolean;
  105455. sideOrientation?: number;
  105456. frontUVs?: Vector4;
  105457. backUVs?: Vector4;
  105458. }, scene?: Nullable<Scene>): Mesh;
  105459. /**
  105460. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105461. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105462. * * 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`)
  105463. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105464. * * 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
  105465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105468. * @param name defines the name of the mesh
  105469. * @param options defines the options used to create the mesh
  105470. * @param scene defines the hosting scene
  105471. * @returns the icosahedron mesh
  105472. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105473. */
  105474. static CreateIcoSphere(name: string, options: {
  105475. radius?: number;
  105476. radiusX?: number;
  105477. radiusY?: number;
  105478. radiusZ?: number;
  105479. flat?: boolean;
  105480. subdivisions?: number;
  105481. sideOrientation?: number;
  105482. frontUVs?: Vector4;
  105483. backUVs?: Vector4;
  105484. updatable?: boolean;
  105485. }, scene: Scene): Mesh;
  105486. /**
  105487. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105488. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105489. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105490. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105491. * * 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
  105492. * * 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
  105493. * * 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
  105494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105496. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105497. * * 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
  105498. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105499. * * 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
  105500. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105502. * @param name defines the name of the mesh
  105503. * @param options defines the options used to create the mesh
  105504. * @param scene defines the hosting scene
  105505. * @returns the ribbon mesh
  105506. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105507. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105508. */
  105509. static CreateRibbon(name: string, options: {
  105510. pathArray: Vector3[][];
  105511. closeArray?: boolean;
  105512. closePath?: boolean;
  105513. offset?: number;
  105514. updatable?: boolean;
  105515. sideOrientation?: number;
  105516. frontUVs?: Vector4;
  105517. backUVs?: Vector4;
  105518. instance?: Mesh;
  105519. invertUV?: boolean;
  105520. uvs?: Vector2[];
  105521. colors?: Color4[];
  105522. }, scene?: Nullable<Scene>): Mesh;
  105523. /**
  105524. * Creates a cylinder or a cone mesh
  105525. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105526. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105527. * * 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.
  105528. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  105529. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  105530. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  105531. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  105532. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  105533. * * 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).
  105534. * * 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
  105535. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  105536. * * 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
  105537. * * 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.
  105538. * * If `enclose` is false, a ring surface is one element.
  105539. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  105540. * * 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
  105541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105544. * @param name defines the name of the mesh
  105545. * @param options defines the options used to create the mesh
  105546. * @param scene defines the hosting scene
  105547. * @returns the cylinder mesh
  105548. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  105549. */
  105550. static CreateCylinder(name: string, options: {
  105551. height?: number;
  105552. diameterTop?: number;
  105553. diameterBottom?: number;
  105554. diameter?: number;
  105555. tessellation?: number;
  105556. subdivisions?: number;
  105557. arc?: number;
  105558. faceColors?: Color4[];
  105559. faceUV?: Vector4[];
  105560. updatable?: boolean;
  105561. hasRings?: boolean;
  105562. enclose?: boolean;
  105563. sideOrientation?: number;
  105564. frontUVs?: Vector4;
  105565. backUVs?: Vector4;
  105566. }, scene: any): Mesh;
  105567. /**
  105568. * Creates a torus mesh
  105569. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  105570. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  105571. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  105572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105575. * @param name defines the name of the mesh
  105576. * @param options defines the options used to create the mesh
  105577. * @param scene defines the hosting scene
  105578. * @returns the torus mesh
  105579. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  105580. */
  105581. static CreateTorus(name: string, options: {
  105582. diameter?: number;
  105583. thickness?: number;
  105584. tessellation?: number;
  105585. updatable?: boolean;
  105586. sideOrientation?: number;
  105587. frontUVs?: Vector4;
  105588. backUVs?: Vector4;
  105589. }, scene: any): Mesh;
  105590. /**
  105591. * Creates a torus knot mesh
  105592. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105593. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105594. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105595. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105599. * @param name defines the name of the mesh
  105600. * @param options defines the options used to create the mesh
  105601. * @param scene defines the hosting scene
  105602. * @returns the torus knot mesh
  105603. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105604. */
  105605. static CreateTorusKnot(name: string, options: {
  105606. radius?: number;
  105607. tube?: number;
  105608. radialSegments?: number;
  105609. tubularSegments?: number;
  105610. p?: number;
  105611. q?: number;
  105612. updatable?: boolean;
  105613. sideOrientation?: number;
  105614. frontUVs?: Vector4;
  105615. backUVs?: Vector4;
  105616. }, scene: any): Mesh;
  105617. /**
  105618. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  105619. * * 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
  105620. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  105621. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  105622. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  105623. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  105624. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  105625. * * 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
  105626. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  105627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105628. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  105629. * @param name defines the name of the new line system
  105630. * @param options defines the options used to create the line system
  105631. * @param scene defines the hosting scene
  105632. * @returns a new line system mesh
  105633. */
  105634. static CreateLineSystem(name: string, options: {
  105635. lines: Vector3[][];
  105636. updatable?: boolean;
  105637. instance?: Nullable<LinesMesh>;
  105638. colors?: Nullable<Color4[][]>;
  105639. useVertexAlpha?: boolean;
  105640. }, scene: Nullable<Scene>): LinesMesh;
  105641. /**
  105642. * Creates a line mesh
  105643. * 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
  105644. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105645. * * The parameter `points` is an array successive Vector3
  105646. * * 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
  105647. * * The optional parameter `colors` is an array of successive Color4, one per line point
  105648. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  105649. * * When updating an instance, remember that only point positions can change, not the number of points
  105650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  105652. * @param name defines the name of the new line system
  105653. * @param options defines the options used to create the line system
  105654. * @param scene defines the hosting scene
  105655. * @returns a new line mesh
  105656. */
  105657. static CreateLines(name: string, options: {
  105658. points: Vector3[];
  105659. updatable?: boolean;
  105660. instance?: Nullable<LinesMesh>;
  105661. colors?: Color4[];
  105662. useVertexAlpha?: boolean;
  105663. }, scene?: Nullable<Scene>): LinesMesh;
  105664. /**
  105665. * Creates a dashed line mesh
  105666. * * 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
  105667. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105668. * * The parameter `points` is an array successive Vector3
  105669. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  105670. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  105671. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105672. * * 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
  105673. * * When updating an instance, remember that only point positions can change, not the number of points
  105674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105675. * @param name defines the name of the mesh
  105676. * @param options defines the options used to create the mesh
  105677. * @param scene defines the hosting scene
  105678. * @returns the dashed line mesh
  105679. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  105680. */
  105681. static CreateDashedLines(name: string, options: {
  105682. points: Vector3[];
  105683. dashSize?: number;
  105684. gapSize?: number;
  105685. dashNb?: number;
  105686. updatable?: boolean;
  105687. instance?: LinesMesh;
  105688. }, scene?: Nullable<Scene>): LinesMesh;
  105689. /**
  105690. * 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.
  105691. * * 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.
  105692. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105693. * * 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.
  105694. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105695. * * 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
  105696. * * 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
  105697. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105699. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105700. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105702. * @param name defines the name of the mesh
  105703. * @param options defines the options used to create the mesh
  105704. * @param scene defines the hosting scene
  105705. * @returns the extruded shape mesh
  105706. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105708. */
  105709. static ExtrudeShape(name: string, options: {
  105710. shape: Vector3[];
  105711. path: Vector3[];
  105712. scale?: number;
  105713. rotation?: number;
  105714. cap?: number;
  105715. updatable?: boolean;
  105716. sideOrientation?: number;
  105717. frontUVs?: Vector4;
  105718. backUVs?: Vector4;
  105719. instance?: Mesh;
  105720. invertUV?: boolean;
  105721. }, scene?: Nullable<Scene>): Mesh;
  105722. /**
  105723. * Creates an custom extruded shape mesh.
  105724. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105725. * * 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.
  105726. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105727. * * 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
  105728. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105729. * * 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
  105730. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105731. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105732. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105733. * * 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
  105734. * * 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
  105735. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105737. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105738. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105740. * @param name defines the name of the mesh
  105741. * @param options defines the options used to create the mesh
  105742. * @param scene defines the hosting scene
  105743. * @returns the custom extruded shape mesh
  105744. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105745. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105746. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105747. */
  105748. static ExtrudeShapeCustom(name: string, options: {
  105749. shape: Vector3[];
  105750. path: Vector3[];
  105751. scaleFunction?: any;
  105752. rotationFunction?: any;
  105753. ribbonCloseArray?: boolean;
  105754. ribbonClosePath?: boolean;
  105755. cap?: number;
  105756. updatable?: boolean;
  105757. sideOrientation?: number;
  105758. frontUVs?: Vector4;
  105759. backUVs?: Vector4;
  105760. instance?: Mesh;
  105761. invertUV?: boolean;
  105762. }, scene: Scene): Mesh;
  105763. /**
  105764. * Creates lathe mesh.
  105765. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105766. * * 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
  105767. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105768. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105769. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105770. * * 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
  105771. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105772. * * 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
  105773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105775. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105777. * @param name defines the name of the mesh
  105778. * @param options defines the options used to create the mesh
  105779. * @param scene defines the hosting scene
  105780. * @returns the lathe mesh
  105781. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105782. */
  105783. static CreateLathe(name: string, options: {
  105784. shape: Vector3[];
  105785. radius?: number;
  105786. tessellation?: number;
  105787. clip?: number;
  105788. arc?: number;
  105789. closed?: boolean;
  105790. updatable?: boolean;
  105791. sideOrientation?: number;
  105792. frontUVs?: Vector4;
  105793. backUVs?: Vector4;
  105794. cap?: number;
  105795. invertUV?: boolean;
  105796. }, scene: Scene): Mesh;
  105797. /**
  105798. * Creates a plane mesh
  105799. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105800. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105801. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105805. * @param name defines the name of the mesh
  105806. * @param options defines the options used to create the mesh
  105807. * @param scene defines the hosting scene
  105808. * @returns the plane mesh
  105809. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105810. */
  105811. static CreatePlane(name: string, options: {
  105812. size?: number;
  105813. width?: number;
  105814. height?: number;
  105815. sideOrientation?: number;
  105816. frontUVs?: Vector4;
  105817. backUVs?: Vector4;
  105818. updatable?: boolean;
  105819. sourcePlane?: Plane;
  105820. }, scene: Scene): Mesh;
  105821. /**
  105822. * Creates a ground mesh
  105823. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  105824. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  105825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105826. * @param name defines the name of the mesh
  105827. * @param options defines the options used to create the mesh
  105828. * @param scene defines the hosting scene
  105829. * @returns the ground mesh
  105830. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  105831. */
  105832. static CreateGround(name: string, options: {
  105833. width?: number;
  105834. height?: number;
  105835. subdivisions?: number;
  105836. subdivisionsX?: number;
  105837. subdivisionsY?: number;
  105838. updatable?: boolean;
  105839. }, scene: any): Mesh;
  105840. /**
  105841. * Creates a tiled ground mesh
  105842. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  105843. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  105844. * * 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
  105845. * * 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
  105846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105847. * @param name defines the name of the mesh
  105848. * @param options defines the options used to create the mesh
  105849. * @param scene defines the hosting scene
  105850. * @returns the tiled ground mesh
  105851. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  105852. */
  105853. static CreateTiledGround(name: string, options: {
  105854. xmin: number;
  105855. zmin: number;
  105856. xmax: number;
  105857. zmax: number;
  105858. subdivisions?: {
  105859. w: number;
  105860. h: number;
  105861. };
  105862. precision?: {
  105863. w: number;
  105864. h: number;
  105865. };
  105866. updatable?: boolean;
  105867. }, scene: Scene): Mesh;
  105868. /**
  105869. * Creates a ground mesh from a height map
  105870. * * The parameter `url` sets the URL of the height map image resource.
  105871. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  105872. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  105873. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  105874. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  105875. * * 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.
  105876. * * 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).
  105877. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105879. * @param name defines the name of the mesh
  105880. * @param url defines the url to the height map
  105881. * @param options defines the options used to create the mesh
  105882. * @param scene defines the hosting scene
  105883. * @returns the ground mesh
  105884. * @see https://doc.babylonjs.com/babylon101/height_map
  105885. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105886. */
  105887. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105888. width?: number;
  105889. height?: number;
  105890. subdivisions?: number;
  105891. minHeight?: number;
  105892. maxHeight?: number;
  105893. colorFilter?: Color3;
  105894. alphaFilter?: number;
  105895. updatable?: boolean;
  105896. onReady?: (mesh: GroundMesh) => void;
  105897. }, scene: Scene): GroundMesh;
  105898. /**
  105899. * Creates a polygon mesh
  105900. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105901. * * 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
  105902. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105905. * * Remember you can only change the shape positions, not their number when updating a polygon
  105906. * @param name defines the name of the mesh
  105907. * @param options defines the options used to create the mesh
  105908. * @param scene defines the hosting scene
  105909. * @param earcutInjection can be used to inject your own earcut reference
  105910. * @returns the polygon mesh
  105911. */
  105912. static CreatePolygon(name: string, options: {
  105913. shape: Vector3[];
  105914. holes?: Vector3[][];
  105915. depth?: number;
  105916. faceUV?: Vector4[];
  105917. faceColors?: Color4[];
  105918. updatable?: boolean;
  105919. sideOrientation?: number;
  105920. frontUVs?: Vector4;
  105921. backUVs?: Vector4;
  105922. }, scene: Scene, earcutInjection?: any): Mesh;
  105923. /**
  105924. * Creates an extruded polygon mesh, with depth in the Y direction.
  105925. * * 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)
  105926. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105927. * @param name defines the name of the mesh
  105928. * @param options defines the options used to create the mesh
  105929. * @param scene defines the hosting scene
  105930. * @param earcutInjection can be used to inject your own earcut reference
  105931. * @returns the polygon mesh
  105932. */
  105933. static ExtrudePolygon(name: string, options: {
  105934. shape: Vector3[];
  105935. holes?: Vector3[][];
  105936. depth?: number;
  105937. faceUV?: Vector4[];
  105938. faceColors?: Color4[];
  105939. updatable?: boolean;
  105940. sideOrientation?: number;
  105941. frontUVs?: Vector4;
  105942. backUVs?: Vector4;
  105943. }, scene: Scene, earcutInjection?: any): Mesh;
  105944. /**
  105945. * Creates a tube mesh.
  105946. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105947. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105948. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105949. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105950. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105951. * * 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)
  105952. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105953. * * 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
  105954. * * 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
  105955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105957. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105959. * @param name defines the name of the mesh
  105960. * @param options defines the options used to create the mesh
  105961. * @param scene defines the hosting scene
  105962. * @returns the tube mesh
  105963. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105964. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105965. */
  105966. static CreateTube(name: string, options: {
  105967. path: Vector3[];
  105968. radius?: number;
  105969. tessellation?: number;
  105970. radiusFunction?: {
  105971. (i: number, distance: number): number;
  105972. };
  105973. cap?: number;
  105974. arc?: number;
  105975. updatable?: boolean;
  105976. sideOrientation?: number;
  105977. frontUVs?: Vector4;
  105978. backUVs?: Vector4;
  105979. instance?: Mesh;
  105980. invertUV?: boolean;
  105981. }, scene: Scene): Mesh;
  105982. /**
  105983. * Creates a polyhedron mesh
  105984. * * 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
  105985. * * The parameter `size` (positive float, default 1) sets the polygon size
  105986. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105987. * * 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`
  105988. * * 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
  105989. * * 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)`)
  105990. * * 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
  105991. * * 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
  105992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105995. * @param name defines the name of the mesh
  105996. * @param options defines the options used to create the mesh
  105997. * @param scene defines the hosting scene
  105998. * @returns the polyhedron mesh
  105999. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106000. */
  106001. static CreatePolyhedron(name: string, options: {
  106002. type?: number;
  106003. size?: number;
  106004. sizeX?: number;
  106005. sizeY?: number;
  106006. sizeZ?: number;
  106007. custom?: any;
  106008. faceUV?: Vector4[];
  106009. faceColors?: Color4[];
  106010. flat?: boolean;
  106011. updatable?: boolean;
  106012. sideOrientation?: number;
  106013. frontUVs?: Vector4;
  106014. backUVs?: Vector4;
  106015. }, scene: Scene): Mesh;
  106016. /**
  106017. * Creates a decal mesh.
  106018. * 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
  106019. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106020. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106021. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106022. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106023. * @param name defines the name of the mesh
  106024. * @param sourceMesh defines the mesh where the decal must be applied
  106025. * @param options defines the options used to create the mesh
  106026. * @param scene defines the hosting scene
  106027. * @returns the decal mesh
  106028. * @see https://doc.babylonjs.com/how_to/decals
  106029. */
  106030. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106031. position?: Vector3;
  106032. normal?: Vector3;
  106033. size?: Vector3;
  106034. angle?: number;
  106035. }): Mesh;
  106036. }
  106037. }
  106038. declare module BABYLON {
  106039. /**
  106040. * A simplifier interface for future simplification implementations
  106041. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106042. */
  106043. export interface ISimplifier {
  106044. /**
  106045. * Simplification of a given mesh according to the given settings.
  106046. * Since this requires computation, it is assumed that the function runs async.
  106047. * @param settings The settings of the simplification, including quality and distance
  106048. * @param successCallback A callback that will be called after the mesh was simplified.
  106049. * @param errorCallback in case of an error, this callback will be called. optional.
  106050. */
  106051. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  106052. }
  106053. /**
  106054. * Expected simplification settings.
  106055. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  106056. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106057. */
  106058. export interface ISimplificationSettings {
  106059. /**
  106060. * Gets or sets the expected quality
  106061. */
  106062. quality: number;
  106063. /**
  106064. * Gets or sets the distance when this optimized version should be used
  106065. */
  106066. distance: number;
  106067. /**
  106068. * Gets an already optimized mesh
  106069. */
  106070. optimizeMesh?: boolean;
  106071. }
  106072. /**
  106073. * Class used to specify simplification options
  106074. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106075. */
  106076. export class SimplificationSettings implements ISimplificationSettings {
  106077. /** expected quality */
  106078. quality: number;
  106079. /** distance when this optimized version should be used */
  106080. distance: number;
  106081. /** already optimized mesh */
  106082. optimizeMesh?: boolean | undefined;
  106083. /**
  106084. * Creates a SimplificationSettings
  106085. * @param quality expected quality
  106086. * @param distance distance when this optimized version should be used
  106087. * @param optimizeMesh already optimized mesh
  106088. */
  106089. constructor(
  106090. /** expected quality */
  106091. quality: number,
  106092. /** distance when this optimized version should be used */
  106093. distance: number,
  106094. /** already optimized mesh */
  106095. optimizeMesh?: boolean | undefined);
  106096. }
  106097. /**
  106098. * Interface used to define a simplification task
  106099. */
  106100. export interface ISimplificationTask {
  106101. /**
  106102. * Array of settings
  106103. */
  106104. settings: Array<ISimplificationSettings>;
  106105. /**
  106106. * Simplification type
  106107. */
  106108. simplificationType: SimplificationType;
  106109. /**
  106110. * Mesh to simplify
  106111. */
  106112. mesh: Mesh;
  106113. /**
  106114. * Callback called on success
  106115. */
  106116. successCallback?: () => void;
  106117. /**
  106118. * Defines if parallel processing can be used
  106119. */
  106120. parallelProcessing: boolean;
  106121. }
  106122. /**
  106123. * Queue used to order the simplification tasks
  106124. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106125. */
  106126. export class SimplificationQueue {
  106127. private _simplificationArray;
  106128. /**
  106129. * Gets a boolean indicating that the process is still running
  106130. */
  106131. running: boolean;
  106132. /**
  106133. * Creates a new queue
  106134. */
  106135. constructor();
  106136. /**
  106137. * Adds a new simplification task
  106138. * @param task defines a task to add
  106139. */
  106140. addTask(task: ISimplificationTask): void;
  106141. /**
  106142. * Execute next task
  106143. */
  106144. executeNext(): void;
  106145. /**
  106146. * Execute a simplification task
  106147. * @param task defines the task to run
  106148. */
  106149. runSimplification(task: ISimplificationTask): void;
  106150. private getSimplifier;
  106151. }
  106152. /**
  106153. * The implemented types of simplification
  106154. * At the moment only Quadratic Error Decimation is implemented
  106155. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106156. */
  106157. export enum SimplificationType {
  106158. /** Quadratic error decimation */
  106159. QUADRATIC = 0
  106160. }
  106161. }
  106162. declare module BABYLON {
  106163. interface Scene {
  106164. /** @hidden (Backing field) */
  106165. _simplificationQueue: SimplificationQueue;
  106166. /**
  106167. * Gets or sets the simplification queue attached to the scene
  106168. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106169. */
  106170. simplificationQueue: SimplificationQueue;
  106171. }
  106172. interface Mesh {
  106173. /**
  106174. * Simplify the mesh according to the given array of settings.
  106175. * Function will return immediately and will simplify async
  106176. * @param settings a collection of simplification settings
  106177. * @param parallelProcessing should all levels calculate parallel or one after the other
  106178. * @param simplificationType the type of simplification to run
  106179. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  106180. * @returns the current mesh
  106181. */
  106182. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  106183. }
  106184. /**
  106185. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  106186. * created in a scene
  106187. */
  106188. export class SimplicationQueueSceneComponent implements ISceneComponent {
  106189. /**
  106190. * The component name helpfull to identify the component in the list of scene components.
  106191. */
  106192. readonly name: string;
  106193. /**
  106194. * The scene the component belongs to.
  106195. */
  106196. scene: Scene;
  106197. /**
  106198. * Creates a new instance of the component for the given scene
  106199. * @param scene Defines the scene to register the component in
  106200. */
  106201. constructor(scene: Scene);
  106202. /**
  106203. * Registers the component in a given scene
  106204. */
  106205. register(): void;
  106206. /**
  106207. * Rebuilds the elements related to this component in case of
  106208. * context lost for instance.
  106209. */
  106210. rebuild(): void;
  106211. /**
  106212. * Disposes the component and the associated ressources
  106213. */
  106214. dispose(): void;
  106215. private _beforeCameraUpdate;
  106216. }
  106217. }
  106218. declare module BABYLON {
  106219. /**
  106220. * Class used to enable access to IndexedDB
  106221. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106222. */
  106223. export class Database implements IOfflineProvider {
  106224. private _callbackManifestChecked;
  106225. private _currentSceneUrl;
  106226. private _db;
  106227. private _enableSceneOffline;
  106228. private _enableTexturesOffline;
  106229. private _manifestVersionFound;
  106230. private _mustUpdateRessources;
  106231. private _hasReachedQuota;
  106232. private _isSupported;
  106233. private _idbFactory;
  106234. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106235. private static IsUASupportingBlobStorage;
  106236. /**
  106237. * Gets a boolean indicating if Database storate is enabled (off by default)
  106238. */
  106239. static IDBStorageEnabled: boolean;
  106240. /**
  106241. * Gets a boolean indicating if scene must be saved in the database
  106242. */
  106243. readonly enableSceneOffline: boolean;
  106244. /**
  106245. * Gets a boolean indicating if textures must be saved in the database
  106246. */
  106247. readonly enableTexturesOffline: boolean;
  106248. /**
  106249. * Creates a new Database
  106250. * @param urlToScene defines the url to load the scene
  106251. * @param callbackManifestChecked defines the callback to use when manifest is checked
  106252. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  106253. */
  106254. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  106255. private static _ParseURL;
  106256. private static _ReturnFullUrlLocation;
  106257. private _checkManifestFile;
  106258. /**
  106259. * Open the database and make it available
  106260. * @param successCallback defines the callback to call on success
  106261. * @param errorCallback defines the callback to call on error
  106262. */
  106263. open(successCallback: () => void, errorCallback: () => void): void;
  106264. /**
  106265. * Loads an image from the database
  106266. * @param url defines the url to load from
  106267. * @param image defines the target DOM image
  106268. */
  106269. loadImage(url: string, image: HTMLImageElement): void;
  106270. private _loadImageFromDBAsync;
  106271. private _saveImageIntoDBAsync;
  106272. private _checkVersionFromDB;
  106273. private _loadVersionFromDBAsync;
  106274. private _saveVersionIntoDBAsync;
  106275. /**
  106276. * Loads a file from database
  106277. * @param url defines the URL to load from
  106278. * @param sceneLoaded defines a callback to call on success
  106279. * @param progressCallBack defines a callback to call when progress changed
  106280. * @param errorCallback defines a callback to call on error
  106281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106282. */
  106283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  106284. private _loadFileAsync;
  106285. private _saveFileAsync;
  106286. /**
  106287. * Validates if xhr data is correct
  106288. * @param xhr defines the request to validate
  106289. * @param dataType defines the expected data type
  106290. * @returns true if data is correct
  106291. */
  106292. private static _ValidateXHRData;
  106293. }
  106294. }
  106295. declare module BABYLON {
  106296. /** @hidden */
  106297. export var gpuUpdateParticlesPixelShader: {
  106298. name: string;
  106299. shader: string;
  106300. };
  106301. }
  106302. declare module BABYLON {
  106303. /** @hidden */
  106304. export var gpuUpdateParticlesVertexShader: {
  106305. name: string;
  106306. shader: string;
  106307. };
  106308. }
  106309. declare module BABYLON {
  106310. /** @hidden */
  106311. export var clipPlaneFragmentDeclaration2: {
  106312. name: string;
  106313. shader: string;
  106314. };
  106315. }
  106316. declare module BABYLON {
  106317. /** @hidden */
  106318. export var gpuRenderParticlesPixelShader: {
  106319. name: string;
  106320. shader: string;
  106321. };
  106322. }
  106323. declare module BABYLON {
  106324. /** @hidden */
  106325. export var clipPlaneVertexDeclaration2: {
  106326. name: string;
  106327. shader: string;
  106328. };
  106329. }
  106330. declare module BABYLON {
  106331. /** @hidden */
  106332. export var gpuRenderParticlesVertexShader: {
  106333. name: string;
  106334. shader: string;
  106335. };
  106336. }
  106337. declare module BABYLON {
  106338. /**
  106339. * This represents a GPU particle system in Babylon
  106340. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  106341. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  106342. */
  106343. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  106344. /**
  106345. * The layer mask we are rendering the particles through.
  106346. */
  106347. layerMask: number;
  106348. private _capacity;
  106349. private _activeCount;
  106350. private _currentActiveCount;
  106351. private _accumulatedCount;
  106352. private _renderEffect;
  106353. private _updateEffect;
  106354. private _buffer0;
  106355. private _buffer1;
  106356. private _spriteBuffer;
  106357. private _updateVAO;
  106358. private _renderVAO;
  106359. private _targetIndex;
  106360. private _sourceBuffer;
  106361. private _targetBuffer;
  106362. private _engine;
  106363. private _currentRenderId;
  106364. private _started;
  106365. private _stopped;
  106366. private _timeDelta;
  106367. private _randomTexture;
  106368. private _randomTexture2;
  106369. private _attributesStrideSize;
  106370. private _updateEffectOptions;
  106371. private _randomTextureSize;
  106372. private _actualFrame;
  106373. private readonly _rawTextureWidth;
  106374. /**
  106375. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  106376. */
  106377. static readonly IsSupported: boolean;
  106378. /**
  106379. * An event triggered when the system is disposed.
  106380. */
  106381. onDisposeObservable: Observable<GPUParticleSystem>;
  106382. /**
  106383. * Gets the maximum number of particles active at the same time.
  106384. * @returns The max number of active particles.
  106385. */
  106386. getCapacity(): number;
  106387. /**
  106388. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106389. * to override the particles.
  106390. */
  106391. forceDepthWrite: boolean;
  106392. /**
  106393. * Gets or set the number of active particles
  106394. */
  106395. activeParticleCount: number;
  106396. private _preWarmDone;
  106397. /**
  106398. * Is this system ready to be used/rendered
  106399. * @return true if the system is ready
  106400. */
  106401. isReady(): boolean;
  106402. /**
  106403. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106404. * @returns True if it has been started, otherwise false.
  106405. */
  106406. isStarted(): boolean;
  106407. /**
  106408. * Starts the particle system and begins to emit
  106409. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106410. */
  106411. start(delay?: number): void;
  106412. /**
  106413. * Stops the particle system.
  106414. */
  106415. stop(): void;
  106416. /**
  106417. * Remove all active particles
  106418. */
  106419. reset(): void;
  106420. /**
  106421. * Returns the string "GPUParticleSystem"
  106422. * @returns a string containing the class name
  106423. */
  106424. getClassName(): string;
  106425. private _colorGradientsTexture;
  106426. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  106427. /**
  106428. * Adds a new color gradient
  106429. * @param gradient defines the gradient to use (between 0 and 1)
  106430. * @param color1 defines the color to affect to the specified gradient
  106431. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  106432. * @returns the current particle system
  106433. */
  106434. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  106435. /**
  106436. * Remove a specific color gradient
  106437. * @param gradient defines the gradient to remove
  106438. * @returns the current particle system
  106439. */
  106440. removeColorGradient(gradient: number): GPUParticleSystem;
  106441. private _angularSpeedGradientsTexture;
  106442. private _sizeGradientsTexture;
  106443. private _velocityGradientsTexture;
  106444. private _limitVelocityGradientsTexture;
  106445. private _dragGradientsTexture;
  106446. private _addFactorGradient;
  106447. /**
  106448. * Adds a new size gradient
  106449. * @param gradient defines the gradient to use (between 0 and 1)
  106450. * @param factor defines the size factor to affect to the specified gradient
  106451. * @returns the current particle system
  106452. */
  106453. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  106454. /**
  106455. * Remove a specific size gradient
  106456. * @param gradient defines the gradient to remove
  106457. * @returns the current particle system
  106458. */
  106459. removeSizeGradient(gradient: number): GPUParticleSystem;
  106460. /**
  106461. * Adds a new angular speed gradient
  106462. * @param gradient defines the gradient to use (between 0 and 1)
  106463. * @param factor defines the angular speed to affect to the specified gradient
  106464. * @returns the current particle system
  106465. */
  106466. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  106467. /**
  106468. * Remove a specific angular speed gradient
  106469. * @param gradient defines the gradient to remove
  106470. * @returns the current particle system
  106471. */
  106472. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  106473. /**
  106474. * Adds a new velocity gradient
  106475. * @param gradient defines the gradient to use (between 0 and 1)
  106476. * @param factor defines the velocity to affect to the specified gradient
  106477. * @returns the current particle system
  106478. */
  106479. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106480. /**
  106481. * Remove a specific velocity gradient
  106482. * @param gradient defines the gradient to remove
  106483. * @returns the current particle system
  106484. */
  106485. removeVelocityGradient(gradient: number): GPUParticleSystem;
  106486. /**
  106487. * Adds a new limit velocity gradient
  106488. * @param gradient defines the gradient to use (between 0 and 1)
  106489. * @param factor defines the limit velocity value to affect to the specified gradient
  106490. * @returns the current particle system
  106491. */
  106492. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106493. /**
  106494. * Remove a specific limit velocity gradient
  106495. * @param gradient defines the gradient to remove
  106496. * @returns the current particle system
  106497. */
  106498. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  106499. /**
  106500. * Adds a new drag gradient
  106501. * @param gradient defines the gradient to use (between 0 and 1)
  106502. * @param factor defines the drag value to affect to the specified gradient
  106503. * @returns the current particle system
  106504. */
  106505. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  106506. /**
  106507. * Remove a specific drag gradient
  106508. * @param gradient defines the gradient to remove
  106509. * @returns the current particle system
  106510. */
  106511. removeDragGradient(gradient: number): GPUParticleSystem;
  106512. /**
  106513. * Not supported by GPUParticleSystem
  106514. * @param gradient defines the gradient to use (between 0 and 1)
  106515. * @param factor defines the emit rate value to affect to the specified gradient
  106516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106517. * @returns the current particle system
  106518. */
  106519. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106520. /**
  106521. * Not supported by GPUParticleSystem
  106522. * @param gradient defines the gradient to remove
  106523. * @returns the current particle system
  106524. */
  106525. removeEmitRateGradient(gradient: number): IParticleSystem;
  106526. /**
  106527. * Not supported by GPUParticleSystem
  106528. * @param gradient defines the gradient to use (between 0 and 1)
  106529. * @param factor defines the start size value to affect to the specified gradient
  106530. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106531. * @returns the current particle system
  106532. */
  106533. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106534. /**
  106535. * Not supported by GPUParticleSystem
  106536. * @param gradient defines the gradient to remove
  106537. * @returns the current particle system
  106538. */
  106539. removeStartSizeGradient(gradient: number): IParticleSystem;
  106540. /**
  106541. * Not supported by GPUParticleSystem
  106542. * @param gradient defines the gradient to use (between 0 and 1)
  106543. * @param min defines the color remap minimal range
  106544. * @param max defines the color remap maximal range
  106545. * @returns the current particle system
  106546. */
  106547. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  106548. /**
  106549. * Not supported by GPUParticleSystem
  106550. * @param gradient defines the gradient to remove
  106551. * @returns the current particle system
  106552. */
  106553. removeColorRemapGradient(): IParticleSystem;
  106554. /**
  106555. * Not supported by GPUParticleSystem
  106556. * @param gradient defines the gradient to use (between 0 and 1)
  106557. * @param min defines the alpha remap minimal range
  106558. * @param max defines the alpha remap maximal range
  106559. * @returns the current particle system
  106560. */
  106561. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  106562. /**
  106563. * Not supported by GPUParticleSystem
  106564. * @param gradient defines the gradient to remove
  106565. * @returns the current particle system
  106566. */
  106567. removeAlphaRemapGradient(): IParticleSystem;
  106568. /**
  106569. * Not supported by GPUParticleSystem
  106570. * @param gradient defines the gradient to use (between 0 and 1)
  106571. * @param color defines the color to affect to the specified gradient
  106572. * @returns the current particle system
  106573. */
  106574. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  106575. /**
  106576. * Not supported by GPUParticleSystem
  106577. * @param gradient defines the gradient to remove
  106578. * @returns the current particle system
  106579. */
  106580. removeRampGradient(): IParticleSystem;
  106581. /**
  106582. * Not supported by GPUParticleSystem
  106583. * @returns the list of ramp gradients
  106584. */
  106585. getRampGradients(): Nullable<Array<Color3Gradient>>;
  106586. /**
  106587. * Not supported by GPUParticleSystem
  106588. * Gets or sets a boolean indicating that ramp gradients must be used
  106589. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  106590. */
  106591. useRampGradients: boolean;
  106592. /**
  106593. * Not supported by GPUParticleSystem
  106594. * @param gradient defines the gradient to use (between 0 and 1)
  106595. * @param factor defines the life time factor to affect to the specified gradient
  106596. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106597. * @returns the current particle system
  106598. */
  106599. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106600. /**
  106601. * Not supported by GPUParticleSystem
  106602. * @param gradient defines the gradient to remove
  106603. * @returns the current particle system
  106604. */
  106605. removeLifeTimeGradient(gradient: number): IParticleSystem;
  106606. /**
  106607. * Instantiates a GPU particle system.
  106608. * 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.
  106609. * @param name The name of the particle system
  106610. * @param options The options used to create the system
  106611. * @param scene The scene the particle system belongs to
  106612. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  106613. */
  106614. constructor(name: string, options: Partial<{
  106615. capacity: number;
  106616. randomTextureSize: number;
  106617. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  106618. protected _reset(): void;
  106619. private _createUpdateVAO;
  106620. private _createRenderVAO;
  106621. private _initialize;
  106622. /** @hidden */
  106623. _recreateUpdateEffect(): void;
  106624. /** @hidden */
  106625. _recreateRenderEffect(): void;
  106626. /**
  106627. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  106628. * @param preWarm defines if we are in the pre-warmimg phase
  106629. */
  106630. animate(preWarm?: boolean): void;
  106631. private _createFactorGradientTexture;
  106632. private _createSizeGradientTexture;
  106633. private _createAngularSpeedGradientTexture;
  106634. private _createVelocityGradientTexture;
  106635. private _createLimitVelocityGradientTexture;
  106636. private _createDragGradientTexture;
  106637. private _createColorGradientTexture;
  106638. /**
  106639. * Renders the particle system in its current state
  106640. * @param preWarm defines if the system should only update the particles but not render them
  106641. * @returns the current number of particles
  106642. */
  106643. render(preWarm?: boolean): number;
  106644. /**
  106645. * Rebuilds the particle system
  106646. */
  106647. rebuild(): void;
  106648. private _releaseBuffers;
  106649. private _releaseVAOs;
  106650. /**
  106651. * Disposes the particle system and free the associated resources
  106652. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  106653. */
  106654. dispose(disposeTexture?: boolean): void;
  106655. /**
  106656. * Clones the particle system.
  106657. * @param name The name of the cloned object
  106658. * @param newEmitter The new emitter to use
  106659. * @returns the cloned particle system
  106660. */
  106661. clone(name: string, newEmitter: any): GPUParticleSystem;
  106662. /**
  106663. * Serializes the particle system to a JSON object.
  106664. * @returns the JSON object
  106665. */
  106666. serialize(): any;
  106667. /**
  106668. * Parses a JSON object to create a GPU particle system.
  106669. * @param parsedParticleSystem The JSON object to parse
  106670. * @param scene The scene to create the particle system in
  106671. * @param rootUrl The root url to use to load external dependencies like texture
  106672. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  106673. * @returns the parsed GPU particle system
  106674. */
  106675. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  106676. }
  106677. }
  106678. declare module BABYLON {
  106679. /**
  106680. * Represents a set of particle systems working together to create a specific effect
  106681. */
  106682. export class ParticleSystemSet implements IDisposable {
  106683. private _emitterCreationOptions;
  106684. private _emitterNode;
  106685. /**
  106686. * Gets the particle system list
  106687. */
  106688. systems: IParticleSystem[];
  106689. /**
  106690. * Gets the emitter node used with this set
  106691. */
  106692. readonly emitterNode: Nullable<TransformNode>;
  106693. /**
  106694. * Creates a new emitter mesh as a sphere
  106695. * @param options defines the options used to create the sphere
  106696. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  106697. * @param scene defines the hosting scene
  106698. */
  106699. setEmitterAsSphere(options: {
  106700. diameter: number;
  106701. segments: number;
  106702. color: Color3;
  106703. }, renderingGroupId: number, scene: Scene): void;
  106704. /**
  106705. * Starts all particle systems of the set
  106706. * @param emitter defines an optional mesh to use as emitter for the particle systems
  106707. */
  106708. start(emitter?: AbstractMesh): void;
  106709. /**
  106710. * Release all associated resources
  106711. */
  106712. dispose(): void;
  106713. /**
  106714. * Serialize the set into a JSON compatible object
  106715. * @returns a JSON compatible representation of the set
  106716. */
  106717. serialize(): any;
  106718. /**
  106719. * Parse a new ParticleSystemSet from a serialized source
  106720. * @param data defines a JSON compatible representation of the set
  106721. * @param scene defines the hosting scene
  106722. * @param gpu defines if we want GPU particles or CPU particles
  106723. * @returns a new ParticleSystemSet
  106724. */
  106725. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  106726. }
  106727. }
  106728. declare module BABYLON {
  106729. /**
  106730. * This class is made for on one-liner static method to help creating particle system set.
  106731. */
  106732. export class ParticleHelper {
  106733. /**
  106734. * Gets or sets base Assets URL
  106735. */
  106736. static BaseAssetsUrl: string;
  106737. /**
  106738. * Create a default particle system that you can tweak
  106739. * @param emitter defines the emitter to use
  106740. * @param capacity defines the system capacity (default is 500 particles)
  106741. * @param scene defines the hosting scene
  106742. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  106743. * @returns the new Particle system
  106744. */
  106745. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  106746. /**
  106747. * This is the main static method (one-liner) of this helper to create different particle systems
  106748. * @param type This string represents the type to the particle system to create
  106749. * @param scene The scene where the particle system should live
  106750. * @param gpu If the system will use gpu
  106751. * @returns the ParticleSystemSet created
  106752. */
  106753. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  106754. /**
  106755. * Static function used to export a particle system to a ParticleSystemSet variable.
  106756. * Please note that the emitter shape is not exported
  106757. * @param systems defines the particle systems to export
  106758. * @returns the created particle system set
  106759. */
  106760. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  106761. }
  106762. }
  106763. declare module BABYLON {
  106764. interface Engine {
  106765. /**
  106766. * Create an effect to use with particle systems.
  106767. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  106768. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  106769. * @param uniformsNames defines a list of attribute names
  106770. * @param samplers defines an array of string used to represent textures
  106771. * @param defines defines the string containing the defines to use to compile the shaders
  106772. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  106773. * @param onCompiled defines a function to call when the effect creation is successful
  106774. * @param onError defines a function to call when the effect creation has failed
  106775. * @returns the new Effect
  106776. */
  106777. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  106778. }
  106779. interface Mesh {
  106780. /**
  106781. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  106782. * @returns an array of IParticleSystem
  106783. */
  106784. getEmittedParticleSystems(): IParticleSystem[];
  106785. /**
  106786. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  106787. * @returns an array of IParticleSystem
  106788. */
  106789. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  106790. }
  106791. /**
  106792. * @hidden
  106793. */
  106794. export var _IDoNeedToBeInTheBuild: number;
  106795. }
  106796. declare module BABYLON {
  106797. interface Scene {
  106798. /** @hidden (Backing field) */
  106799. _physicsEngine: Nullable<IPhysicsEngine>;
  106800. /**
  106801. * Gets the current physics engine
  106802. * @returns a IPhysicsEngine or null if none attached
  106803. */
  106804. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  106805. /**
  106806. * Enables physics to the current scene
  106807. * @param gravity defines the scene's gravity for the physics engine
  106808. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  106809. * @return a boolean indicating if the physics engine was initialized
  106810. */
  106811. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  106812. /**
  106813. * Disables and disposes the physics engine associated with the scene
  106814. */
  106815. disablePhysicsEngine(): void;
  106816. /**
  106817. * Gets a boolean indicating if there is an active physics engine
  106818. * @returns a boolean indicating if there is an active physics engine
  106819. */
  106820. isPhysicsEnabled(): boolean;
  106821. /**
  106822. * Deletes a physics compound impostor
  106823. * @param compound defines the compound to delete
  106824. */
  106825. deleteCompoundImpostor(compound: any): void;
  106826. /**
  106827. * An event triggered when physic simulation is about to be run
  106828. */
  106829. onBeforePhysicsObservable: Observable<Scene>;
  106830. /**
  106831. * An event triggered when physic simulation has been done
  106832. */
  106833. onAfterPhysicsObservable: Observable<Scene>;
  106834. }
  106835. interface AbstractMesh {
  106836. /** @hidden */
  106837. _physicsImpostor: Nullable<PhysicsImpostor>;
  106838. /**
  106839. * Gets or sets impostor used for physic simulation
  106840. * @see http://doc.babylonjs.com/features/physics_engine
  106841. */
  106842. physicsImpostor: Nullable<PhysicsImpostor>;
  106843. /**
  106844. * Gets the current physics impostor
  106845. * @see http://doc.babylonjs.com/features/physics_engine
  106846. * @returns a physics impostor or null
  106847. */
  106848. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  106849. /** Apply a physic impulse to the mesh
  106850. * @param force defines the force to apply
  106851. * @param contactPoint defines where to apply the force
  106852. * @returns the current mesh
  106853. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  106854. */
  106855. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  106856. /**
  106857. * Creates a physic joint between two meshes
  106858. * @param otherMesh defines the other mesh to use
  106859. * @param pivot1 defines the pivot to use on this mesh
  106860. * @param pivot2 defines the pivot to use on the other mesh
  106861. * @param options defines additional options (can be plugin dependent)
  106862. * @returns the current mesh
  106863. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  106864. */
  106865. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  106866. /** @hidden */
  106867. _disposePhysicsObserver: Nullable<Observer<Node>>;
  106868. }
  106869. /**
  106870. * Defines the physics engine scene component responsible to manage a physics engine
  106871. */
  106872. export class PhysicsEngineSceneComponent implements ISceneComponent {
  106873. /**
  106874. * The component name helpful to identify the component in the list of scene components.
  106875. */
  106876. readonly name: string;
  106877. /**
  106878. * The scene the component belongs to.
  106879. */
  106880. scene: Scene;
  106881. /**
  106882. * Creates a new instance of the component for the given scene
  106883. * @param scene Defines the scene to register the component in
  106884. */
  106885. constructor(scene: Scene);
  106886. /**
  106887. * Registers the component in a given scene
  106888. */
  106889. register(): void;
  106890. /**
  106891. * Rebuilds the elements related to this component in case of
  106892. * context lost for instance.
  106893. */
  106894. rebuild(): void;
  106895. /**
  106896. * Disposes the component and the associated ressources
  106897. */
  106898. dispose(): void;
  106899. }
  106900. }
  106901. declare module BABYLON {
  106902. /**
  106903. * A helper for physics simulations
  106904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106905. */
  106906. export class PhysicsHelper {
  106907. private _scene;
  106908. private _physicsEngine;
  106909. /**
  106910. * Initializes the Physics helper
  106911. * @param scene Babylon.js scene
  106912. */
  106913. constructor(scene: Scene);
  106914. /**
  106915. * Applies a radial explosion impulse
  106916. * @param origin the origin of the explosion
  106917. * @param radius the explosion radius
  106918. * @param strength the explosion strength
  106919. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106920. * @returns A physics radial explosion event, or null
  106921. */
  106922. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106923. /**
  106924. * Applies a radial explosion force
  106925. * @param origin the origin of the explosion
  106926. * @param radius the explosion radius
  106927. * @param strength the explosion strength
  106928. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106929. * @returns A physics radial explosion event, or null
  106930. */
  106931. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106932. /**
  106933. * Creates a gravitational field
  106934. * @param origin the origin of the explosion
  106935. * @param radius the explosion radius
  106936. * @param strength the explosion strength
  106937. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106938. * @returns A physics gravitational field event, or null
  106939. */
  106940. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  106941. /**
  106942. * Creates a physics updraft event
  106943. * @param origin the origin of the updraft
  106944. * @param radius the radius of the updraft
  106945. * @param strength the strength of the updraft
  106946. * @param height the height of the updraft
  106947. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  106948. * @returns A physics updraft event, or null
  106949. */
  106950. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  106951. /**
  106952. * Creates a physics vortex event
  106953. * @param origin the of the vortex
  106954. * @param radius the radius of the vortex
  106955. * @param strength the strength of the vortex
  106956. * @param height the height of the vortex
  106957. * @returns a Physics vortex event, or null
  106958. * A physics vortex event or null
  106959. */
  106960. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  106961. }
  106962. /**
  106963. * Represents a physics radial explosion event
  106964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106965. */
  106966. export class PhysicsRadialExplosionEvent {
  106967. private _scene;
  106968. private _sphere;
  106969. private _sphereOptions;
  106970. private _rays;
  106971. private _dataFetched;
  106972. /**
  106973. * Initializes a radial explosioin event
  106974. * @param scene BabylonJS scene
  106975. */
  106976. constructor(scene: Scene);
  106977. /**
  106978. * Returns the data related to the radial explosion event (sphere & rays).
  106979. * @returns The radial explosion event data
  106980. */
  106981. getData(): PhysicsRadialExplosionEventData;
  106982. /**
  106983. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  106984. * @param impostor A physics imposter
  106985. * @param origin the origin of the explosion
  106986. * @param radius the explosion radius
  106987. * @param strength the explosion strength
  106988. * @param falloff possible options: Constant & Linear
  106989. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  106990. */
  106991. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  106992. /**
  106993. * Disposes the sphere.
  106994. * @param force Specifies if the sphere should be disposed by force
  106995. */
  106996. dispose(force?: boolean): void;
  106997. /*** Helpers ***/
  106998. private _prepareSphere;
  106999. private _intersectsWithSphere;
  107000. }
  107001. /**
  107002. * Represents a gravitational field event
  107003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107004. */
  107005. export class PhysicsGravitationalFieldEvent {
  107006. private _physicsHelper;
  107007. private _scene;
  107008. private _origin;
  107009. private _radius;
  107010. private _strength;
  107011. private _falloff;
  107012. private _tickCallback;
  107013. private _sphere;
  107014. private _dataFetched;
  107015. /**
  107016. * Initializes the physics gravitational field event
  107017. * @param physicsHelper A physics helper
  107018. * @param scene BabylonJS scene
  107019. * @param origin The origin position of the gravitational field event
  107020. * @param radius The radius of the gravitational field event
  107021. * @param strength The strength of the gravitational field event
  107022. * @param falloff The falloff for the gravitational field event
  107023. */
  107024. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  107025. /**
  107026. * Returns the data related to the gravitational field event (sphere).
  107027. * @returns A gravitational field event
  107028. */
  107029. getData(): PhysicsGravitationalFieldEventData;
  107030. /**
  107031. * Enables the gravitational field.
  107032. */
  107033. enable(): void;
  107034. /**
  107035. * Disables the gravitational field.
  107036. */
  107037. disable(): void;
  107038. /**
  107039. * Disposes the sphere.
  107040. * @param force The force to dispose from the gravitational field event
  107041. */
  107042. dispose(force?: boolean): void;
  107043. private _tick;
  107044. }
  107045. /**
  107046. * Represents a physics updraft event
  107047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107048. */
  107049. export class PhysicsUpdraftEvent {
  107050. private _scene;
  107051. private _origin;
  107052. private _radius;
  107053. private _strength;
  107054. private _height;
  107055. private _updraftMode;
  107056. private _physicsEngine;
  107057. private _originTop;
  107058. private _originDirection;
  107059. private _tickCallback;
  107060. private _cylinder;
  107061. private _cylinderPosition;
  107062. private _dataFetched;
  107063. /**
  107064. * Initializes the physics updraft event
  107065. * @param _scene BabylonJS scene
  107066. * @param _origin The origin position of the updraft
  107067. * @param _radius The radius of the updraft
  107068. * @param _strength The strength of the updraft
  107069. * @param _height The height of the updraft
  107070. * @param _updraftMode The mode of the updraft
  107071. */
  107072. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  107073. /**
  107074. * Returns the data related to the updraft event (cylinder).
  107075. * @returns A physics updraft event
  107076. */
  107077. getData(): PhysicsUpdraftEventData;
  107078. /**
  107079. * Enables the updraft.
  107080. */
  107081. enable(): void;
  107082. /**
  107083. * Disables the cortex.
  107084. */
  107085. disable(): void;
  107086. /**
  107087. * Disposes the sphere.
  107088. * @param force Specifies if the updraft should be disposed by force
  107089. */
  107090. dispose(force?: boolean): void;
  107091. private getImpostorForceAndContactPoint;
  107092. private _tick;
  107093. /*** Helpers ***/
  107094. private _prepareCylinder;
  107095. private _intersectsWithCylinder;
  107096. }
  107097. /**
  107098. * Represents a physics vortex event
  107099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107100. */
  107101. export class PhysicsVortexEvent {
  107102. private _scene;
  107103. private _origin;
  107104. private _radius;
  107105. private _strength;
  107106. private _height;
  107107. private _physicsEngine;
  107108. private _originTop;
  107109. private _centripetalForceThreshold;
  107110. private _updraftMultiplier;
  107111. private _tickCallback;
  107112. private _cylinder;
  107113. private _cylinderPosition;
  107114. private _dataFetched;
  107115. /**
  107116. * Initializes the physics vortex event
  107117. * @param _scene The BabylonJS scene
  107118. * @param _origin The origin position of the vortex
  107119. * @param _radius The radius of the vortex
  107120. * @param _strength The strength of the vortex
  107121. * @param _height The height of the vortex
  107122. */
  107123. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  107124. /**
  107125. * Returns the data related to the vortex event (cylinder).
  107126. * @returns The physics vortex event data
  107127. */
  107128. getData(): PhysicsVortexEventData;
  107129. /**
  107130. * Enables the vortex.
  107131. */
  107132. enable(): void;
  107133. /**
  107134. * Disables the cortex.
  107135. */
  107136. disable(): void;
  107137. /**
  107138. * Disposes the sphere.
  107139. * @param force
  107140. */
  107141. dispose(force?: boolean): void;
  107142. private getImpostorForceAndContactPoint;
  107143. private _tick;
  107144. /*** Helpers ***/
  107145. private _prepareCylinder;
  107146. private _intersectsWithCylinder;
  107147. }
  107148. /**
  107149. * The strenght of the force in correspondence to the distance of the affected object
  107150. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107151. */
  107152. export enum PhysicsRadialImpulseFalloff {
  107153. /** Defines that impulse is constant in strength across it's whole radius */
  107154. Constant = 0,
  107155. /** DEfines that impulse gets weaker if it's further from the origin */
  107156. Linear = 1
  107157. }
  107158. /**
  107159. * The strength of the force in correspondence to the distance of the affected object
  107160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107161. */
  107162. export enum PhysicsUpdraftMode {
  107163. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  107164. Center = 0,
  107165. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  107166. Perpendicular = 1
  107167. }
  107168. /**
  107169. * Interface for a physics force and contact point
  107170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107171. */
  107172. export interface PhysicsForceAndContactPoint {
  107173. /**
  107174. * The force applied at the contact point
  107175. */
  107176. force: Vector3;
  107177. /**
  107178. * The contact point
  107179. */
  107180. contactPoint: Vector3;
  107181. }
  107182. /**
  107183. * Interface for radial explosion event data
  107184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107185. */
  107186. export interface PhysicsRadialExplosionEventData {
  107187. /**
  107188. * A sphere used for the radial explosion event
  107189. */
  107190. sphere: Mesh;
  107191. /**
  107192. * An array of rays for the radial explosion event
  107193. */
  107194. rays: Array<Ray>;
  107195. }
  107196. /**
  107197. * Interface for gravitational field event data
  107198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107199. */
  107200. export interface PhysicsGravitationalFieldEventData {
  107201. /**
  107202. * A sphere mesh used for the gravitational field event
  107203. */
  107204. sphere: Mesh;
  107205. }
  107206. /**
  107207. * Interface for updraft event data
  107208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107209. */
  107210. export interface PhysicsUpdraftEventData {
  107211. /**
  107212. * A cylinder used for the updraft event
  107213. */
  107214. cylinder: Mesh;
  107215. }
  107216. /**
  107217. * Interface for vortex event data
  107218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107219. */
  107220. export interface PhysicsVortexEventData {
  107221. /**
  107222. * A cylinder used for the vortex event
  107223. */
  107224. cylinder: Mesh;
  107225. }
  107226. }
  107227. declare module BABYLON {
  107228. /**
  107229. * AmmoJS Physics plugin
  107230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107231. * @see https://github.com/kripken/ammo.js/
  107232. */
  107233. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107234. private _useDeltaForWorldStep;
  107235. /**
  107236. * Reference to the Ammo library
  107237. */
  107238. bjsAMMO: any;
  107239. /**
  107240. * Created ammoJS world which physics bodies are added to
  107241. */
  107242. world: any;
  107243. /**
  107244. * Name of the plugin
  107245. */
  107246. name: string;
  107247. private _timeStep;
  107248. private _fixedTimeStep;
  107249. private _maxSteps;
  107250. private _tmpQuaternion;
  107251. private _tmpAmmoTransform;
  107252. private _tmpAmmoQuaternion;
  107253. private _tmpAmmoConcreteContactResultCallback;
  107254. private _collisionConfiguration;
  107255. private _dispatcher;
  107256. private _overlappingPairCache;
  107257. private _solver;
  107258. private _tmpAmmoVectorA;
  107259. private _tmpAmmoVectorB;
  107260. private _tmpAmmoVectorC;
  107261. private _tmpContactCallbackResult;
  107262. private static readonly DISABLE_COLLISION_FLAG;
  107263. private static readonly KINEMATIC_FLAG;
  107264. private static readonly DISABLE_DEACTIVATION_FLAG;
  107265. /**
  107266. * Initializes the ammoJS plugin
  107267. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107268. * @param ammoInjection can be used to inject your own ammo reference
  107269. */
  107270. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107271. /**
  107272. * Sets the gravity of the physics world (m/(s^2))
  107273. * @param gravity Gravity to set
  107274. */
  107275. setGravity(gravity: Vector3): void;
  107276. /**
  107277. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107278. * @param timeStep timestep to use in seconds
  107279. */
  107280. setTimeStep(timeStep: number): void;
  107281. /**
  107282. * 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)
  107283. * @param fixedTimeStep fixedTimeStep to use in seconds
  107284. */
  107285. setFixedTimeStep(fixedTimeStep: number): void;
  107286. /**
  107287. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107288. * @param maxSteps the maximum number of steps by the physics engine per frame
  107289. */
  107290. setMaxSteps(maxSteps: number): void;
  107291. /**
  107292. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107293. * @returns the current timestep in seconds
  107294. */
  107295. getTimeStep(): number;
  107296. private _isImpostorInContact;
  107297. private _isImpostorPairInContact;
  107298. private _stepSimulation;
  107299. /**
  107300. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107301. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107302. * After the step the babylon meshes are set to the position of the physics imposters
  107303. * @param delta amount of time to step forward
  107304. * @param impostors array of imposters to update before/after the step
  107305. */
  107306. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107307. private _tmpVector;
  107308. private _tmpMatrix;
  107309. /**
  107310. * Applies an implulse on the imposter
  107311. * @param impostor imposter to apply impulse
  107312. * @param force amount of force to be applied to the imposter
  107313. * @param contactPoint the location to apply the impulse on the imposter
  107314. */
  107315. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107316. /**
  107317. * Applies a force on the imposter
  107318. * @param impostor imposter to apply force
  107319. * @param force amount of force to be applied to the imposter
  107320. * @param contactPoint the location to apply the force on the imposter
  107321. */
  107322. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107323. /**
  107324. * Creates a physics body using the plugin
  107325. * @param impostor the imposter to create the physics body on
  107326. */
  107327. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107328. /**
  107329. * Removes the physics body from the imposter and disposes of the body's memory
  107330. * @param impostor imposter to remove the physics body from
  107331. */
  107332. removePhysicsBody(impostor: PhysicsImpostor): void;
  107333. /**
  107334. * Generates a joint
  107335. * @param impostorJoint the imposter joint to create the joint with
  107336. */
  107337. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107338. /**
  107339. * Removes a joint
  107340. * @param impostorJoint the imposter joint to remove the joint from
  107341. */
  107342. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107343. private _addMeshVerts;
  107344. private _createShape;
  107345. /**
  107346. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107347. * @param impostor imposter containing the physics body and babylon object
  107348. */
  107349. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107350. /**
  107351. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107352. * @param impostor imposter containing the physics body and babylon object
  107353. * @param newPosition new position
  107354. * @param newRotation new rotation
  107355. */
  107356. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107357. /**
  107358. * If this plugin is supported
  107359. * @returns true if its supported
  107360. */
  107361. isSupported(): boolean;
  107362. /**
  107363. * Sets the linear velocity of the physics body
  107364. * @param impostor imposter to set the velocity on
  107365. * @param velocity velocity to set
  107366. */
  107367. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107368. /**
  107369. * Sets the angular velocity of the physics body
  107370. * @param impostor imposter to set the velocity on
  107371. * @param velocity velocity to set
  107372. */
  107373. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107374. /**
  107375. * gets the linear velocity
  107376. * @param impostor imposter to get linear velocity from
  107377. * @returns linear velocity
  107378. */
  107379. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107380. /**
  107381. * gets the angular velocity
  107382. * @param impostor imposter to get angular velocity from
  107383. * @returns angular velocity
  107384. */
  107385. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107386. /**
  107387. * Sets the mass of physics body
  107388. * @param impostor imposter to set the mass on
  107389. * @param mass mass to set
  107390. */
  107391. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107392. /**
  107393. * Gets the mass of the physics body
  107394. * @param impostor imposter to get the mass from
  107395. * @returns mass
  107396. */
  107397. getBodyMass(impostor: PhysicsImpostor): number;
  107398. /**
  107399. * Gets friction of the impostor
  107400. * @param impostor impostor to get friction from
  107401. * @returns friction value
  107402. */
  107403. getBodyFriction(impostor: PhysicsImpostor): number;
  107404. /**
  107405. * Sets friction of the impostor
  107406. * @param impostor impostor to set friction on
  107407. * @param friction friction value
  107408. */
  107409. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107410. /**
  107411. * Gets restitution of the impostor
  107412. * @param impostor impostor to get restitution from
  107413. * @returns restitution value
  107414. */
  107415. getBodyRestitution(impostor: PhysicsImpostor): number;
  107416. /**
  107417. * Sets resitution of the impostor
  107418. * @param impostor impostor to set resitution on
  107419. * @param restitution resitution value
  107420. */
  107421. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107422. /**
  107423. * Sleeps the physics body and stops it from being active
  107424. * @param impostor impostor to sleep
  107425. */
  107426. sleepBody(impostor: PhysicsImpostor): void;
  107427. /**
  107428. * Activates the physics body
  107429. * @param impostor impostor to activate
  107430. */
  107431. wakeUpBody(impostor: PhysicsImpostor): void;
  107432. /**
  107433. * Updates the distance parameters of the joint
  107434. * @param joint joint to update
  107435. * @param maxDistance maximum distance of the joint
  107436. * @param minDistance minimum distance of the joint
  107437. */
  107438. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107439. /**
  107440. * Sets a motor on the joint
  107441. * @param joint joint to set motor on
  107442. * @param speed speed of the motor
  107443. * @param maxForce maximum force of the motor
  107444. * @param motorIndex index of the motor
  107445. */
  107446. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107447. /**
  107448. * Sets the motors limit
  107449. * @param joint joint to set limit on
  107450. * @param upperLimit upper limit
  107451. * @param lowerLimit lower limit
  107452. */
  107453. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107454. /**
  107455. * Syncs the position and rotation of a mesh with the impostor
  107456. * @param mesh mesh to sync
  107457. * @param impostor impostor to update the mesh with
  107458. */
  107459. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107460. /**
  107461. * Gets the radius of the impostor
  107462. * @param impostor impostor to get radius from
  107463. * @returns the radius
  107464. */
  107465. getRadius(impostor: PhysicsImpostor): number;
  107466. /**
  107467. * Gets the box size of the impostor
  107468. * @param impostor impostor to get box size from
  107469. * @param result the resulting box size
  107470. */
  107471. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107472. /**
  107473. * Disposes of the impostor
  107474. */
  107475. dispose(): void;
  107476. }
  107477. }
  107478. declare module BABYLON {
  107479. /** @hidden */
  107480. export var blackAndWhitePixelShader: {
  107481. name: string;
  107482. shader: string;
  107483. };
  107484. }
  107485. declare module BABYLON {
  107486. /**
  107487. * Post process used to render in black and white
  107488. */
  107489. export class BlackAndWhitePostProcess extends PostProcess {
  107490. /**
  107491. * Linear about to convert he result to black and white (default: 1)
  107492. */
  107493. degree: number;
  107494. /**
  107495. * Creates a black and white post process
  107496. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  107497. * @param name The name of the effect.
  107498. * @param options The required width/height ratio to downsize to before computing the render pass.
  107499. * @param camera The camera to apply the render pass to.
  107500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107501. * @param engine The engine which the post process will be applied. (default: current engine)
  107502. * @param reusable If the post process can be reused on the same frame. (default: false)
  107503. */
  107504. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107505. }
  107506. }
  107507. declare module BABYLON {
  107508. /**
  107509. * This represents a set of one or more post processes in Babylon.
  107510. * A post process can be used to apply a shader to a texture after it is rendered.
  107511. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107512. */
  107513. export class PostProcessRenderEffect {
  107514. private _postProcesses;
  107515. private _getPostProcesses;
  107516. private _singleInstance;
  107517. private _cameras;
  107518. private _indicesForCamera;
  107519. /**
  107520. * Name of the effect
  107521. * @hidden
  107522. */
  107523. _name: string;
  107524. /**
  107525. * Instantiates a post process render effect.
  107526. * A post process can be used to apply a shader to a texture after it is rendered.
  107527. * @param engine The engine the effect is tied to
  107528. * @param name The name of the effect
  107529. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  107530. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  107531. */
  107532. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  107533. /**
  107534. * Checks if all the post processes in the effect are supported.
  107535. */
  107536. readonly isSupported: boolean;
  107537. /**
  107538. * Updates the current state of the effect
  107539. * @hidden
  107540. */
  107541. _update(): void;
  107542. /**
  107543. * Attaches the effect on cameras
  107544. * @param cameras The camera to attach to.
  107545. * @hidden
  107546. */
  107547. _attachCameras(cameras: Camera): void;
  107548. /**
  107549. * Attaches the effect on cameras
  107550. * @param cameras The camera to attach to.
  107551. * @hidden
  107552. */
  107553. _attachCameras(cameras: Camera[]): void;
  107554. /**
  107555. * Detatches the effect on cameras
  107556. * @param cameras The camera to detatch from.
  107557. * @hidden
  107558. */
  107559. _detachCameras(cameras: Camera): void;
  107560. /**
  107561. * Detatches the effect on cameras
  107562. * @param cameras The camera to detatch from.
  107563. * @hidden
  107564. */
  107565. _detachCameras(cameras: Camera[]): void;
  107566. /**
  107567. * Enables the effect on given cameras
  107568. * @param cameras The camera to enable.
  107569. * @hidden
  107570. */
  107571. _enable(cameras: Camera): void;
  107572. /**
  107573. * Enables the effect on given cameras
  107574. * @param cameras The camera to enable.
  107575. * @hidden
  107576. */
  107577. _enable(cameras: Nullable<Camera[]>): void;
  107578. /**
  107579. * Disables the effect on the given cameras
  107580. * @param cameras The camera to disable.
  107581. * @hidden
  107582. */
  107583. _disable(cameras: Camera): void;
  107584. /**
  107585. * Disables the effect on the given cameras
  107586. * @param cameras The camera to disable.
  107587. * @hidden
  107588. */
  107589. _disable(cameras: Nullable<Camera[]>): void;
  107590. /**
  107591. * Gets a list of the post processes contained in the effect.
  107592. * @param camera The camera to get the post processes on.
  107593. * @returns The list of the post processes in the effect.
  107594. */
  107595. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  107596. }
  107597. }
  107598. declare module BABYLON {
  107599. /** @hidden */
  107600. export var extractHighlightsPixelShader: {
  107601. name: string;
  107602. shader: string;
  107603. };
  107604. }
  107605. declare module BABYLON {
  107606. /**
  107607. * 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.
  107608. */
  107609. export class ExtractHighlightsPostProcess extends PostProcess {
  107610. /**
  107611. * The luminance threshold, pixels below this value will be set to black.
  107612. */
  107613. threshold: number;
  107614. /** @hidden */
  107615. _exposure: number;
  107616. /**
  107617. * Post process which has the input texture to be used when performing highlight extraction
  107618. * @hidden
  107619. */
  107620. _inputPostProcess: Nullable<PostProcess>;
  107621. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107622. }
  107623. }
  107624. declare module BABYLON {
  107625. /** @hidden */
  107626. export var bloomMergePixelShader: {
  107627. name: string;
  107628. shader: string;
  107629. };
  107630. }
  107631. declare module BABYLON {
  107632. /**
  107633. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  107634. */
  107635. export class BloomMergePostProcess extends PostProcess {
  107636. /** Weight of the bloom to be added to the original input. */
  107637. weight: number;
  107638. /**
  107639. * Creates a new instance of @see BloomMergePostProcess
  107640. * @param name The name of the effect.
  107641. * @param originalFromInput Post process which's input will be used for the merge.
  107642. * @param blurred Blurred highlights post process which's output will be used.
  107643. * @param weight Weight of the bloom to be added to the original input.
  107644. * @param options The required width/height ratio to downsize to before computing the render pass.
  107645. * @param camera The camera to apply the render pass to.
  107646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107647. * @param engine The engine which the post process will be applied. (default: current engine)
  107648. * @param reusable If the post process can be reused on the same frame. (default: false)
  107649. * @param textureType Type of textures used when performing the post process. (default: 0)
  107650. * @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)
  107651. */
  107652. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  107653. /** Weight of the bloom to be added to the original input. */
  107654. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107655. }
  107656. }
  107657. declare module BABYLON {
  107658. /**
  107659. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  107660. */
  107661. export class BloomEffect extends PostProcessRenderEffect {
  107662. private bloomScale;
  107663. /**
  107664. * @hidden Internal
  107665. */
  107666. _effects: Array<PostProcess>;
  107667. /**
  107668. * @hidden Internal
  107669. */
  107670. _downscale: ExtractHighlightsPostProcess;
  107671. private _blurX;
  107672. private _blurY;
  107673. private _merge;
  107674. /**
  107675. * The luminance threshold to find bright areas of the image to bloom.
  107676. */
  107677. threshold: number;
  107678. /**
  107679. * The strength of the bloom.
  107680. */
  107681. weight: number;
  107682. /**
  107683. * Specifies the size of the bloom blur kernel, relative to the final output size
  107684. */
  107685. kernel: number;
  107686. /**
  107687. * Creates a new instance of @see BloomEffect
  107688. * @param scene The scene the effect belongs to.
  107689. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  107690. * @param bloomKernel The size of the kernel to be used when applying the blur.
  107691. * @param bloomWeight The the strength of bloom.
  107692. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  107693. * @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)
  107694. */
  107695. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  107696. /**
  107697. * Disposes each of the internal effects for a given camera.
  107698. * @param camera The camera to dispose the effect on.
  107699. */
  107700. disposeEffects(camera: Camera): void;
  107701. /**
  107702. * @hidden Internal
  107703. */
  107704. _updateEffects(): void;
  107705. /**
  107706. * Internal
  107707. * @returns if all the contained post processes are ready.
  107708. * @hidden
  107709. */
  107710. _isReady(): boolean;
  107711. }
  107712. }
  107713. declare module BABYLON {
  107714. /** @hidden */
  107715. export var chromaticAberrationPixelShader: {
  107716. name: string;
  107717. shader: string;
  107718. };
  107719. }
  107720. declare module BABYLON {
  107721. /**
  107722. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  107723. */
  107724. export class ChromaticAberrationPostProcess extends PostProcess {
  107725. /**
  107726. * The amount of seperation of rgb channels (default: 30)
  107727. */
  107728. aberrationAmount: number;
  107729. /**
  107730. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  107731. */
  107732. radialIntensity: number;
  107733. /**
  107734. * 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))
  107735. */
  107736. direction: Vector2;
  107737. /**
  107738. * 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))
  107739. */
  107740. centerPosition: Vector2;
  107741. /**
  107742. * Creates a new instance ChromaticAberrationPostProcess
  107743. * @param name The name of the effect.
  107744. * @param screenWidth The width of the screen to apply the effect on.
  107745. * @param screenHeight The height of the screen to apply the effect on.
  107746. * @param options The required width/height ratio to downsize to before computing the render pass.
  107747. * @param camera The camera to apply the render pass to.
  107748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107749. * @param engine The engine which the post process will be applied. (default: current engine)
  107750. * @param reusable If the post process can be reused on the same frame. (default: false)
  107751. * @param textureType Type of textures used when performing the post process. (default: 0)
  107752. * @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)
  107753. */
  107754. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107755. }
  107756. }
  107757. declare module BABYLON {
  107758. /** @hidden */
  107759. export var circleOfConfusionPixelShader: {
  107760. name: string;
  107761. shader: string;
  107762. };
  107763. }
  107764. declare module BABYLON {
  107765. /**
  107766. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  107767. */
  107768. export class CircleOfConfusionPostProcess extends PostProcess {
  107769. /**
  107770. * 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.
  107771. */
  107772. lensSize: number;
  107773. /**
  107774. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  107775. */
  107776. fStop: number;
  107777. /**
  107778. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  107779. */
  107780. focusDistance: number;
  107781. /**
  107782. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  107783. */
  107784. focalLength: number;
  107785. private _depthTexture;
  107786. /**
  107787. * Creates a new instance CircleOfConfusionPostProcess
  107788. * @param name The name of the effect.
  107789. * @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.
  107790. * @param options The required width/height ratio to downsize to before computing the render pass.
  107791. * @param camera The camera to apply the render pass to.
  107792. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107793. * @param engine The engine which the post process will be applied. (default: current engine)
  107794. * @param reusable If the post process can be reused on the same frame. (default: false)
  107795. * @param textureType Type of textures used when performing the post process. (default: 0)
  107796. * @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)
  107797. */
  107798. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107799. /**
  107800. * 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.
  107801. */
  107802. depthTexture: RenderTargetTexture;
  107803. }
  107804. }
  107805. declare module BABYLON {
  107806. /** @hidden */
  107807. export var colorCorrectionPixelShader: {
  107808. name: string;
  107809. shader: string;
  107810. };
  107811. }
  107812. declare module BABYLON {
  107813. /**
  107814. *
  107815. * This post-process allows the modification of rendered colors by using
  107816. * a 'look-up table' (LUT). This effect is also called Color Grading.
  107817. *
  107818. * The object needs to be provided an url to a texture containing the color
  107819. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  107820. * Use an image editing software to tweak the LUT to match your needs.
  107821. *
  107822. * For an example of a color LUT, see here:
  107823. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  107824. * For explanations on color grading, see here:
  107825. * @see http://udn.epicgames.com/Three/ColorGrading.html
  107826. *
  107827. */
  107828. export class ColorCorrectionPostProcess extends PostProcess {
  107829. private _colorTableTexture;
  107830. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107831. }
  107832. }
  107833. declare module BABYLON {
  107834. /** @hidden */
  107835. export var convolutionPixelShader: {
  107836. name: string;
  107837. shader: string;
  107838. };
  107839. }
  107840. declare module BABYLON {
  107841. /**
  107842. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  107843. * input texture to perform effects such as edge detection or sharpening
  107844. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  107845. */
  107846. export class ConvolutionPostProcess extends PostProcess {
  107847. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  107848. kernel: number[];
  107849. /**
  107850. * Creates a new instance ConvolutionPostProcess
  107851. * @param name The name of the effect.
  107852. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  107853. * @param options The required width/height ratio to downsize to before computing the render pass.
  107854. * @param camera The camera to apply the render pass to.
  107855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107856. * @param engine The engine which the post process will be applied. (default: current engine)
  107857. * @param reusable If the post process can be reused on the same frame. (default: false)
  107858. * @param textureType Type of textures used when performing the post process. (default: 0)
  107859. */
  107860. constructor(name: string,
  107861. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  107862. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  107863. /**
  107864. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107865. */
  107866. static EdgeDetect0Kernel: number[];
  107867. /**
  107868. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107869. */
  107870. static EdgeDetect1Kernel: number[];
  107871. /**
  107872. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107873. */
  107874. static EdgeDetect2Kernel: number[];
  107875. /**
  107876. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107877. */
  107878. static SharpenKernel: number[];
  107879. /**
  107880. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107881. */
  107882. static EmbossKernel: number[];
  107883. /**
  107884. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107885. */
  107886. static GaussianKernel: number[];
  107887. }
  107888. }
  107889. declare module BABYLON {
  107890. /**
  107891. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  107892. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  107893. * based on samples that have a large difference in distance than the center pixel.
  107894. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  107895. */
  107896. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  107897. direction: Vector2;
  107898. /**
  107899. * Creates a new instance CircleOfConfusionPostProcess
  107900. * @param name The name of the effect.
  107901. * @param scene The scene the effect belongs to.
  107902. * @param direction The direction the blur should be applied.
  107903. * @param kernel The size of the kernel used to blur.
  107904. * @param options The required width/height ratio to downsize to before computing the render pass.
  107905. * @param camera The camera to apply the render pass to.
  107906. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  107907. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  107908. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107909. * @param engine The engine which the post process will be applied. (default: current engine)
  107910. * @param reusable If the post process can be reused on the same frame. (default: false)
  107911. * @param textureType Type of textures used when performing the post process. (default: 0)
  107912. * @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)
  107913. */
  107914. 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);
  107915. }
  107916. }
  107917. declare module BABYLON {
  107918. /** @hidden */
  107919. export var depthOfFieldMergePixelShader: {
  107920. name: string;
  107921. shader: string;
  107922. };
  107923. }
  107924. declare module BABYLON {
  107925. /**
  107926. * Options to be set when merging outputs from the default pipeline.
  107927. */
  107928. export class DepthOfFieldMergePostProcessOptions {
  107929. /**
  107930. * The original image to merge on top of
  107931. */
  107932. originalFromInput: PostProcess;
  107933. /**
  107934. * Parameters to perform the merge of the depth of field effect
  107935. */
  107936. depthOfField?: {
  107937. circleOfConfusion: PostProcess;
  107938. blurSteps: Array<PostProcess>;
  107939. };
  107940. /**
  107941. * Parameters to perform the merge of bloom effect
  107942. */
  107943. bloom?: {
  107944. blurred: PostProcess;
  107945. weight: number;
  107946. };
  107947. }
  107948. /**
  107949. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  107950. */
  107951. export class DepthOfFieldMergePostProcess extends PostProcess {
  107952. private blurSteps;
  107953. /**
  107954. * Creates a new instance of DepthOfFieldMergePostProcess
  107955. * @param name The name of the effect.
  107956. * @param originalFromInput Post process which's input will be used for the merge.
  107957. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  107958. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  107959. * @param options The required width/height ratio to downsize to before computing the render pass.
  107960. * @param camera The camera to apply the render pass to.
  107961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107962. * @param engine The engine which the post process will be applied. (default: current engine)
  107963. * @param reusable If the post process can be reused on the same frame. (default: false)
  107964. * @param textureType Type of textures used when performing the post process. (default: 0)
  107965. * @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)
  107966. */
  107967. 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);
  107968. /**
  107969. * Updates the effect with the current post process compile time values and recompiles the shader.
  107970. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  107971. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  107972. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  107973. * @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
  107974. * @param onCompiled Called when the shader has been compiled.
  107975. * @param onError Called if there is an error when compiling a shader.
  107976. */
  107977. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  107978. }
  107979. }
  107980. declare module BABYLON {
  107981. /**
  107982. * Specifies the level of max blur that should be applied when using the depth of field effect
  107983. */
  107984. export enum DepthOfFieldEffectBlurLevel {
  107985. /**
  107986. * Subtle blur
  107987. */
  107988. Low = 0,
  107989. /**
  107990. * Medium blur
  107991. */
  107992. Medium = 1,
  107993. /**
  107994. * Large blur
  107995. */
  107996. High = 2
  107997. }
  107998. /**
  107999. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  108000. */
  108001. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  108002. private _circleOfConfusion;
  108003. /**
  108004. * @hidden Internal, blurs from high to low
  108005. */
  108006. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  108007. private _depthOfFieldBlurY;
  108008. private _dofMerge;
  108009. /**
  108010. * @hidden Internal post processes in depth of field effect
  108011. */
  108012. _effects: Array<PostProcess>;
  108013. /**
  108014. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  108015. */
  108016. focalLength: number;
  108017. /**
  108018. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108019. */
  108020. fStop: number;
  108021. /**
  108022. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108023. */
  108024. focusDistance: number;
  108025. /**
  108026. * 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.
  108027. */
  108028. lensSize: number;
  108029. /**
  108030. * Creates a new instance DepthOfFieldEffect
  108031. * @param scene The scene the effect belongs to.
  108032. * @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.
  108033. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108034. * @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)
  108035. */
  108036. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  108037. /**
  108038. * 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.
  108039. */
  108040. depthTexture: RenderTargetTexture;
  108041. /**
  108042. * Disposes each of the internal effects for a given camera.
  108043. * @param camera The camera to dispose the effect on.
  108044. */
  108045. disposeEffects(camera: Camera): void;
  108046. /**
  108047. * @hidden Internal
  108048. */
  108049. _updateEffects(): void;
  108050. /**
  108051. * Internal
  108052. * @returns if all the contained post processes are ready.
  108053. * @hidden
  108054. */
  108055. _isReady(): boolean;
  108056. }
  108057. }
  108058. declare module BABYLON {
  108059. /** @hidden */
  108060. export var displayPassPixelShader: {
  108061. name: string;
  108062. shader: string;
  108063. };
  108064. }
  108065. declare module BABYLON {
  108066. /**
  108067. * DisplayPassPostProcess which produces an output the same as it's input
  108068. */
  108069. export class DisplayPassPostProcess extends PostProcess {
  108070. /**
  108071. * Creates the DisplayPassPostProcess
  108072. * @param name The name of the effect.
  108073. * @param options The required width/height ratio to downsize to before computing the render pass.
  108074. * @param camera The camera to apply the render pass to.
  108075. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108076. * @param engine The engine which the post process will be applied. (default: current engine)
  108077. * @param reusable If the post process can be reused on the same frame. (default: false)
  108078. */
  108079. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108080. }
  108081. }
  108082. declare module BABYLON {
  108083. /** @hidden */
  108084. export var filterPixelShader: {
  108085. name: string;
  108086. shader: string;
  108087. };
  108088. }
  108089. declare module BABYLON {
  108090. /**
  108091. * Applies a kernel filter to the image
  108092. */
  108093. export class FilterPostProcess extends PostProcess {
  108094. /** The matrix to be applied to the image */
  108095. kernelMatrix: Matrix;
  108096. /**
  108097. *
  108098. * @param name The name of the effect.
  108099. * @param kernelMatrix The matrix to be applied to the image
  108100. * @param options The required width/height ratio to downsize to before computing the render pass.
  108101. * @param camera The camera to apply the render pass to.
  108102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108103. * @param engine The engine which the post process will be applied. (default: current engine)
  108104. * @param reusable If the post process can be reused on the same frame. (default: false)
  108105. */
  108106. constructor(name: string,
  108107. /** The matrix to be applied to the image */
  108108. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108109. }
  108110. }
  108111. declare module BABYLON {
  108112. /** @hidden */
  108113. export var fxaaPixelShader: {
  108114. name: string;
  108115. shader: string;
  108116. };
  108117. }
  108118. declare module BABYLON {
  108119. /** @hidden */
  108120. export var fxaaVertexShader: {
  108121. name: string;
  108122. shader: string;
  108123. };
  108124. }
  108125. declare module BABYLON {
  108126. /**
  108127. * Fxaa post process
  108128. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  108129. */
  108130. export class FxaaPostProcess extends PostProcess {
  108131. /** @hidden */
  108132. texelWidth: number;
  108133. /** @hidden */
  108134. texelHeight: number;
  108135. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108136. private _getDefines;
  108137. }
  108138. }
  108139. declare module BABYLON {
  108140. /** @hidden */
  108141. export var grainPixelShader: {
  108142. name: string;
  108143. shader: string;
  108144. };
  108145. }
  108146. declare module BABYLON {
  108147. /**
  108148. * The GrainPostProcess adds noise to the image at mid luminance levels
  108149. */
  108150. export class GrainPostProcess extends PostProcess {
  108151. /**
  108152. * The intensity of the grain added (default: 30)
  108153. */
  108154. intensity: number;
  108155. /**
  108156. * If the grain should be randomized on every frame
  108157. */
  108158. animated: boolean;
  108159. /**
  108160. * Creates a new instance of @see GrainPostProcess
  108161. * @param name The name of the effect.
  108162. * @param options The required width/height ratio to downsize to before computing the render pass.
  108163. * @param camera The camera to apply the render pass to.
  108164. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108165. * @param engine The engine which the post process will be applied. (default: current engine)
  108166. * @param reusable If the post process can be reused on the same frame. (default: false)
  108167. * @param textureType Type of textures used when performing the post process. (default: 0)
  108168. * @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)
  108169. */
  108170. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108171. }
  108172. }
  108173. declare module BABYLON {
  108174. /** @hidden */
  108175. export var highlightsPixelShader: {
  108176. name: string;
  108177. shader: string;
  108178. };
  108179. }
  108180. declare module BABYLON {
  108181. /**
  108182. * Extracts highlights from the image
  108183. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108184. */
  108185. export class HighlightsPostProcess extends PostProcess {
  108186. /**
  108187. * Extracts highlights from the image
  108188. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108189. * @param name The name of the effect.
  108190. * @param options The required width/height ratio to downsize to before computing the render pass.
  108191. * @param camera The camera to apply the render pass to.
  108192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108193. * @param engine The engine which the post process will be applied. (default: current engine)
  108194. * @param reusable If the post process can be reused on the same frame. (default: false)
  108195. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  108196. */
  108197. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108198. }
  108199. }
  108200. declare module BABYLON {
  108201. /** @hidden */
  108202. export var mrtFragmentDeclaration: {
  108203. name: string;
  108204. shader: string;
  108205. };
  108206. }
  108207. declare module BABYLON {
  108208. /** @hidden */
  108209. export var geometryPixelShader: {
  108210. name: string;
  108211. shader: string;
  108212. };
  108213. }
  108214. declare module BABYLON {
  108215. /** @hidden */
  108216. export var geometryVertexShader: {
  108217. name: string;
  108218. shader: string;
  108219. };
  108220. }
  108221. declare module BABYLON {
  108222. /**
  108223. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108224. */
  108225. export class GeometryBufferRenderer {
  108226. /**
  108227. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108228. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108229. */
  108230. static readonly POSITION_TEXTURE_TYPE: number;
  108231. /**
  108232. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108233. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108234. */
  108235. static readonly VELOCITY_TEXTURE_TYPE: number;
  108236. /**
  108237. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108238. * in order to compute objects velocities when enableVelocity is set to "true"
  108239. * @hidden
  108240. */
  108241. _previousTransformationMatrices: {
  108242. [index: number]: Matrix;
  108243. };
  108244. private _scene;
  108245. private _multiRenderTarget;
  108246. private _ratio;
  108247. private _enablePosition;
  108248. private _enableVelocity;
  108249. private _positionIndex;
  108250. private _velocityIndex;
  108251. protected _effect: Effect;
  108252. protected _cachedDefines: string;
  108253. /**
  108254. * Set the render list (meshes to be rendered) used in the G buffer.
  108255. */
  108256. renderList: Mesh[];
  108257. /**
  108258. * Gets wether or not G buffer are supported by the running hardware.
  108259. * This requires draw buffer supports
  108260. */
  108261. readonly isSupported: boolean;
  108262. /**
  108263. * Returns the index of the given texture type in the G-Buffer textures array
  108264. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108265. * @returns the index of the given texture type in the G-Buffer textures array
  108266. */
  108267. getTextureIndex(textureType: number): number;
  108268. /**
  108269. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108270. */
  108271. /**
  108272. * Sets whether or not objects positions are enabled for the G buffer.
  108273. */
  108274. enablePosition: boolean;
  108275. /**
  108276. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108277. */
  108278. /**
  108279. * Sets wether or not objects velocities are enabled for the G buffer.
  108280. */
  108281. enableVelocity: boolean;
  108282. /**
  108283. * Gets the scene associated with the buffer.
  108284. */
  108285. readonly scene: Scene;
  108286. /**
  108287. * Gets the ratio used by the buffer during its creation.
  108288. * How big is the buffer related to the main canvas.
  108289. */
  108290. readonly ratio: number;
  108291. /** @hidden */
  108292. static _SceneComponentInitialization: (scene: Scene) => void;
  108293. /**
  108294. * Creates a new G Buffer for the scene
  108295. * @param scene The scene the buffer belongs to
  108296. * @param ratio How big is the buffer related to the main canvas.
  108297. */
  108298. constructor(scene: Scene, ratio?: number);
  108299. /**
  108300. * Checks wether everything is ready to render a submesh to the G buffer.
  108301. * @param subMesh the submesh to check readiness for
  108302. * @param useInstances is the mesh drawn using instance or not
  108303. * @returns true if ready otherwise false
  108304. */
  108305. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108306. /**
  108307. * Gets the current underlying G Buffer.
  108308. * @returns the buffer
  108309. */
  108310. getGBuffer(): MultiRenderTarget;
  108311. /**
  108312. * Gets the number of samples used to render the buffer (anti aliasing).
  108313. */
  108314. /**
  108315. * Sets the number of samples used to render the buffer (anti aliasing).
  108316. */
  108317. samples: number;
  108318. /**
  108319. * Disposes the renderer and frees up associated resources.
  108320. */
  108321. dispose(): void;
  108322. protected _createRenderTargets(): void;
  108323. }
  108324. }
  108325. declare module BABYLON {
  108326. /** @hidden */
  108327. export var motionBlurPixelShader: {
  108328. name: string;
  108329. shader: string;
  108330. };
  108331. }
  108332. declare module BABYLON {
  108333. /**
  108334. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  108335. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  108336. * As an example, all you have to do is to create the post-process:
  108337. * var mb = new BABYLON.MotionBlurPostProcess(
  108338. * 'mb', // The name of the effect.
  108339. * scene, // The scene containing the objects to blur according to their velocity.
  108340. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  108341. * camera // The camera to apply the render pass to.
  108342. * );
  108343. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  108344. */
  108345. export class MotionBlurPostProcess extends PostProcess {
  108346. /**
  108347. * Defines how much the image is blurred by the movement. Default value is equal to 1
  108348. */
  108349. motionStrength: number;
  108350. /**
  108351. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  108352. */
  108353. /**
  108354. * Sets the number of iterations to be used for motion blur quality
  108355. */
  108356. motionBlurSamples: number;
  108357. private _motionBlurSamples;
  108358. private _geometryBufferRenderer;
  108359. /**
  108360. * Creates a new instance MotionBlurPostProcess
  108361. * @param name The name of the effect.
  108362. * @param scene The scene containing the objects to blur according to their velocity.
  108363. * @param options The required width/height ratio to downsize to before computing the render pass.
  108364. * @param camera The camera to apply the render pass to.
  108365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108366. * @param engine The engine which the post process will be applied. (default: current engine)
  108367. * @param reusable If the post process can be reused on the same frame. (default: false)
  108368. * @param textureType Type of textures used when performing the post process. (default: 0)
  108369. * @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)
  108370. */
  108371. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108372. /**
  108373. * Disposes the post process.
  108374. * @param camera The camera to dispose the post process on.
  108375. */
  108376. dispose(camera?: Camera): void;
  108377. }
  108378. }
  108379. declare module BABYLON {
  108380. /** @hidden */
  108381. export var refractionPixelShader: {
  108382. name: string;
  108383. shader: string;
  108384. };
  108385. }
  108386. declare module BABYLON {
  108387. /**
  108388. * Post process which applies a refractin texture
  108389. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108390. */
  108391. export class RefractionPostProcess extends PostProcess {
  108392. /** the base color of the refraction (used to taint the rendering) */
  108393. color: Color3;
  108394. /** simulated refraction depth */
  108395. depth: number;
  108396. /** the coefficient of the base color (0 to remove base color tainting) */
  108397. colorLevel: number;
  108398. private _refTexture;
  108399. private _ownRefractionTexture;
  108400. /**
  108401. * Gets or sets the refraction texture
  108402. * Please note that you are responsible for disposing the texture if you set it manually
  108403. */
  108404. refractionTexture: Texture;
  108405. /**
  108406. * Initializes the RefractionPostProcess
  108407. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108408. * @param name The name of the effect.
  108409. * @param refractionTextureUrl Url of the refraction texture to use
  108410. * @param color the base color of the refraction (used to taint the rendering)
  108411. * @param depth simulated refraction depth
  108412. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  108413. * @param camera The camera to apply the render pass to.
  108414. * @param options The required width/height ratio to downsize to before computing the render pass.
  108415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108416. * @param engine The engine which the post process will be applied. (default: current engine)
  108417. * @param reusable If the post process can be reused on the same frame. (default: false)
  108418. */
  108419. constructor(name: string, refractionTextureUrl: string,
  108420. /** the base color of the refraction (used to taint the rendering) */
  108421. color: Color3,
  108422. /** simulated refraction depth */
  108423. depth: number,
  108424. /** the coefficient of the base color (0 to remove base color tainting) */
  108425. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108426. /**
  108427. * Disposes of the post process
  108428. * @param camera Camera to dispose post process on
  108429. */
  108430. dispose(camera: Camera): void;
  108431. }
  108432. }
  108433. declare module BABYLON {
  108434. /** @hidden */
  108435. export var sharpenPixelShader: {
  108436. name: string;
  108437. shader: string;
  108438. };
  108439. }
  108440. declare module BABYLON {
  108441. /**
  108442. * The SharpenPostProcess applies a sharpen kernel to every pixel
  108443. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108444. */
  108445. export class SharpenPostProcess extends PostProcess {
  108446. /**
  108447. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  108448. */
  108449. colorAmount: number;
  108450. /**
  108451. * How much sharpness should be applied (default: 0.3)
  108452. */
  108453. edgeAmount: number;
  108454. /**
  108455. * Creates a new instance ConvolutionPostProcess
  108456. * @param name The name of the effect.
  108457. * @param options The required width/height ratio to downsize to before computing the render pass.
  108458. * @param camera The camera to apply the render pass to.
  108459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108460. * @param engine The engine which the post process will be applied. (default: current engine)
  108461. * @param reusable If the post process can be reused on the same frame. (default: false)
  108462. * @param textureType Type of textures used when performing the post process. (default: 0)
  108463. * @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)
  108464. */
  108465. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108466. }
  108467. }
  108468. declare module BABYLON {
  108469. /**
  108470. * PostProcessRenderPipeline
  108471. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108472. */
  108473. export class PostProcessRenderPipeline {
  108474. private engine;
  108475. private _renderEffects;
  108476. private _renderEffectsForIsolatedPass;
  108477. /**
  108478. * @hidden
  108479. */
  108480. protected _cameras: Camera[];
  108481. /** @hidden */
  108482. _name: string;
  108483. /**
  108484. * Gets pipeline name
  108485. */
  108486. readonly name: string;
  108487. /**
  108488. * Initializes a PostProcessRenderPipeline
  108489. * @param engine engine to add the pipeline to
  108490. * @param name name of the pipeline
  108491. */
  108492. constructor(engine: Engine, name: string);
  108493. /**
  108494. * Gets the class name
  108495. * @returns "PostProcessRenderPipeline"
  108496. */
  108497. getClassName(): string;
  108498. /**
  108499. * If all the render effects in the pipeline are supported
  108500. */
  108501. readonly isSupported: boolean;
  108502. /**
  108503. * Adds an effect to the pipeline
  108504. * @param renderEffect the effect to add
  108505. */
  108506. addEffect(renderEffect: PostProcessRenderEffect): void;
  108507. /** @hidden */
  108508. _rebuild(): void;
  108509. /** @hidden */
  108510. _enableEffect(renderEffectName: string, cameras: Camera): void;
  108511. /** @hidden */
  108512. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  108513. /** @hidden */
  108514. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  108515. /** @hidden */
  108516. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  108517. /** @hidden */
  108518. _attachCameras(cameras: Camera, unique: boolean): void;
  108519. /** @hidden */
  108520. _attachCameras(cameras: Camera[], unique: boolean): void;
  108521. /** @hidden */
  108522. _detachCameras(cameras: Camera): void;
  108523. /** @hidden */
  108524. _detachCameras(cameras: Nullable<Camera[]>): void;
  108525. /** @hidden */
  108526. _update(): void;
  108527. /** @hidden */
  108528. _reset(): void;
  108529. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  108530. /**
  108531. * Disposes of the pipeline
  108532. */
  108533. dispose(): void;
  108534. }
  108535. }
  108536. declare module BABYLON {
  108537. /**
  108538. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  108539. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  108540. */
  108541. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  108542. private _scene;
  108543. private _camerasToBeAttached;
  108544. /**
  108545. * ID of the sharpen post process,
  108546. */
  108547. private readonly SharpenPostProcessId;
  108548. /**
  108549. * @ignore
  108550. * ID of the image processing post process;
  108551. */
  108552. readonly ImageProcessingPostProcessId: string;
  108553. /**
  108554. * @ignore
  108555. * ID of the Fast Approximate Anti-Aliasing post process;
  108556. */
  108557. readonly FxaaPostProcessId: string;
  108558. /**
  108559. * ID of the chromatic aberration post process,
  108560. */
  108561. private readonly ChromaticAberrationPostProcessId;
  108562. /**
  108563. * ID of the grain post process
  108564. */
  108565. private readonly GrainPostProcessId;
  108566. /**
  108567. * Sharpen post process which will apply a sharpen convolution to enhance edges
  108568. */
  108569. sharpen: SharpenPostProcess;
  108570. private _sharpenEffect;
  108571. private bloom;
  108572. /**
  108573. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  108574. */
  108575. depthOfField: DepthOfFieldEffect;
  108576. /**
  108577. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  108578. */
  108579. fxaa: FxaaPostProcess;
  108580. /**
  108581. * Image post processing pass used to perform operations such as tone mapping or color grading.
  108582. */
  108583. imageProcessing: ImageProcessingPostProcess;
  108584. /**
  108585. * Chromatic aberration post process which will shift rgb colors in the image
  108586. */
  108587. chromaticAberration: ChromaticAberrationPostProcess;
  108588. private _chromaticAberrationEffect;
  108589. /**
  108590. * Grain post process which add noise to the image
  108591. */
  108592. grain: GrainPostProcess;
  108593. private _grainEffect;
  108594. /**
  108595. * Glow post process which adds a glow to emissive areas of the image
  108596. */
  108597. private _glowLayer;
  108598. /**
  108599. * Animations which can be used to tweak settings over a period of time
  108600. */
  108601. animations: Animation[];
  108602. private _imageProcessingConfigurationObserver;
  108603. private _sharpenEnabled;
  108604. private _bloomEnabled;
  108605. private _depthOfFieldEnabled;
  108606. private _depthOfFieldBlurLevel;
  108607. private _fxaaEnabled;
  108608. private _imageProcessingEnabled;
  108609. private _defaultPipelineTextureType;
  108610. private _bloomScale;
  108611. private _chromaticAberrationEnabled;
  108612. private _grainEnabled;
  108613. private _buildAllowed;
  108614. /**
  108615. * Gets active scene
  108616. */
  108617. readonly scene: Scene;
  108618. /**
  108619. * Enable or disable the sharpen process from the pipeline
  108620. */
  108621. sharpenEnabled: boolean;
  108622. private _resizeObserver;
  108623. private _hardwareScaleLevel;
  108624. private _bloomKernel;
  108625. /**
  108626. * Specifies the size of the bloom blur kernel, relative to the final output size
  108627. */
  108628. bloomKernel: number;
  108629. /**
  108630. * Specifies the weight of the bloom in the final rendering
  108631. */
  108632. private _bloomWeight;
  108633. /**
  108634. * Specifies the luma threshold for the area that will be blurred by the bloom
  108635. */
  108636. private _bloomThreshold;
  108637. private _hdr;
  108638. /**
  108639. * The strength of the bloom.
  108640. */
  108641. bloomWeight: number;
  108642. /**
  108643. * The strength of the bloom.
  108644. */
  108645. bloomThreshold: number;
  108646. /**
  108647. * The scale of the bloom, lower value will provide better performance.
  108648. */
  108649. bloomScale: number;
  108650. /**
  108651. * Enable or disable the bloom from the pipeline
  108652. */
  108653. bloomEnabled: boolean;
  108654. private _rebuildBloom;
  108655. /**
  108656. * If the depth of field is enabled.
  108657. */
  108658. depthOfFieldEnabled: boolean;
  108659. /**
  108660. * Blur level of the depth of field effect. (Higher blur will effect performance)
  108661. */
  108662. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  108663. /**
  108664. * If the anti aliasing is enabled.
  108665. */
  108666. fxaaEnabled: boolean;
  108667. private _samples;
  108668. /**
  108669. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  108670. */
  108671. samples: number;
  108672. /**
  108673. * If image processing is enabled.
  108674. */
  108675. imageProcessingEnabled: boolean;
  108676. /**
  108677. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  108678. */
  108679. glowLayerEnabled: boolean;
  108680. /**
  108681. * Enable or disable the chromaticAberration process from the pipeline
  108682. */
  108683. chromaticAberrationEnabled: boolean;
  108684. /**
  108685. * Enable or disable the grain process from the pipeline
  108686. */
  108687. grainEnabled: boolean;
  108688. /**
  108689. * @constructor
  108690. * @param name - The rendering pipeline name (default: "")
  108691. * @param hdr - If high dynamic range textures should be used (default: true)
  108692. * @param scene - The scene linked to this pipeline (default: the last created scene)
  108693. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  108694. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  108695. */
  108696. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  108697. /**
  108698. * Get the class name
  108699. * @returns "DefaultRenderingPipeline"
  108700. */
  108701. getClassName(): string;
  108702. /**
  108703. * Force the compilation of the entire pipeline.
  108704. */
  108705. prepare(): void;
  108706. private _hasCleared;
  108707. private _prevPostProcess;
  108708. private _prevPrevPostProcess;
  108709. private _setAutoClearAndTextureSharing;
  108710. private _depthOfFieldSceneObserver;
  108711. private _buildPipeline;
  108712. private _disposePostProcesses;
  108713. /**
  108714. * Adds a camera to the pipeline
  108715. * @param camera the camera to be added
  108716. */
  108717. addCamera(camera: Camera): void;
  108718. /**
  108719. * Removes a camera from the pipeline
  108720. * @param camera the camera to remove
  108721. */
  108722. removeCamera(camera: Camera): void;
  108723. /**
  108724. * Dispose of the pipeline and stop all post processes
  108725. */
  108726. dispose(): void;
  108727. /**
  108728. * Serialize the rendering pipeline (Used when exporting)
  108729. * @returns the serialized object
  108730. */
  108731. serialize(): any;
  108732. /**
  108733. * Parse the serialized pipeline
  108734. * @param source Source pipeline.
  108735. * @param scene The scene to load the pipeline to.
  108736. * @param rootUrl The URL of the serialized pipeline.
  108737. * @returns An instantiated pipeline from the serialized object.
  108738. */
  108739. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  108740. }
  108741. }
  108742. declare module BABYLON {
  108743. /** @hidden */
  108744. export var lensHighlightsPixelShader: {
  108745. name: string;
  108746. shader: string;
  108747. };
  108748. }
  108749. declare module BABYLON {
  108750. /** @hidden */
  108751. export var depthOfFieldPixelShader: {
  108752. name: string;
  108753. shader: string;
  108754. };
  108755. }
  108756. declare module BABYLON {
  108757. /**
  108758. * BABYLON.JS Chromatic Aberration GLSL Shader
  108759. * Author: Olivier Guyot
  108760. * Separates very slightly R, G and B colors on the edges of the screen
  108761. * Inspired by Francois Tarlier & Martins Upitis
  108762. */
  108763. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  108764. /**
  108765. * @ignore
  108766. * The chromatic aberration PostProcess id in the pipeline
  108767. */
  108768. LensChromaticAberrationEffect: string;
  108769. /**
  108770. * @ignore
  108771. * The highlights enhancing PostProcess id in the pipeline
  108772. */
  108773. HighlightsEnhancingEffect: string;
  108774. /**
  108775. * @ignore
  108776. * The depth-of-field PostProcess id in the pipeline
  108777. */
  108778. LensDepthOfFieldEffect: string;
  108779. private _scene;
  108780. private _depthTexture;
  108781. private _grainTexture;
  108782. private _chromaticAberrationPostProcess;
  108783. private _highlightsPostProcess;
  108784. private _depthOfFieldPostProcess;
  108785. private _edgeBlur;
  108786. private _grainAmount;
  108787. private _chromaticAberration;
  108788. private _distortion;
  108789. private _highlightsGain;
  108790. private _highlightsThreshold;
  108791. private _dofDistance;
  108792. private _dofAperture;
  108793. private _dofDarken;
  108794. private _dofPentagon;
  108795. private _blurNoise;
  108796. /**
  108797. * @constructor
  108798. *
  108799. * Effect parameters are as follow:
  108800. * {
  108801. * chromatic_aberration: number; // from 0 to x (1 for realism)
  108802. * edge_blur: number; // from 0 to x (1 for realism)
  108803. * distortion: number; // from 0 to x (1 for realism)
  108804. * grain_amount: number; // from 0 to 1
  108805. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  108806. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  108807. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  108808. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  108809. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  108810. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  108811. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  108812. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  108813. * }
  108814. * Note: if an effect parameter is unset, effect is disabled
  108815. *
  108816. * @param name The rendering pipeline name
  108817. * @param parameters - An object containing all parameters (see above)
  108818. * @param scene The scene linked to this pipeline
  108819. * @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)
  108820. * @param cameras The array of cameras that the rendering pipeline will be attached to
  108821. */
  108822. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  108823. /**
  108824. * Sets the amount of blur at the edges
  108825. * @param amount blur amount
  108826. */
  108827. setEdgeBlur(amount: number): void;
  108828. /**
  108829. * Sets edge blur to 0
  108830. */
  108831. disableEdgeBlur(): void;
  108832. /**
  108833. * Sets the amout of grain
  108834. * @param amount Amount of grain
  108835. */
  108836. setGrainAmount(amount: number): void;
  108837. /**
  108838. * Set grain amount to 0
  108839. */
  108840. disableGrain(): void;
  108841. /**
  108842. * Sets the chromatic aberration amount
  108843. * @param amount amount of chromatic aberration
  108844. */
  108845. setChromaticAberration(amount: number): void;
  108846. /**
  108847. * Sets chromatic aberration amount to 0
  108848. */
  108849. disableChromaticAberration(): void;
  108850. /**
  108851. * Sets the EdgeDistortion amount
  108852. * @param amount amount of EdgeDistortion
  108853. */
  108854. setEdgeDistortion(amount: number): void;
  108855. /**
  108856. * Sets edge distortion to 0
  108857. */
  108858. disableEdgeDistortion(): void;
  108859. /**
  108860. * Sets the FocusDistance amount
  108861. * @param amount amount of FocusDistance
  108862. */
  108863. setFocusDistance(amount: number): void;
  108864. /**
  108865. * Disables depth of field
  108866. */
  108867. disableDepthOfField(): void;
  108868. /**
  108869. * Sets the Aperture amount
  108870. * @param amount amount of Aperture
  108871. */
  108872. setAperture(amount: number): void;
  108873. /**
  108874. * Sets the DarkenOutOfFocus amount
  108875. * @param amount amount of DarkenOutOfFocus
  108876. */
  108877. setDarkenOutOfFocus(amount: number): void;
  108878. /**
  108879. * Creates a pentagon bokeh effect
  108880. */
  108881. enablePentagonBokeh(): void;
  108882. /**
  108883. * Disables the pentagon bokeh effect
  108884. */
  108885. disablePentagonBokeh(): void;
  108886. /**
  108887. * Enables noise blur
  108888. */
  108889. enableNoiseBlur(): void;
  108890. /**
  108891. * Disables noise blur
  108892. */
  108893. disableNoiseBlur(): void;
  108894. /**
  108895. * Sets the HighlightsGain amount
  108896. * @param amount amount of HighlightsGain
  108897. */
  108898. setHighlightsGain(amount: number): void;
  108899. /**
  108900. * Sets the HighlightsThreshold amount
  108901. * @param amount amount of HighlightsThreshold
  108902. */
  108903. setHighlightsThreshold(amount: number): void;
  108904. /**
  108905. * Disables highlights
  108906. */
  108907. disableHighlights(): void;
  108908. /**
  108909. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  108910. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  108911. */
  108912. dispose(disableDepthRender?: boolean): void;
  108913. private _createChromaticAberrationPostProcess;
  108914. private _createHighlightsPostProcess;
  108915. private _createDepthOfFieldPostProcess;
  108916. private _createGrainTexture;
  108917. }
  108918. }
  108919. declare module BABYLON {
  108920. /** @hidden */
  108921. export var ssao2PixelShader: {
  108922. name: string;
  108923. shader: string;
  108924. };
  108925. }
  108926. declare module BABYLON {
  108927. /** @hidden */
  108928. export var ssaoCombinePixelShader: {
  108929. name: string;
  108930. shader: string;
  108931. };
  108932. }
  108933. declare module BABYLON {
  108934. /**
  108935. * Render pipeline to produce ssao effect
  108936. */
  108937. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  108938. /**
  108939. * @ignore
  108940. * The PassPostProcess id in the pipeline that contains the original scene color
  108941. */
  108942. SSAOOriginalSceneColorEffect: string;
  108943. /**
  108944. * @ignore
  108945. * The SSAO PostProcess id in the pipeline
  108946. */
  108947. SSAORenderEffect: string;
  108948. /**
  108949. * @ignore
  108950. * The horizontal blur PostProcess id in the pipeline
  108951. */
  108952. SSAOBlurHRenderEffect: string;
  108953. /**
  108954. * @ignore
  108955. * The vertical blur PostProcess id in the pipeline
  108956. */
  108957. SSAOBlurVRenderEffect: string;
  108958. /**
  108959. * @ignore
  108960. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  108961. */
  108962. SSAOCombineRenderEffect: string;
  108963. /**
  108964. * The output strength of the SSAO post-process. Default value is 1.0.
  108965. */
  108966. totalStrength: number;
  108967. /**
  108968. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  108969. */
  108970. maxZ: number;
  108971. /**
  108972. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  108973. */
  108974. minZAspect: number;
  108975. private _samples;
  108976. /**
  108977. * Number of samples used for the SSAO calculations. Default value is 8
  108978. */
  108979. samples: number;
  108980. private _textureSamples;
  108981. /**
  108982. * Number of samples to use for antialiasing
  108983. */
  108984. textureSamples: number;
  108985. /**
  108986. * Ratio object used for SSAO ratio and blur ratio
  108987. */
  108988. private _ratio;
  108989. /**
  108990. * Dynamically generated sphere sampler.
  108991. */
  108992. private _sampleSphere;
  108993. /**
  108994. * Blur filter offsets
  108995. */
  108996. private _samplerOffsets;
  108997. private _expensiveBlur;
  108998. /**
  108999. * If bilateral blur should be used
  109000. */
  109001. expensiveBlur: boolean;
  109002. /**
  109003. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  109004. */
  109005. radius: number;
  109006. /**
  109007. * The base color of the SSAO post-process
  109008. * The final result is "base + ssao" between [0, 1]
  109009. */
  109010. base: number;
  109011. /**
  109012. * Support test.
  109013. */
  109014. static readonly IsSupported: boolean;
  109015. private _scene;
  109016. private _depthTexture;
  109017. private _normalTexture;
  109018. private _randomTexture;
  109019. private _originalColorPostProcess;
  109020. private _ssaoPostProcess;
  109021. private _blurHPostProcess;
  109022. private _blurVPostProcess;
  109023. private _ssaoCombinePostProcess;
  109024. private _firstUpdate;
  109025. /**
  109026. * Gets active scene
  109027. */
  109028. readonly scene: Scene;
  109029. /**
  109030. * @constructor
  109031. * @param name The rendering pipeline name
  109032. * @param scene The scene linked to this pipeline
  109033. * @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 }
  109034. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109035. */
  109036. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109037. /**
  109038. * Get the class name
  109039. * @returns "SSAO2RenderingPipeline"
  109040. */
  109041. getClassName(): string;
  109042. /**
  109043. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109044. */
  109045. dispose(disableGeometryBufferRenderer?: boolean): void;
  109046. private _createBlurPostProcess;
  109047. /** @hidden */
  109048. _rebuild(): void;
  109049. private _bits;
  109050. private _radicalInverse_VdC;
  109051. private _hammersley;
  109052. private _hemisphereSample_uniform;
  109053. private _generateHemisphere;
  109054. private _createSSAOPostProcess;
  109055. private _createSSAOCombinePostProcess;
  109056. private _createRandomTexture;
  109057. /**
  109058. * Serialize the rendering pipeline (Used when exporting)
  109059. * @returns the serialized object
  109060. */
  109061. serialize(): any;
  109062. /**
  109063. * Parse the serialized pipeline
  109064. * @param source Source pipeline.
  109065. * @param scene The scene to load the pipeline to.
  109066. * @param rootUrl The URL of the serialized pipeline.
  109067. * @returns An instantiated pipeline from the serialized object.
  109068. */
  109069. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  109070. }
  109071. }
  109072. declare module BABYLON {
  109073. /** @hidden */
  109074. export var ssaoPixelShader: {
  109075. name: string;
  109076. shader: string;
  109077. };
  109078. }
  109079. declare module BABYLON {
  109080. /**
  109081. * Render pipeline to produce ssao effect
  109082. */
  109083. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  109084. /**
  109085. * @ignore
  109086. * The PassPostProcess id in the pipeline that contains the original scene color
  109087. */
  109088. SSAOOriginalSceneColorEffect: string;
  109089. /**
  109090. * @ignore
  109091. * The SSAO PostProcess id in the pipeline
  109092. */
  109093. SSAORenderEffect: string;
  109094. /**
  109095. * @ignore
  109096. * The horizontal blur PostProcess id in the pipeline
  109097. */
  109098. SSAOBlurHRenderEffect: string;
  109099. /**
  109100. * @ignore
  109101. * The vertical blur PostProcess id in the pipeline
  109102. */
  109103. SSAOBlurVRenderEffect: string;
  109104. /**
  109105. * @ignore
  109106. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109107. */
  109108. SSAOCombineRenderEffect: string;
  109109. /**
  109110. * The output strength of the SSAO post-process. Default value is 1.0.
  109111. */
  109112. totalStrength: number;
  109113. /**
  109114. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  109115. */
  109116. radius: number;
  109117. /**
  109118. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  109119. * Must not be equal to fallOff and superior to fallOff.
  109120. * Default value is 0.0075
  109121. */
  109122. area: number;
  109123. /**
  109124. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  109125. * Must not be equal to area and inferior to area.
  109126. * Default value is 0.000001
  109127. */
  109128. fallOff: number;
  109129. /**
  109130. * The base color of the SSAO post-process
  109131. * The final result is "base + ssao" between [0, 1]
  109132. */
  109133. base: number;
  109134. private _scene;
  109135. private _depthTexture;
  109136. private _randomTexture;
  109137. private _originalColorPostProcess;
  109138. private _ssaoPostProcess;
  109139. private _blurHPostProcess;
  109140. private _blurVPostProcess;
  109141. private _ssaoCombinePostProcess;
  109142. private _firstUpdate;
  109143. /**
  109144. * Gets active scene
  109145. */
  109146. readonly scene: Scene;
  109147. /**
  109148. * @constructor
  109149. * @param name - The rendering pipeline name
  109150. * @param scene - The scene linked to this pipeline
  109151. * @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 }
  109152. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  109153. */
  109154. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109155. /**
  109156. * Get the class name
  109157. * @returns "SSAORenderingPipeline"
  109158. */
  109159. getClassName(): string;
  109160. /**
  109161. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109162. */
  109163. dispose(disableDepthRender?: boolean): void;
  109164. private _createBlurPostProcess;
  109165. /** @hidden */
  109166. _rebuild(): void;
  109167. private _createSSAOPostProcess;
  109168. private _createSSAOCombinePostProcess;
  109169. private _createRandomTexture;
  109170. }
  109171. }
  109172. declare module BABYLON {
  109173. /** @hidden */
  109174. export var standardPixelShader: {
  109175. name: string;
  109176. shader: string;
  109177. };
  109178. }
  109179. declare module BABYLON {
  109180. /**
  109181. * Standard rendering pipeline
  109182. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109183. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  109184. */
  109185. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109186. /**
  109187. * Public members
  109188. */
  109189. /**
  109190. * Post-process which contains the original scene color before the pipeline applies all the effects
  109191. */
  109192. originalPostProcess: Nullable<PostProcess>;
  109193. /**
  109194. * Post-process used to down scale an image x4
  109195. */
  109196. downSampleX4PostProcess: Nullable<PostProcess>;
  109197. /**
  109198. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  109199. */
  109200. brightPassPostProcess: Nullable<PostProcess>;
  109201. /**
  109202. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  109203. */
  109204. blurHPostProcesses: PostProcess[];
  109205. /**
  109206. * Post-process array storing all the vertical blur post-processes used by the pipeline
  109207. */
  109208. blurVPostProcesses: PostProcess[];
  109209. /**
  109210. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  109211. */
  109212. textureAdderPostProcess: Nullable<PostProcess>;
  109213. /**
  109214. * Post-process used to create volumetric lighting effect
  109215. */
  109216. volumetricLightPostProcess: Nullable<PostProcess>;
  109217. /**
  109218. * Post-process used to smooth the previous volumetric light post-process on the X axis
  109219. */
  109220. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  109221. /**
  109222. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  109223. */
  109224. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  109225. /**
  109226. * Post-process used to merge the volumetric light effect and the real scene color
  109227. */
  109228. volumetricLightMergePostProces: Nullable<PostProcess>;
  109229. /**
  109230. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  109231. */
  109232. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  109233. /**
  109234. * Base post-process used to calculate the average luminance of the final image for HDR
  109235. */
  109236. luminancePostProcess: Nullable<PostProcess>;
  109237. /**
  109238. * Post-processes used to create down sample post-processes in order to get
  109239. * the average luminance of the final image for HDR
  109240. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  109241. */
  109242. luminanceDownSamplePostProcesses: PostProcess[];
  109243. /**
  109244. * Post-process used to create a HDR effect (light adaptation)
  109245. */
  109246. hdrPostProcess: Nullable<PostProcess>;
  109247. /**
  109248. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  109249. */
  109250. textureAdderFinalPostProcess: Nullable<PostProcess>;
  109251. /**
  109252. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  109253. */
  109254. lensFlareFinalPostProcess: Nullable<PostProcess>;
  109255. /**
  109256. * Post-process used to merge the final HDR post-process and the real scene color
  109257. */
  109258. hdrFinalPostProcess: Nullable<PostProcess>;
  109259. /**
  109260. * Post-process used to create a lens flare effect
  109261. */
  109262. lensFlarePostProcess: Nullable<PostProcess>;
  109263. /**
  109264. * Post-process that merges the result of the lens flare post-process and the real scene color
  109265. */
  109266. lensFlareComposePostProcess: Nullable<PostProcess>;
  109267. /**
  109268. * Post-process used to create a motion blur effect
  109269. */
  109270. motionBlurPostProcess: Nullable<PostProcess>;
  109271. /**
  109272. * Post-process used to create a depth of field effect
  109273. */
  109274. depthOfFieldPostProcess: Nullable<PostProcess>;
  109275. /**
  109276. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109277. */
  109278. fxaaPostProcess: Nullable<FxaaPostProcess>;
  109279. /**
  109280. * Represents the brightness threshold in order to configure the illuminated surfaces
  109281. */
  109282. brightThreshold: number;
  109283. /**
  109284. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  109285. */
  109286. blurWidth: number;
  109287. /**
  109288. * Sets if the blur for highlighted surfaces must be only horizontal
  109289. */
  109290. horizontalBlur: boolean;
  109291. /**
  109292. * Sets the overall exposure used by the pipeline
  109293. */
  109294. exposure: number;
  109295. /**
  109296. * Texture used typically to simulate "dirty" on camera lens
  109297. */
  109298. lensTexture: Nullable<Texture>;
  109299. /**
  109300. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  109301. */
  109302. volumetricLightCoefficient: number;
  109303. /**
  109304. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  109305. */
  109306. volumetricLightPower: number;
  109307. /**
  109308. * Used the set the blur intensity to smooth the volumetric lights
  109309. */
  109310. volumetricLightBlurScale: number;
  109311. /**
  109312. * Light (spot or directional) used to generate the volumetric lights rays
  109313. * The source light must have a shadow generate so the pipeline can get its
  109314. * depth map
  109315. */
  109316. sourceLight: Nullable<SpotLight | DirectionalLight>;
  109317. /**
  109318. * For eye adaptation, represents the minimum luminance the eye can see
  109319. */
  109320. hdrMinimumLuminance: number;
  109321. /**
  109322. * For eye adaptation, represents the decrease luminance speed
  109323. */
  109324. hdrDecreaseRate: number;
  109325. /**
  109326. * For eye adaptation, represents the increase luminance speed
  109327. */
  109328. hdrIncreaseRate: number;
  109329. /**
  109330. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  109331. */
  109332. lensColorTexture: Nullable<Texture>;
  109333. /**
  109334. * The overall strengh for the lens flare effect
  109335. */
  109336. lensFlareStrength: number;
  109337. /**
  109338. * Dispersion coefficient for lens flare ghosts
  109339. */
  109340. lensFlareGhostDispersal: number;
  109341. /**
  109342. * Main lens flare halo width
  109343. */
  109344. lensFlareHaloWidth: number;
  109345. /**
  109346. * Based on the lens distortion effect, defines how much the lens flare result
  109347. * is distorted
  109348. */
  109349. lensFlareDistortionStrength: number;
  109350. /**
  109351. * Lens star texture must be used to simulate rays on the flares and is available
  109352. * in the documentation
  109353. */
  109354. lensStarTexture: Nullable<Texture>;
  109355. /**
  109356. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  109357. * flare effect by taking account of the dirt texture
  109358. */
  109359. lensFlareDirtTexture: Nullable<Texture>;
  109360. /**
  109361. * Represents the focal length for the depth of field effect
  109362. */
  109363. depthOfFieldDistance: number;
  109364. /**
  109365. * Represents the blur intensity for the blurred part of the depth of field effect
  109366. */
  109367. depthOfFieldBlurWidth: number;
  109368. /**
  109369. * For motion blur, defines how much the image is blurred by the movement
  109370. */
  109371. motionStrength: number;
  109372. /**
  109373. * List of animations for the pipeline (IAnimatable implementation)
  109374. */
  109375. animations: Animation[];
  109376. /**
  109377. * Private members
  109378. */
  109379. private _scene;
  109380. private _currentDepthOfFieldSource;
  109381. private _basePostProcess;
  109382. private _hdrCurrentLuminance;
  109383. private _floatTextureType;
  109384. private _ratio;
  109385. private _bloomEnabled;
  109386. private _depthOfFieldEnabled;
  109387. private _vlsEnabled;
  109388. private _lensFlareEnabled;
  109389. private _hdrEnabled;
  109390. private _motionBlurEnabled;
  109391. private _fxaaEnabled;
  109392. private _motionBlurSamples;
  109393. private _volumetricLightStepsCount;
  109394. private _samples;
  109395. /**
  109396. * @ignore
  109397. * Specifies if the bloom pipeline is enabled
  109398. */
  109399. BloomEnabled: boolean;
  109400. /**
  109401. * @ignore
  109402. * Specifies if the depth of field pipeline is enabed
  109403. */
  109404. DepthOfFieldEnabled: boolean;
  109405. /**
  109406. * @ignore
  109407. * Specifies if the lens flare pipeline is enabed
  109408. */
  109409. LensFlareEnabled: boolean;
  109410. /**
  109411. * @ignore
  109412. * Specifies if the HDR pipeline is enabled
  109413. */
  109414. HDREnabled: boolean;
  109415. /**
  109416. * @ignore
  109417. * Specifies if the volumetric lights scattering effect is enabled
  109418. */
  109419. VLSEnabled: boolean;
  109420. /**
  109421. * @ignore
  109422. * Specifies if the motion blur effect is enabled
  109423. */
  109424. MotionBlurEnabled: boolean;
  109425. /**
  109426. * Specifies if anti-aliasing is enabled
  109427. */
  109428. fxaaEnabled: boolean;
  109429. /**
  109430. * Specifies the number of steps used to calculate the volumetric lights
  109431. * Typically in interval [50, 200]
  109432. */
  109433. volumetricLightStepsCount: number;
  109434. /**
  109435. * Specifies the number of samples used for the motion blur effect
  109436. * Typically in interval [16, 64]
  109437. */
  109438. motionBlurSamples: number;
  109439. /**
  109440. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109441. */
  109442. samples: number;
  109443. /**
  109444. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109445. * @constructor
  109446. * @param name The rendering pipeline name
  109447. * @param scene The scene linked to this pipeline
  109448. * @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)
  109449. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  109450. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109451. */
  109452. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  109453. private _buildPipeline;
  109454. private _createDownSampleX4PostProcess;
  109455. private _createBrightPassPostProcess;
  109456. private _createBlurPostProcesses;
  109457. private _createTextureAdderPostProcess;
  109458. private _createVolumetricLightPostProcess;
  109459. private _createLuminancePostProcesses;
  109460. private _createHdrPostProcess;
  109461. private _createLensFlarePostProcess;
  109462. private _createDepthOfFieldPostProcess;
  109463. private _createMotionBlurPostProcess;
  109464. private _getDepthTexture;
  109465. private _disposePostProcesses;
  109466. /**
  109467. * Dispose of the pipeline and stop all post processes
  109468. */
  109469. dispose(): void;
  109470. /**
  109471. * Serialize the rendering pipeline (Used when exporting)
  109472. * @returns the serialized object
  109473. */
  109474. serialize(): any;
  109475. /**
  109476. * Parse the serialized pipeline
  109477. * @param source Source pipeline.
  109478. * @param scene The scene to load the pipeline to.
  109479. * @param rootUrl The URL of the serialized pipeline.
  109480. * @returns An instantiated pipeline from the serialized object.
  109481. */
  109482. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  109483. /**
  109484. * Luminance steps
  109485. */
  109486. static LuminanceSteps: number;
  109487. }
  109488. }
  109489. declare module BABYLON {
  109490. /**
  109491. * PostProcessRenderPipelineManager class
  109492. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109493. */
  109494. export class PostProcessRenderPipelineManager {
  109495. private _renderPipelines;
  109496. /**
  109497. * Initializes a PostProcessRenderPipelineManager
  109498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109499. */
  109500. constructor();
  109501. /**
  109502. * Gets the list of supported render pipelines
  109503. */
  109504. readonly supportedPipelines: PostProcessRenderPipeline[];
  109505. /**
  109506. * Adds a pipeline to the manager
  109507. * @param renderPipeline The pipeline to add
  109508. */
  109509. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  109510. /**
  109511. * Attaches a camera to the pipeline
  109512. * @param renderPipelineName The name of the pipeline to attach to
  109513. * @param cameras the camera to attach
  109514. * @param unique if the camera can be attached multiple times to the pipeline
  109515. */
  109516. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  109517. /**
  109518. * Detaches a camera from the pipeline
  109519. * @param renderPipelineName The name of the pipeline to detach from
  109520. * @param cameras the camera to detach
  109521. */
  109522. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  109523. /**
  109524. * Enables an effect by name on a pipeline
  109525. * @param renderPipelineName the name of the pipeline to enable the effect in
  109526. * @param renderEffectName the name of the effect to enable
  109527. * @param cameras the cameras that the effect should be enabled on
  109528. */
  109529. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109530. /**
  109531. * Disables an effect by name on a pipeline
  109532. * @param renderPipelineName the name of the pipeline to disable the effect in
  109533. * @param renderEffectName the name of the effect to disable
  109534. * @param cameras the cameras that the effect should be disabled on
  109535. */
  109536. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109537. /**
  109538. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  109539. */
  109540. update(): void;
  109541. /** @hidden */
  109542. _rebuild(): void;
  109543. /**
  109544. * Disposes of the manager and pipelines
  109545. */
  109546. dispose(): void;
  109547. }
  109548. }
  109549. declare module BABYLON {
  109550. interface Scene {
  109551. /** @hidden (Backing field) */
  109552. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109553. /**
  109554. * Gets the postprocess render pipeline manager
  109555. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109556. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109557. */
  109558. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109559. }
  109560. /**
  109561. * Defines the Render Pipeline scene component responsible to rendering pipelines
  109562. */
  109563. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  109564. /**
  109565. * The component name helpfull to identify the component in the list of scene components.
  109566. */
  109567. readonly name: string;
  109568. /**
  109569. * The scene the component belongs to.
  109570. */
  109571. scene: Scene;
  109572. /**
  109573. * Creates a new instance of the component for the given scene
  109574. * @param scene Defines the scene to register the component in
  109575. */
  109576. constructor(scene: Scene);
  109577. /**
  109578. * Registers the component in a given scene
  109579. */
  109580. register(): void;
  109581. /**
  109582. * Rebuilds the elements related to this component in case of
  109583. * context lost for instance.
  109584. */
  109585. rebuild(): void;
  109586. /**
  109587. * Disposes the component and the associated ressources
  109588. */
  109589. dispose(): void;
  109590. private _gatherRenderTargets;
  109591. }
  109592. }
  109593. declare module BABYLON {
  109594. /** @hidden */
  109595. export var tonemapPixelShader: {
  109596. name: string;
  109597. shader: string;
  109598. };
  109599. }
  109600. declare module BABYLON {
  109601. /** Defines operator used for tonemapping */
  109602. export enum TonemappingOperator {
  109603. /** Hable */
  109604. Hable = 0,
  109605. /** Reinhard */
  109606. Reinhard = 1,
  109607. /** HejiDawson */
  109608. HejiDawson = 2,
  109609. /** Photographic */
  109610. Photographic = 3
  109611. }
  109612. /**
  109613. * Defines a post process to apply tone mapping
  109614. */
  109615. export class TonemapPostProcess extends PostProcess {
  109616. private _operator;
  109617. /** Defines the required exposure adjustement */
  109618. exposureAdjustment: number;
  109619. /**
  109620. * Creates a new TonemapPostProcess
  109621. * @param name defines the name of the postprocess
  109622. * @param _operator defines the operator to use
  109623. * @param exposureAdjustment defines the required exposure adjustement
  109624. * @param camera defines the camera to use (can be null)
  109625. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  109626. * @param engine defines the hosting engine (can be ignore if camera is set)
  109627. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109628. */
  109629. constructor(name: string, _operator: TonemappingOperator,
  109630. /** Defines the required exposure adjustement */
  109631. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  109632. }
  109633. }
  109634. declare module BABYLON {
  109635. /** @hidden */
  109636. export var depthVertexShader: {
  109637. name: string;
  109638. shader: string;
  109639. };
  109640. }
  109641. declare module BABYLON {
  109642. /** @hidden */
  109643. export var volumetricLightScatteringPixelShader: {
  109644. name: string;
  109645. shader: string;
  109646. };
  109647. }
  109648. declare module BABYLON {
  109649. /** @hidden */
  109650. export var volumetricLightScatteringPassPixelShader: {
  109651. name: string;
  109652. shader: string;
  109653. };
  109654. }
  109655. declare module BABYLON {
  109656. /**
  109657. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  109658. */
  109659. export class VolumetricLightScatteringPostProcess extends PostProcess {
  109660. private _volumetricLightScatteringPass;
  109661. private _volumetricLightScatteringRTT;
  109662. private _viewPort;
  109663. private _screenCoordinates;
  109664. private _cachedDefines;
  109665. /**
  109666. * If not undefined, the mesh position is computed from the attached node position
  109667. */
  109668. attachedNode: {
  109669. position: Vector3;
  109670. };
  109671. /**
  109672. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  109673. */
  109674. customMeshPosition: Vector3;
  109675. /**
  109676. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  109677. */
  109678. useCustomMeshPosition: boolean;
  109679. /**
  109680. * If the post-process should inverse the light scattering direction
  109681. */
  109682. invert: boolean;
  109683. /**
  109684. * The internal mesh used by the post-process
  109685. */
  109686. mesh: Mesh;
  109687. /**
  109688. * @hidden
  109689. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  109690. */
  109691. useDiffuseColor: boolean;
  109692. /**
  109693. * Array containing the excluded meshes not rendered in the internal pass
  109694. */
  109695. excludedMeshes: AbstractMesh[];
  109696. /**
  109697. * Controls the overall intensity of the post-process
  109698. */
  109699. exposure: number;
  109700. /**
  109701. * Dissipates each sample's contribution in range [0, 1]
  109702. */
  109703. decay: number;
  109704. /**
  109705. * Controls the overall intensity of each sample
  109706. */
  109707. weight: number;
  109708. /**
  109709. * Controls the density of each sample
  109710. */
  109711. density: number;
  109712. /**
  109713. * @constructor
  109714. * @param name The post-process name
  109715. * @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)
  109716. * @param camera The camera that the post-process will be attached to
  109717. * @param mesh The mesh used to create the light scattering
  109718. * @param samples The post-process quality, default 100
  109719. * @param samplingModeThe post-process filtering mode
  109720. * @param engine The babylon engine
  109721. * @param reusable If the post-process is reusable
  109722. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  109723. */
  109724. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  109725. /**
  109726. * Returns the string "VolumetricLightScatteringPostProcess"
  109727. * @returns "VolumetricLightScatteringPostProcess"
  109728. */
  109729. getClassName(): string;
  109730. private _isReady;
  109731. /**
  109732. * Sets the new light position for light scattering effect
  109733. * @param position The new custom light position
  109734. */
  109735. setCustomMeshPosition(position: Vector3): void;
  109736. /**
  109737. * Returns the light position for light scattering effect
  109738. * @return Vector3 The custom light position
  109739. */
  109740. getCustomMeshPosition(): Vector3;
  109741. /**
  109742. * Disposes the internal assets and detaches the post-process from the camera
  109743. */
  109744. dispose(camera: Camera): void;
  109745. /**
  109746. * Returns the render target texture used by the post-process
  109747. * @return the render target texture used by the post-process
  109748. */
  109749. getPass(): RenderTargetTexture;
  109750. private _meshExcluded;
  109751. private _createPass;
  109752. private _updateMeshScreenCoordinates;
  109753. /**
  109754. * Creates a default mesh for the Volumeric Light Scattering post-process
  109755. * @param name The mesh name
  109756. * @param scene The scene where to create the mesh
  109757. * @return the default mesh
  109758. */
  109759. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  109760. }
  109761. }
  109762. declare module BABYLON {
  109763. interface Scene {
  109764. /** @hidden (Backing field) */
  109765. _boundingBoxRenderer: BoundingBoxRenderer;
  109766. /** @hidden (Backing field) */
  109767. _forceShowBoundingBoxes: boolean;
  109768. /**
  109769. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  109770. */
  109771. forceShowBoundingBoxes: boolean;
  109772. /**
  109773. * Gets the bounding box renderer associated with the scene
  109774. * @returns a BoundingBoxRenderer
  109775. */
  109776. getBoundingBoxRenderer(): BoundingBoxRenderer;
  109777. }
  109778. interface AbstractMesh {
  109779. /** @hidden (Backing field) */
  109780. _showBoundingBox: boolean;
  109781. /**
  109782. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  109783. */
  109784. showBoundingBox: boolean;
  109785. }
  109786. /**
  109787. * Component responsible of rendering the bounding box of the meshes in a scene.
  109788. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  109789. */
  109790. export class BoundingBoxRenderer implements ISceneComponent {
  109791. /**
  109792. * The component name helpfull to identify the component in the list of scene components.
  109793. */
  109794. readonly name: string;
  109795. /**
  109796. * The scene the component belongs to.
  109797. */
  109798. scene: Scene;
  109799. /**
  109800. * Color of the bounding box lines placed in front of an object
  109801. */
  109802. frontColor: Color3;
  109803. /**
  109804. * Color of the bounding box lines placed behind an object
  109805. */
  109806. backColor: Color3;
  109807. /**
  109808. * Defines if the renderer should show the back lines or not
  109809. */
  109810. showBackLines: boolean;
  109811. /**
  109812. * @hidden
  109813. */
  109814. renderList: SmartArray<BoundingBox>;
  109815. private _colorShader;
  109816. private _vertexBuffers;
  109817. private _indexBuffer;
  109818. /**
  109819. * Instantiates a new bounding box renderer in a scene.
  109820. * @param scene the scene the renderer renders in
  109821. */
  109822. constructor(scene: Scene);
  109823. /**
  109824. * Registers the component in a given scene
  109825. */
  109826. register(): void;
  109827. private _evaluateSubMesh;
  109828. private _activeMesh;
  109829. private _prepareRessources;
  109830. private _createIndexBuffer;
  109831. /**
  109832. * Rebuilds the elements related to this component in case of
  109833. * context lost for instance.
  109834. */
  109835. rebuild(): void;
  109836. /**
  109837. * @hidden
  109838. */
  109839. reset(): void;
  109840. /**
  109841. * Render the bounding boxes of a specific rendering group
  109842. * @param renderingGroupId defines the rendering group to render
  109843. */
  109844. render(renderingGroupId: number): void;
  109845. /**
  109846. * In case of occlusion queries, we can render the occlusion bounding box through this method
  109847. * @param mesh Define the mesh to render the occlusion bounding box for
  109848. */
  109849. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  109850. /**
  109851. * Dispose and release the resources attached to this renderer.
  109852. */
  109853. dispose(): void;
  109854. }
  109855. }
  109856. declare module BABYLON {
  109857. /** @hidden */
  109858. export var depthPixelShader: {
  109859. name: string;
  109860. shader: string;
  109861. };
  109862. }
  109863. declare module BABYLON {
  109864. /**
  109865. * This represents a depth renderer in Babylon.
  109866. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  109867. */
  109868. export class DepthRenderer {
  109869. private _scene;
  109870. private _depthMap;
  109871. private _effect;
  109872. private _cachedDefines;
  109873. private _camera;
  109874. /**
  109875. * Specifiess that the depth renderer will only be used within
  109876. * the camera it is created for.
  109877. * This can help forcing its rendering during the camera processing.
  109878. */
  109879. useOnlyInActiveCamera: boolean;
  109880. /** @hidden */
  109881. static _SceneComponentInitialization: (scene: Scene) => void;
  109882. /**
  109883. * Instantiates a depth renderer
  109884. * @param scene The scene the renderer belongs to
  109885. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  109886. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  109887. */
  109888. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  109889. /**
  109890. * Creates the depth rendering effect and checks if the effect is ready.
  109891. * @param subMesh The submesh to be used to render the depth map of
  109892. * @param useInstances If multiple world instances should be used
  109893. * @returns if the depth renderer is ready to render the depth map
  109894. */
  109895. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109896. /**
  109897. * Gets the texture which the depth map will be written to.
  109898. * @returns The depth map texture
  109899. */
  109900. getDepthMap(): RenderTargetTexture;
  109901. /**
  109902. * Disposes of the depth renderer.
  109903. */
  109904. dispose(): void;
  109905. }
  109906. }
  109907. declare module BABYLON {
  109908. interface Scene {
  109909. /** @hidden (Backing field) */
  109910. _depthRenderer: {
  109911. [id: string]: DepthRenderer;
  109912. };
  109913. /**
  109914. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  109915. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  109916. * @returns the created depth renderer
  109917. */
  109918. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  109919. /**
  109920. * Disables a depth renderer for a given camera
  109921. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  109922. */
  109923. disableDepthRenderer(camera?: Nullable<Camera>): void;
  109924. }
  109925. /**
  109926. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  109927. * in several rendering techniques.
  109928. */
  109929. export class DepthRendererSceneComponent implements ISceneComponent {
  109930. /**
  109931. * The component name helpfull to identify the component in the list of scene components.
  109932. */
  109933. readonly name: string;
  109934. /**
  109935. * The scene the component belongs to.
  109936. */
  109937. scene: Scene;
  109938. /**
  109939. * Creates a new instance of the component for the given scene
  109940. * @param scene Defines the scene to register the component in
  109941. */
  109942. constructor(scene: Scene);
  109943. /**
  109944. * Registers the component in a given scene
  109945. */
  109946. register(): void;
  109947. /**
  109948. * Rebuilds the elements related to this component in case of
  109949. * context lost for instance.
  109950. */
  109951. rebuild(): void;
  109952. /**
  109953. * Disposes the component and the associated ressources
  109954. */
  109955. dispose(): void;
  109956. private _gatherRenderTargets;
  109957. private _gatherActiveCameraRenderTargets;
  109958. }
  109959. }
  109960. declare module BABYLON {
  109961. interface Scene {
  109962. /** @hidden (Backing field) */
  109963. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109964. /**
  109965. * Gets or Sets the current geometry buffer associated to the scene.
  109966. */
  109967. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109968. /**
  109969. * Enables a GeometryBufferRender and associates it with the scene
  109970. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  109971. * @returns the GeometryBufferRenderer
  109972. */
  109973. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  109974. /**
  109975. * Disables the GeometryBufferRender associated with the scene
  109976. */
  109977. disableGeometryBufferRenderer(): void;
  109978. }
  109979. /**
  109980. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  109981. * in several rendering techniques.
  109982. */
  109983. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  109984. /**
  109985. * The component name helpful to identify the component in the list of scene components.
  109986. */
  109987. readonly name: string;
  109988. /**
  109989. * The scene the component belongs to.
  109990. */
  109991. scene: Scene;
  109992. /**
  109993. * Creates a new instance of the component for the given scene
  109994. * @param scene Defines the scene to register the component in
  109995. */
  109996. constructor(scene: Scene);
  109997. /**
  109998. * Registers the component in a given scene
  109999. */
  110000. register(): void;
  110001. /**
  110002. * Rebuilds the elements related to this component in case of
  110003. * context lost for instance.
  110004. */
  110005. rebuild(): void;
  110006. /**
  110007. * Disposes the component and the associated ressources
  110008. */
  110009. dispose(): void;
  110010. private _gatherRenderTargets;
  110011. }
  110012. }
  110013. declare module BABYLON {
  110014. /** @hidden */
  110015. export var outlinePixelShader: {
  110016. name: string;
  110017. shader: string;
  110018. };
  110019. }
  110020. declare module BABYLON {
  110021. /** @hidden */
  110022. export var outlineVertexShader: {
  110023. name: string;
  110024. shader: string;
  110025. };
  110026. }
  110027. declare module BABYLON {
  110028. interface Scene {
  110029. /** @hidden */
  110030. _outlineRenderer: OutlineRenderer;
  110031. /**
  110032. * Gets the outline renderer associated with the scene
  110033. * @returns a OutlineRenderer
  110034. */
  110035. getOutlineRenderer(): OutlineRenderer;
  110036. }
  110037. interface AbstractMesh {
  110038. /** @hidden (Backing field) */
  110039. _renderOutline: boolean;
  110040. /**
  110041. * Gets or sets a boolean indicating if the outline must be rendered as well
  110042. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  110043. */
  110044. renderOutline: boolean;
  110045. /** @hidden (Backing field) */
  110046. _renderOverlay: boolean;
  110047. /**
  110048. * Gets or sets a boolean indicating if the overlay must be rendered as well
  110049. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  110050. */
  110051. renderOverlay: boolean;
  110052. }
  110053. /**
  110054. * This class is responsible to draw bothe outline/overlay of meshes.
  110055. * It should not be used directly but through the available method on mesh.
  110056. */
  110057. export class OutlineRenderer implements ISceneComponent {
  110058. /**
  110059. * The name of the component. Each component must have a unique name.
  110060. */
  110061. name: string;
  110062. /**
  110063. * The scene the component belongs to.
  110064. */
  110065. scene: Scene;
  110066. /**
  110067. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  110068. */
  110069. zOffset: number;
  110070. private _engine;
  110071. private _effect;
  110072. private _cachedDefines;
  110073. private _savedDepthWrite;
  110074. /**
  110075. * Instantiates a new outline renderer. (There could be only one per scene).
  110076. * @param scene Defines the scene it belongs to
  110077. */
  110078. constructor(scene: Scene);
  110079. /**
  110080. * Register the component to one instance of a scene.
  110081. */
  110082. register(): void;
  110083. /**
  110084. * Rebuilds the elements related to this component in case of
  110085. * context lost for instance.
  110086. */
  110087. rebuild(): void;
  110088. /**
  110089. * Disposes the component and the associated ressources.
  110090. */
  110091. dispose(): void;
  110092. /**
  110093. * Renders the outline in the canvas.
  110094. * @param subMesh Defines the sumesh to render
  110095. * @param batch Defines the batch of meshes in case of instances
  110096. * @param useOverlay Defines if the rendering is for the overlay or the outline
  110097. */
  110098. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  110099. /**
  110100. * Returns whether or not the outline renderer is ready for a given submesh.
  110101. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  110102. * @param subMesh Defines the submesh to check readyness for
  110103. * @param useInstances Defines wheter wee are trying to render instances or not
  110104. * @returns true if ready otherwise false
  110105. */
  110106. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110107. private _beforeRenderingMesh;
  110108. private _afterRenderingMesh;
  110109. }
  110110. }
  110111. declare module BABYLON {
  110112. /**
  110113. * Defines the list of states available for a task inside a AssetsManager
  110114. */
  110115. export enum AssetTaskState {
  110116. /**
  110117. * Initialization
  110118. */
  110119. INIT = 0,
  110120. /**
  110121. * Running
  110122. */
  110123. RUNNING = 1,
  110124. /**
  110125. * Done
  110126. */
  110127. DONE = 2,
  110128. /**
  110129. * Error
  110130. */
  110131. ERROR = 3
  110132. }
  110133. /**
  110134. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  110135. */
  110136. export abstract class AbstractAssetTask {
  110137. /**
  110138. * Task name
  110139. */ name: string;
  110140. /**
  110141. * Callback called when the task is successful
  110142. */
  110143. onSuccess: (task: any) => void;
  110144. /**
  110145. * Callback called when the task is not successful
  110146. */
  110147. onError: (task: any, message?: string, exception?: any) => void;
  110148. /**
  110149. * Creates a new AssetsManager
  110150. * @param name defines the name of the task
  110151. */
  110152. constructor(
  110153. /**
  110154. * Task name
  110155. */ name: string);
  110156. private _isCompleted;
  110157. private _taskState;
  110158. private _errorObject;
  110159. /**
  110160. * Get if the task is completed
  110161. */
  110162. readonly isCompleted: boolean;
  110163. /**
  110164. * Gets the current state of the task
  110165. */
  110166. readonly taskState: AssetTaskState;
  110167. /**
  110168. * Gets the current error object (if task is in error)
  110169. */
  110170. readonly errorObject: {
  110171. message?: string;
  110172. exception?: any;
  110173. };
  110174. /**
  110175. * Internal only
  110176. * @hidden
  110177. */
  110178. _setErrorObject(message?: string, exception?: any): void;
  110179. /**
  110180. * Execute the current task
  110181. * @param scene defines the scene where you want your assets to be loaded
  110182. * @param onSuccess is a callback called when the task is successfully executed
  110183. * @param onError is a callback called if an error occurs
  110184. */
  110185. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110186. /**
  110187. * Execute the current task
  110188. * @param scene defines the scene where you want your assets to be loaded
  110189. * @param onSuccess is a callback called when the task is successfully executed
  110190. * @param onError is a callback called if an error occurs
  110191. */
  110192. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110193. /**
  110194. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  110195. * This can be used with failed tasks that have the reason for failure fixed.
  110196. */
  110197. reset(): void;
  110198. private onErrorCallback;
  110199. private onDoneCallback;
  110200. }
  110201. /**
  110202. * Define the interface used by progress events raised during assets loading
  110203. */
  110204. export interface IAssetsProgressEvent {
  110205. /**
  110206. * Defines the number of remaining tasks to process
  110207. */
  110208. remainingCount: number;
  110209. /**
  110210. * Defines the total number of tasks
  110211. */
  110212. totalCount: number;
  110213. /**
  110214. * Defines the task that was just processed
  110215. */
  110216. task: AbstractAssetTask;
  110217. }
  110218. /**
  110219. * Class used to share progress information about assets loading
  110220. */
  110221. export class AssetsProgressEvent implements IAssetsProgressEvent {
  110222. /**
  110223. * Defines the number of remaining tasks to process
  110224. */
  110225. remainingCount: number;
  110226. /**
  110227. * Defines the total number of tasks
  110228. */
  110229. totalCount: number;
  110230. /**
  110231. * Defines the task that was just processed
  110232. */
  110233. task: AbstractAssetTask;
  110234. /**
  110235. * Creates a AssetsProgressEvent
  110236. * @param remainingCount defines the number of remaining tasks to process
  110237. * @param totalCount defines the total number of tasks
  110238. * @param task defines the task that was just processed
  110239. */
  110240. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  110241. }
  110242. /**
  110243. * Define a task used by AssetsManager to load meshes
  110244. */
  110245. export class MeshAssetTask extends AbstractAssetTask {
  110246. /**
  110247. * Defines the name of the task
  110248. */
  110249. name: string;
  110250. /**
  110251. * Defines the list of mesh's names you want to load
  110252. */
  110253. meshesNames: any;
  110254. /**
  110255. * Defines the root url to use as a base to load your meshes and associated resources
  110256. */
  110257. rootUrl: string;
  110258. /**
  110259. * Defines the filename of the scene to load from
  110260. */
  110261. sceneFilename: string;
  110262. /**
  110263. * Gets the list of loaded meshes
  110264. */
  110265. loadedMeshes: Array<AbstractMesh>;
  110266. /**
  110267. * Gets the list of loaded particle systems
  110268. */
  110269. loadedParticleSystems: Array<IParticleSystem>;
  110270. /**
  110271. * Gets the list of loaded skeletons
  110272. */
  110273. loadedSkeletons: Array<Skeleton>;
  110274. /**
  110275. * Gets the list of loaded animation groups
  110276. */
  110277. loadedAnimationGroups: Array<AnimationGroup>;
  110278. /**
  110279. * Callback called when the task is successful
  110280. */
  110281. onSuccess: (task: MeshAssetTask) => void;
  110282. /**
  110283. * Callback called when the task is successful
  110284. */
  110285. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  110286. /**
  110287. * Creates a new MeshAssetTask
  110288. * @param name defines the name of the task
  110289. * @param meshesNames defines the list of mesh's names you want to load
  110290. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  110291. * @param sceneFilename defines the filename of the scene to load from
  110292. */
  110293. constructor(
  110294. /**
  110295. * Defines the name of the task
  110296. */
  110297. name: string,
  110298. /**
  110299. * Defines the list of mesh's names you want to load
  110300. */
  110301. meshesNames: any,
  110302. /**
  110303. * Defines the root url to use as a base to load your meshes and associated resources
  110304. */
  110305. rootUrl: string,
  110306. /**
  110307. * Defines the filename of the scene to load from
  110308. */
  110309. sceneFilename: string);
  110310. /**
  110311. * Execute the current task
  110312. * @param scene defines the scene where you want your assets to be loaded
  110313. * @param onSuccess is a callback called when the task is successfully executed
  110314. * @param onError is a callback called if an error occurs
  110315. */
  110316. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110317. }
  110318. /**
  110319. * Define a task used by AssetsManager to load text content
  110320. */
  110321. export class TextFileAssetTask extends AbstractAssetTask {
  110322. /**
  110323. * Defines the name of the task
  110324. */
  110325. name: string;
  110326. /**
  110327. * Defines the location of the file to load
  110328. */
  110329. url: string;
  110330. /**
  110331. * Gets the loaded text string
  110332. */
  110333. text: string;
  110334. /**
  110335. * Callback called when the task is successful
  110336. */
  110337. onSuccess: (task: TextFileAssetTask) => void;
  110338. /**
  110339. * Callback called when the task is successful
  110340. */
  110341. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  110342. /**
  110343. * Creates a new TextFileAssetTask object
  110344. * @param name defines the name of the task
  110345. * @param url defines the location of the file to load
  110346. */
  110347. constructor(
  110348. /**
  110349. * Defines the name of the task
  110350. */
  110351. name: string,
  110352. /**
  110353. * Defines the location of the file to load
  110354. */
  110355. url: string);
  110356. /**
  110357. * Execute the current task
  110358. * @param scene defines the scene where you want your assets to be loaded
  110359. * @param onSuccess is a callback called when the task is successfully executed
  110360. * @param onError is a callback called if an error occurs
  110361. */
  110362. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110363. }
  110364. /**
  110365. * Define a task used by AssetsManager to load binary data
  110366. */
  110367. export class BinaryFileAssetTask extends AbstractAssetTask {
  110368. /**
  110369. * Defines the name of the task
  110370. */
  110371. name: string;
  110372. /**
  110373. * Defines the location of the file to load
  110374. */
  110375. url: string;
  110376. /**
  110377. * Gets the lodaded data (as an array buffer)
  110378. */
  110379. data: ArrayBuffer;
  110380. /**
  110381. * Callback called when the task is successful
  110382. */
  110383. onSuccess: (task: BinaryFileAssetTask) => void;
  110384. /**
  110385. * Callback called when the task is successful
  110386. */
  110387. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  110388. /**
  110389. * Creates a new BinaryFileAssetTask object
  110390. * @param name defines the name of the new task
  110391. * @param url defines the location of the file to load
  110392. */
  110393. constructor(
  110394. /**
  110395. * Defines the name of the task
  110396. */
  110397. name: string,
  110398. /**
  110399. * Defines the location of the file to load
  110400. */
  110401. url: string);
  110402. /**
  110403. * Execute the current task
  110404. * @param scene defines the scene where you want your assets to be loaded
  110405. * @param onSuccess is a callback called when the task is successfully executed
  110406. * @param onError is a callback called if an error occurs
  110407. */
  110408. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110409. }
  110410. /**
  110411. * Define a task used by AssetsManager to load images
  110412. */
  110413. export class ImageAssetTask extends AbstractAssetTask {
  110414. /**
  110415. * Defines the name of the task
  110416. */
  110417. name: string;
  110418. /**
  110419. * Defines the location of the image to load
  110420. */
  110421. url: string;
  110422. /**
  110423. * Gets the loaded images
  110424. */
  110425. image: HTMLImageElement;
  110426. /**
  110427. * Callback called when the task is successful
  110428. */
  110429. onSuccess: (task: ImageAssetTask) => void;
  110430. /**
  110431. * Callback called when the task is successful
  110432. */
  110433. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  110434. /**
  110435. * Creates a new ImageAssetTask
  110436. * @param name defines the name of the task
  110437. * @param url defines the location of the image to load
  110438. */
  110439. constructor(
  110440. /**
  110441. * Defines the name of the task
  110442. */
  110443. name: string,
  110444. /**
  110445. * Defines the location of the image to load
  110446. */
  110447. url: string);
  110448. /**
  110449. * Execute the current task
  110450. * @param scene defines the scene where you want your assets to be loaded
  110451. * @param onSuccess is a callback called when the task is successfully executed
  110452. * @param onError is a callback called if an error occurs
  110453. */
  110454. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110455. }
  110456. /**
  110457. * Defines the interface used by texture loading tasks
  110458. */
  110459. export interface ITextureAssetTask<TEX extends BaseTexture> {
  110460. /**
  110461. * Gets the loaded texture
  110462. */
  110463. texture: TEX;
  110464. }
  110465. /**
  110466. * Define a task used by AssetsManager to load 2D textures
  110467. */
  110468. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  110469. /**
  110470. * Defines the name of the task
  110471. */
  110472. name: string;
  110473. /**
  110474. * Defines the location of the file to load
  110475. */
  110476. url: string;
  110477. /**
  110478. * Defines if mipmap should not be generated (default is false)
  110479. */
  110480. noMipmap?: boolean | undefined;
  110481. /**
  110482. * Defines if texture must be inverted on Y axis (default is false)
  110483. */
  110484. invertY?: boolean | undefined;
  110485. /**
  110486. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110487. */
  110488. samplingMode: number;
  110489. /**
  110490. * Gets the loaded texture
  110491. */
  110492. texture: Texture;
  110493. /**
  110494. * Callback called when the task is successful
  110495. */
  110496. onSuccess: (task: TextureAssetTask) => void;
  110497. /**
  110498. * Callback called when the task is successful
  110499. */
  110500. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  110501. /**
  110502. * Creates a new TextureAssetTask object
  110503. * @param name defines the name of the task
  110504. * @param url defines the location of the file to load
  110505. * @param noMipmap defines if mipmap should not be generated (default is false)
  110506. * @param invertY defines if texture must be inverted on Y axis (default is false)
  110507. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110508. */
  110509. constructor(
  110510. /**
  110511. * Defines the name of the task
  110512. */
  110513. name: string,
  110514. /**
  110515. * Defines the location of the file to load
  110516. */
  110517. url: string,
  110518. /**
  110519. * Defines if mipmap should not be generated (default is false)
  110520. */
  110521. noMipmap?: boolean | undefined,
  110522. /**
  110523. * Defines if texture must be inverted on Y axis (default is false)
  110524. */
  110525. invertY?: boolean | undefined,
  110526. /**
  110527. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110528. */
  110529. samplingMode?: number);
  110530. /**
  110531. * Execute the current task
  110532. * @param scene defines the scene where you want your assets to be loaded
  110533. * @param onSuccess is a callback called when the task is successfully executed
  110534. * @param onError is a callback called if an error occurs
  110535. */
  110536. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110537. }
  110538. /**
  110539. * Define a task used by AssetsManager to load cube textures
  110540. */
  110541. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  110542. /**
  110543. * Defines the name of the task
  110544. */
  110545. name: string;
  110546. /**
  110547. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110548. */
  110549. url: string;
  110550. /**
  110551. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110552. */
  110553. extensions?: string[] | undefined;
  110554. /**
  110555. * Defines if mipmaps should not be generated (default is false)
  110556. */
  110557. noMipmap?: boolean | undefined;
  110558. /**
  110559. * Defines the explicit list of files (undefined by default)
  110560. */
  110561. files?: string[] | undefined;
  110562. /**
  110563. * Gets the loaded texture
  110564. */
  110565. texture: CubeTexture;
  110566. /**
  110567. * Callback called when the task is successful
  110568. */
  110569. onSuccess: (task: CubeTextureAssetTask) => void;
  110570. /**
  110571. * Callback called when the task is successful
  110572. */
  110573. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  110574. /**
  110575. * Creates a new CubeTextureAssetTask
  110576. * @param name defines the name of the task
  110577. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110578. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110579. * @param noMipmap defines if mipmaps should not be generated (default is false)
  110580. * @param files defines the explicit list of files (undefined by default)
  110581. */
  110582. constructor(
  110583. /**
  110584. * Defines the name of the task
  110585. */
  110586. name: string,
  110587. /**
  110588. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110589. */
  110590. url: string,
  110591. /**
  110592. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110593. */
  110594. extensions?: string[] | undefined,
  110595. /**
  110596. * Defines if mipmaps should not be generated (default is false)
  110597. */
  110598. noMipmap?: boolean | undefined,
  110599. /**
  110600. * Defines the explicit list of files (undefined by default)
  110601. */
  110602. files?: string[] | undefined);
  110603. /**
  110604. * Execute the current task
  110605. * @param scene defines the scene where you want your assets to be loaded
  110606. * @param onSuccess is a callback called when the task is successfully executed
  110607. * @param onError is a callback called if an error occurs
  110608. */
  110609. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110610. }
  110611. /**
  110612. * Define a task used by AssetsManager to load HDR cube textures
  110613. */
  110614. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  110615. /**
  110616. * Defines the name of the task
  110617. */
  110618. name: string;
  110619. /**
  110620. * Defines the location of the file to load
  110621. */
  110622. url: string;
  110623. /**
  110624. * Defines the desired size (the more it increases the longer the generation will be)
  110625. */
  110626. size: number;
  110627. /**
  110628. * Defines if mipmaps should not be generated (default is false)
  110629. */
  110630. noMipmap: boolean;
  110631. /**
  110632. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110633. */
  110634. generateHarmonics: boolean;
  110635. /**
  110636. * 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)
  110637. */
  110638. gammaSpace: boolean;
  110639. /**
  110640. * Internal Use Only
  110641. */
  110642. reserved: boolean;
  110643. /**
  110644. * Gets the loaded texture
  110645. */
  110646. texture: HDRCubeTexture;
  110647. /**
  110648. * Callback called when the task is successful
  110649. */
  110650. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  110651. /**
  110652. * Callback called when the task is successful
  110653. */
  110654. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  110655. /**
  110656. * Creates a new HDRCubeTextureAssetTask object
  110657. * @param name defines the name of the task
  110658. * @param url defines the location of the file to load
  110659. * @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.
  110660. * @param noMipmap defines if mipmaps should not be generated (default is false)
  110661. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110662. * @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)
  110663. * @param reserved Internal use only
  110664. */
  110665. constructor(
  110666. /**
  110667. * Defines the name of the task
  110668. */
  110669. name: string,
  110670. /**
  110671. * Defines the location of the file to load
  110672. */
  110673. url: string,
  110674. /**
  110675. * Defines the desired size (the more it increases the longer the generation will be)
  110676. */
  110677. size: number,
  110678. /**
  110679. * Defines if mipmaps should not be generated (default is false)
  110680. */
  110681. noMipmap?: boolean,
  110682. /**
  110683. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110684. */
  110685. generateHarmonics?: boolean,
  110686. /**
  110687. * 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)
  110688. */
  110689. gammaSpace?: boolean,
  110690. /**
  110691. * Internal Use Only
  110692. */
  110693. reserved?: boolean);
  110694. /**
  110695. * Execute the current task
  110696. * @param scene defines the scene where you want your assets to be loaded
  110697. * @param onSuccess is a callback called when the task is successfully executed
  110698. * @param onError is a callback called if an error occurs
  110699. */
  110700. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110701. }
  110702. /**
  110703. * This class can be used to easily import assets into a scene
  110704. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  110705. */
  110706. export class AssetsManager {
  110707. private _scene;
  110708. private _isLoading;
  110709. protected _tasks: AbstractAssetTask[];
  110710. protected _waitingTasksCount: number;
  110711. protected _totalTasksCount: number;
  110712. /**
  110713. * Callback called when all tasks are processed
  110714. */
  110715. onFinish: (tasks: AbstractAssetTask[]) => void;
  110716. /**
  110717. * Callback called when a task is successful
  110718. */
  110719. onTaskSuccess: (task: AbstractAssetTask) => void;
  110720. /**
  110721. * Callback called when a task had an error
  110722. */
  110723. onTaskError: (task: AbstractAssetTask) => void;
  110724. /**
  110725. * Callback called when a task is done (whatever the result is)
  110726. */
  110727. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  110728. /**
  110729. * Observable called when all tasks are processed
  110730. */
  110731. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  110732. /**
  110733. * Observable called when a task had an error
  110734. */
  110735. onTaskErrorObservable: Observable<AbstractAssetTask>;
  110736. /**
  110737. * Observable called when a task is successful
  110738. */
  110739. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  110740. /**
  110741. * Observable called when a task is done (whatever the result is)
  110742. */
  110743. onProgressObservable: Observable<IAssetsProgressEvent>;
  110744. /**
  110745. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  110746. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110747. */
  110748. useDefaultLoadingScreen: boolean;
  110749. /**
  110750. * Creates a new AssetsManager
  110751. * @param scene defines the scene to work on
  110752. */
  110753. constructor(scene: Scene);
  110754. /**
  110755. * Add a MeshAssetTask to the list of active tasks
  110756. * @param taskName defines the name of the new task
  110757. * @param meshesNames defines the name of meshes to load
  110758. * @param rootUrl defines the root url to use to locate files
  110759. * @param sceneFilename defines the filename of the scene file
  110760. * @returns a new MeshAssetTask object
  110761. */
  110762. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  110763. /**
  110764. * Add a TextFileAssetTask to the list of active tasks
  110765. * @param taskName defines the name of the new task
  110766. * @param url defines the url of the file to load
  110767. * @returns a new TextFileAssetTask object
  110768. */
  110769. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  110770. /**
  110771. * Add a BinaryFileAssetTask to the list of active tasks
  110772. * @param taskName defines the name of the new task
  110773. * @param url defines the url of the file to load
  110774. * @returns a new BinaryFileAssetTask object
  110775. */
  110776. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  110777. /**
  110778. * Add a ImageAssetTask to the list of active tasks
  110779. * @param taskName defines the name of the new task
  110780. * @param url defines the url of the file to load
  110781. * @returns a new ImageAssetTask object
  110782. */
  110783. addImageTask(taskName: string, url: string): ImageAssetTask;
  110784. /**
  110785. * Add a TextureAssetTask to the list of active tasks
  110786. * @param taskName defines the name of the new task
  110787. * @param url defines the url of the file to load
  110788. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110789. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  110790. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  110791. * @returns a new TextureAssetTask object
  110792. */
  110793. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  110794. /**
  110795. * Add a CubeTextureAssetTask to the list of active tasks
  110796. * @param taskName defines the name of the new task
  110797. * @param url defines the url of the file to load
  110798. * @param extensions defines the extension to use to load the cube map (can be null)
  110799. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110800. * @param files defines the list of files to load (can be null)
  110801. * @returns a new CubeTextureAssetTask object
  110802. */
  110803. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  110804. /**
  110805. *
  110806. * Add a HDRCubeTextureAssetTask to the list of active tasks
  110807. * @param taskName defines the name of the new task
  110808. * @param url defines the url of the file to load
  110809. * @param size defines the size you want for the cubemap (can be null)
  110810. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110811. * @param generateHarmonics defines if you want to automatically generate (true by default)
  110812. * @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)
  110813. * @param reserved Internal use only
  110814. * @returns a new HDRCubeTextureAssetTask object
  110815. */
  110816. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  110817. /**
  110818. * Remove a task from the assets manager.
  110819. * @param task the task to remove
  110820. */
  110821. removeTask(task: AbstractAssetTask): void;
  110822. private _decreaseWaitingTasksCount;
  110823. private _runTask;
  110824. /**
  110825. * Reset the AssetsManager and remove all tasks
  110826. * @return the current instance of the AssetsManager
  110827. */
  110828. reset(): AssetsManager;
  110829. /**
  110830. * Start the loading process
  110831. * @return the current instance of the AssetsManager
  110832. */
  110833. load(): AssetsManager;
  110834. }
  110835. }
  110836. declare module BABYLON {
  110837. /**
  110838. * Wrapper class for promise with external resolve and reject.
  110839. */
  110840. export class Deferred<T> {
  110841. /**
  110842. * The promise associated with this deferred object.
  110843. */
  110844. readonly promise: Promise<T>;
  110845. private _resolve;
  110846. private _reject;
  110847. /**
  110848. * The resolve method of the promise associated with this deferred object.
  110849. */
  110850. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  110851. /**
  110852. * The reject method of the promise associated with this deferred object.
  110853. */
  110854. readonly reject: (reason?: any) => void;
  110855. /**
  110856. * Constructor for this deferred object.
  110857. */
  110858. constructor();
  110859. }
  110860. }
  110861. declare module BABYLON {
  110862. /**
  110863. * Class used to help managing file picking and drag'n'drop
  110864. */
  110865. export class FilesInput {
  110866. /**
  110867. * List of files ready to be loaded
  110868. */
  110869. static readonly FilesToLoad: {
  110870. [key: string]: File;
  110871. };
  110872. /**
  110873. * Callback called when a file is processed
  110874. */
  110875. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  110876. private _engine;
  110877. private _currentScene;
  110878. private _sceneLoadedCallback;
  110879. private _progressCallback;
  110880. private _additionalRenderLoopLogicCallback;
  110881. private _textureLoadingCallback;
  110882. private _startingProcessingFilesCallback;
  110883. private _onReloadCallback;
  110884. private _errorCallback;
  110885. private _elementToMonitor;
  110886. private _sceneFileToLoad;
  110887. private _filesToLoad;
  110888. /**
  110889. * Creates a new FilesInput
  110890. * @param engine defines the rendering engine
  110891. * @param scene defines the hosting scene
  110892. * @param sceneLoadedCallback callback called when scene is loaded
  110893. * @param progressCallback callback called to track progress
  110894. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  110895. * @param textureLoadingCallback callback called when a texture is loading
  110896. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  110897. * @param onReloadCallback callback called when a reload is requested
  110898. * @param errorCallback callback call if an error occurs
  110899. */
  110900. 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);
  110901. private _dragEnterHandler;
  110902. private _dragOverHandler;
  110903. private _dropHandler;
  110904. /**
  110905. * Calls this function to listen to drag'n'drop events on a specific DOM element
  110906. * @param elementToMonitor defines the DOM element to track
  110907. */
  110908. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  110909. /**
  110910. * Release all associated resources
  110911. */
  110912. dispose(): void;
  110913. private renderFunction;
  110914. private drag;
  110915. private drop;
  110916. private _traverseFolder;
  110917. private _processFiles;
  110918. /**
  110919. * Load files from a drop event
  110920. * @param event defines the drop event to use as source
  110921. */
  110922. loadFiles(event: any): void;
  110923. private _processReload;
  110924. /**
  110925. * Reload the current scene from the loaded files
  110926. */
  110927. reload(): void;
  110928. }
  110929. }
  110930. declare module BABYLON {
  110931. /**
  110932. * Defines the root class used to create scene optimization to use with SceneOptimizer
  110933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110934. */
  110935. export class SceneOptimization {
  110936. /**
  110937. * Defines the priority of this optimization (0 by default which means first in the list)
  110938. */
  110939. priority: number;
  110940. /**
  110941. * Gets a string describing the action executed by the current optimization
  110942. * @returns description string
  110943. */
  110944. getDescription(): string;
  110945. /**
  110946. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110947. * @param scene defines the current scene where to apply this optimization
  110948. * @param optimizer defines the current optimizer
  110949. * @returns true if everything that can be done was applied
  110950. */
  110951. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110952. /**
  110953. * Creates the SceneOptimization object
  110954. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110955. * @param desc defines the description associated with the optimization
  110956. */
  110957. constructor(
  110958. /**
  110959. * Defines the priority of this optimization (0 by default which means first in the list)
  110960. */
  110961. priority?: number);
  110962. }
  110963. /**
  110964. * Defines an optimization used to reduce the size of render target textures
  110965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110966. */
  110967. export class TextureOptimization extends SceneOptimization {
  110968. /**
  110969. * Defines the priority of this optimization (0 by default which means first in the list)
  110970. */
  110971. priority: number;
  110972. /**
  110973. * 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
  110974. */
  110975. maximumSize: number;
  110976. /**
  110977. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  110978. */
  110979. step: number;
  110980. /**
  110981. * Gets a string describing the action executed by the current optimization
  110982. * @returns description string
  110983. */
  110984. getDescription(): string;
  110985. /**
  110986. * Creates the TextureOptimization object
  110987. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110988. * @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
  110989. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  110990. */
  110991. constructor(
  110992. /**
  110993. * Defines the priority of this optimization (0 by default which means first in the list)
  110994. */
  110995. priority?: number,
  110996. /**
  110997. * 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
  110998. */
  110999. maximumSize?: number,
  111000. /**
  111001. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111002. */
  111003. step?: number);
  111004. /**
  111005. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111006. * @param scene defines the current scene where to apply this optimization
  111007. * @param optimizer defines the current optimizer
  111008. * @returns true if everything that can be done was applied
  111009. */
  111010. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111011. }
  111012. /**
  111013. * Defines an optimization used to increase or decrease the rendering resolution
  111014. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111015. */
  111016. export class HardwareScalingOptimization extends SceneOptimization {
  111017. /**
  111018. * Defines the priority of this optimization (0 by default which means first in the list)
  111019. */
  111020. priority: number;
  111021. /**
  111022. * Defines the maximum scale to use (2 by default)
  111023. */
  111024. maximumScale: number;
  111025. /**
  111026. * Defines the step to use between two passes (0.5 by default)
  111027. */
  111028. step: number;
  111029. private _currentScale;
  111030. private _directionOffset;
  111031. /**
  111032. * Gets a string describing the action executed by the current optimization
  111033. * @return description string
  111034. */
  111035. getDescription(): string;
  111036. /**
  111037. * Creates the HardwareScalingOptimization object
  111038. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111039. * @param maximumScale defines the maximum scale to use (2 by default)
  111040. * @param step defines the step to use between two passes (0.5 by default)
  111041. */
  111042. constructor(
  111043. /**
  111044. * Defines the priority of this optimization (0 by default which means first in the list)
  111045. */
  111046. priority?: number,
  111047. /**
  111048. * Defines the maximum scale to use (2 by default)
  111049. */
  111050. maximumScale?: number,
  111051. /**
  111052. * Defines the step to use between two passes (0.5 by default)
  111053. */
  111054. step?: number);
  111055. /**
  111056. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111057. * @param scene defines the current scene where to apply this optimization
  111058. * @param optimizer defines the current optimizer
  111059. * @returns true if everything that can be done was applied
  111060. */
  111061. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111062. }
  111063. /**
  111064. * Defines an optimization used to remove shadows
  111065. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111066. */
  111067. export class ShadowsOptimization extends SceneOptimization {
  111068. /**
  111069. * Gets a string describing the action executed by the current optimization
  111070. * @return description string
  111071. */
  111072. getDescription(): string;
  111073. /**
  111074. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111075. * @param scene defines the current scene where to apply this optimization
  111076. * @param optimizer defines the current optimizer
  111077. * @returns true if everything that can be done was applied
  111078. */
  111079. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111080. }
  111081. /**
  111082. * Defines an optimization used to turn post-processes off
  111083. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111084. */
  111085. export class PostProcessesOptimization extends SceneOptimization {
  111086. /**
  111087. * Gets a string describing the action executed by the current optimization
  111088. * @return description string
  111089. */
  111090. getDescription(): string;
  111091. /**
  111092. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111093. * @param scene defines the current scene where to apply this optimization
  111094. * @param optimizer defines the current optimizer
  111095. * @returns true if everything that can be done was applied
  111096. */
  111097. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111098. }
  111099. /**
  111100. * Defines an optimization used to turn lens flares off
  111101. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111102. */
  111103. export class LensFlaresOptimization extends SceneOptimization {
  111104. /**
  111105. * Gets a string describing the action executed by the current optimization
  111106. * @return description string
  111107. */
  111108. getDescription(): string;
  111109. /**
  111110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111111. * @param scene defines the current scene where to apply this optimization
  111112. * @param optimizer defines the current optimizer
  111113. * @returns true if everything that can be done was applied
  111114. */
  111115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111116. }
  111117. /**
  111118. * Defines an optimization based on user defined callback.
  111119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111120. */
  111121. export class CustomOptimization extends SceneOptimization {
  111122. /**
  111123. * Callback called to apply the custom optimization.
  111124. */
  111125. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  111126. /**
  111127. * Callback called to get custom description
  111128. */
  111129. onGetDescription: () => string;
  111130. /**
  111131. * Gets a string describing the action executed by the current optimization
  111132. * @returns description string
  111133. */
  111134. getDescription(): string;
  111135. /**
  111136. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111137. * @param scene defines the current scene where to apply this optimization
  111138. * @param optimizer defines the current optimizer
  111139. * @returns true if everything that can be done was applied
  111140. */
  111141. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111142. }
  111143. /**
  111144. * Defines an optimization used to turn particles off
  111145. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111146. */
  111147. export class ParticlesOptimization extends SceneOptimization {
  111148. /**
  111149. * Gets a string describing the action executed by the current optimization
  111150. * @return description string
  111151. */
  111152. getDescription(): string;
  111153. /**
  111154. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111155. * @param scene defines the current scene where to apply this optimization
  111156. * @param optimizer defines the current optimizer
  111157. * @returns true if everything that can be done was applied
  111158. */
  111159. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111160. }
  111161. /**
  111162. * Defines an optimization used to turn render targets off
  111163. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111164. */
  111165. export class RenderTargetsOptimization extends SceneOptimization {
  111166. /**
  111167. * Gets a string describing the action executed by the current optimization
  111168. * @return description string
  111169. */
  111170. getDescription(): string;
  111171. /**
  111172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111173. * @param scene defines the current scene where to apply this optimization
  111174. * @param optimizer defines the current optimizer
  111175. * @returns true if everything that can be done was applied
  111176. */
  111177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111178. }
  111179. /**
  111180. * Defines an optimization used to merge meshes with compatible materials
  111181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111182. */
  111183. export class MergeMeshesOptimization extends SceneOptimization {
  111184. private static _UpdateSelectionTree;
  111185. /**
  111186. * Gets or sets a boolean which defines if optimization octree has to be updated
  111187. */
  111188. /**
  111189. * Gets or sets a boolean which defines if optimization octree has to be updated
  111190. */
  111191. static UpdateSelectionTree: boolean;
  111192. /**
  111193. * Gets a string describing the action executed by the current optimization
  111194. * @return description string
  111195. */
  111196. getDescription(): string;
  111197. private _canBeMerged;
  111198. /**
  111199. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111200. * @param scene defines the current scene where to apply this optimization
  111201. * @param optimizer defines the current optimizer
  111202. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  111203. * @returns true if everything that can be done was applied
  111204. */
  111205. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  111206. }
  111207. /**
  111208. * Defines a list of options used by SceneOptimizer
  111209. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111210. */
  111211. export class SceneOptimizerOptions {
  111212. /**
  111213. * Defines the target frame rate to reach (60 by default)
  111214. */
  111215. targetFrameRate: number;
  111216. /**
  111217. * Defines the interval between two checkes (2000ms by default)
  111218. */
  111219. trackerDuration: number;
  111220. /**
  111221. * Gets the list of optimizations to apply
  111222. */
  111223. optimizations: SceneOptimization[];
  111224. /**
  111225. * Creates a new list of options used by SceneOptimizer
  111226. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  111227. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  111228. */
  111229. constructor(
  111230. /**
  111231. * Defines the target frame rate to reach (60 by default)
  111232. */
  111233. targetFrameRate?: number,
  111234. /**
  111235. * Defines the interval between two checkes (2000ms by default)
  111236. */
  111237. trackerDuration?: number);
  111238. /**
  111239. * Add a new optimization
  111240. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  111241. * @returns the current SceneOptimizerOptions
  111242. */
  111243. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  111244. /**
  111245. * Add a new custom optimization
  111246. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  111247. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  111248. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111249. * @returns the current SceneOptimizerOptions
  111250. */
  111251. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  111252. /**
  111253. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  111254. * @param targetFrameRate defines the target frame rate (60 by default)
  111255. * @returns a SceneOptimizerOptions object
  111256. */
  111257. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111258. /**
  111259. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  111260. * @param targetFrameRate defines the target frame rate (60 by default)
  111261. * @returns a SceneOptimizerOptions object
  111262. */
  111263. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111264. /**
  111265. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  111266. * @param targetFrameRate defines the target frame rate (60 by default)
  111267. * @returns a SceneOptimizerOptions object
  111268. */
  111269. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111270. }
  111271. /**
  111272. * Class used to run optimizations in order to reach a target frame rate
  111273. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111274. */
  111275. export class SceneOptimizer implements IDisposable {
  111276. private _isRunning;
  111277. private _options;
  111278. private _scene;
  111279. private _currentPriorityLevel;
  111280. private _targetFrameRate;
  111281. private _trackerDuration;
  111282. private _currentFrameRate;
  111283. private _sceneDisposeObserver;
  111284. private _improvementMode;
  111285. /**
  111286. * Defines an observable called when the optimizer reaches the target frame rate
  111287. */
  111288. onSuccessObservable: Observable<SceneOptimizer>;
  111289. /**
  111290. * Defines an observable called when the optimizer enables an optimization
  111291. */
  111292. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  111293. /**
  111294. * Defines an observable called when the optimizer is not able to reach the target frame rate
  111295. */
  111296. onFailureObservable: Observable<SceneOptimizer>;
  111297. /**
  111298. * Gets a boolean indicating if the optimizer is in improvement mode
  111299. */
  111300. readonly isInImprovementMode: boolean;
  111301. /**
  111302. * Gets the current priority level (0 at start)
  111303. */
  111304. readonly currentPriorityLevel: number;
  111305. /**
  111306. * Gets the current frame rate checked by the SceneOptimizer
  111307. */
  111308. readonly currentFrameRate: number;
  111309. /**
  111310. * Gets or sets the current target frame rate (60 by default)
  111311. */
  111312. /**
  111313. * Gets or sets the current target frame rate (60 by default)
  111314. */
  111315. targetFrameRate: number;
  111316. /**
  111317. * Gets or sets the current interval between two checks (every 2000ms by default)
  111318. */
  111319. /**
  111320. * Gets or sets the current interval between two checks (every 2000ms by default)
  111321. */
  111322. trackerDuration: number;
  111323. /**
  111324. * Gets the list of active optimizations
  111325. */
  111326. readonly optimizations: SceneOptimization[];
  111327. /**
  111328. * Creates a new SceneOptimizer
  111329. * @param scene defines the scene to work on
  111330. * @param options defines the options to use with the SceneOptimizer
  111331. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  111332. * @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)
  111333. */
  111334. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  111335. /**
  111336. * Stops the current optimizer
  111337. */
  111338. stop(): void;
  111339. /**
  111340. * Reset the optimizer to initial step (current priority level = 0)
  111341. */
  111342. reset(): void;
  111343. /**
  111344. * Start the optimizer. By default it will try to reach a specific framerate
  111345. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  111346. */
  111347. start(): void;
  111348. private _checkCurrentState;
  111349. /**
  111350. * Release all resources
  111351. */
  111352. dispose(): void;
  111353. /**
  111354. * Helper function to create a SceneOptimizer with one single line of code
  111355. * @param scene defines the scene to work on
  111356. * @param options defines the options to use with the SceneOptimizer
  111357. * @param onSuccess defines a callback to call on success
  111358. * @param onFailure defines a callback to call on failure
  111359. * @returns the new SceneOptimizer object
  111360. */
  111361. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  111362. }
  111363. }
  111364. declare module BABYLON {
  111365. /**
  111366. * Class used to serialize a scene into a string
  111367. */
  111368. export class SceneSerializer {
  111369. /**
  111370. * Clear cache used by a previous serialization
  111371. */
  111372. static ClearCache(): void;
  111373. /**
  111374. * Serialize a scene into a JSON compatible object
  111375. * @param scene defines the scene to serialize
  111376. * @returns a JSON compatible object
  111377. */
  111378. static Serialize(scene: Scene): any;
  111379. /**
  111380. * Serialize a mesh into a JSON compatible object
  111381. * @param toSerialize defines the mesh to serialize
  111382. * @param withParents defines if parents must be serialized as well
  111383. * @param withChildren defines if children must be serialized as well
  111384. * @returns a JSON compatible object
  111385. */
  111386. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  111387. }
  111388. }
  111389. declare module BABYLON {
  111390. /**
  111391. * This represents the different options avilable for the video capture.
  111392. */
  111393. export interface VideoRecorderOptions {
  111394. /** Defines the mime type of the video */
  111395. mimeType: string;
  111396. /** Defines the video the video should be recorded at */
  111397. fps: number;
  111398. /** Defines the chunk size for the recording data */
  111399. recordChunckSize: number;
  111400. /** The audio tracks to attach to the record */
  111401. audioTracks?: MediaStreamTrack[];
  111402. }
  111403. /**
  111404. * This can helps recording videos from BabylonJS.
  111405. * This is based on the available WebRTC functionalities of the browser.
  111406. *
  111407. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  111408. */
  111409. export class VideoRecorder {
  111410. private static readonly _defaultOptions;
  111411. /**
  111412. * Returns wehther or not the VideoRecorder is available in your browser.
  111413. * @param engine Defines the Babylon Engine to check the support for
  111414. * @returns true if supported otherwise false
  111415. */
  111416. static IsSupported(engine: Engine): boolean;
  111417. private readonly _options;
  111418. private _canvas;
  111419. private _mediaRecorder;
  111420. private _recordedChunks;
  111421. private _fileName;
  111422. private _resolve;
  111423. private _reject;
  111424. /**
  111425. * True wether a recording is already in progress.
  111426. */
  111427. readonly isRecording: boolean;
  111428. /**
  111429. * Create a new VideoCapture object which can help converting what you see in Babylon to
  111430. * a video file.
  111431. * @param engine Defines the BabylonJS Engine you wish to record
  111432. * @param options Defines options that can be used to customized the capture
  111433. */
  111434. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  111435. /**
  111436. * Stops the current recording before the default capture timeout passed in the startRecording
  111437. * functions.
  111438. */
  111439. stopRecording(): void;
  111440. /**
  111441. * Starts recording the canvas for a max duration specified in parameters.
  111442. * @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.
  111443. * @param maxDuration Defines the maximum recording time in seconds.
  111444. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  111445. * @return a promise callback at the end of the recording with the video data in Blob.
  111446. */
  111447. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  111448. /**
  111449. * Releases internal resources used during the recording.
  111450. */
  111451. dispose(): void;
  111452. private _handleDataAvailable;
  111453. private _handleError;
  111454. private _handleStop;
  111455. }
  111456. }
  111457. declare module BABYLON {
  111458. /**
  111459. * Helper class to push actions to a pool of workers.
  111460. */
  111461. export class WorkerPool implements IDisposable {
  111462. private _workerInfos;
  111463. private _pendingActions;
  111464. /**
  111465. * Constructor
  111466. * @param workers Array of workers to use for actions
  111467. */
  111468. constructor(workers: Array<Worker>);
  111469. /**
  111470. * Terminates all workers and clears any pending actions.
  111471. */
  111472. dispose(): void;
  111473. /**
  111474. * Pushes an action to the worker pool. If all the workers are active, the action will be
  111475. * pended until a worker has completed its action.
  111476. * @param action The action to perform. Call onComplete when the action is complete.
  111477. */
  111478. push(action: (worker: Worker, onComplete: () => void) => void): void;
  111479. private _execute;
  111480. }
  111481. }
  111482. declare module BABYLON {
  111483. /**
  111484. * Class containing a set of static utilities functions for screenshots
  111485. */
  111486. export class ScreenshotTools {
  111487. /**
  111488. * Captures a screenshot of the current rendering
  111489. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111490. * @param engine defines the rendering engine
  111491. * @param camera defines the source camera
  111492. * @param size This parameter can be set to a single number or to an object with the
  111493. * following (optional) properties: precision, width, height. If a single number is passed,
  111494. * it will be used for both width and height. If an object is passed, the screenshot size
  111495. * will be derived from the parameters. The precision property is a multiplier allowing
  111496. * rendering at a higher or lower resolution
  111497. * @param successCallback defines the callback receives a single parameter which contains the
  111498. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111499. * src parameter of an <img> to display it
  111500. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  111501. * Check your browser for supported MIME types
  111502. */
  111503. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  111504. /**
  111505. * Generates an image screenshot from the specified camera.
  111506. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111507. * @param engine The engine to use for rendering
  111508. * @param camera The camera to use for rendering
  111509. * @param size This parameter can be set to a single number or to an object with the
  111510. * following (optional) properties: precision, width, height. If a single number is passed,
  111511. * it will be used for both width and height. If an object is passed, the screenshot size
  111512. * will be derived from the parameters. The precision property is a multiplier allowing
  111513. * rendering at a higher or lower resolution
  111514. * @param successCallback The callback receives a single parameter which contains the
  111515. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111516. * src parameter of an <img> to display it
  111517. * @param mimeType The MIME type of the screenshot image (default: image/png).
  111518. * Check your browser for supported MIME types
  111519. * @param samples Texture samples (default: 1)
  111520. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  111521. * @param fileName A name for for the downloaded file.
  111522. */
  111523. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  111524. }
  111525. }
  111526. declare module BABYLON {
  111527. /**
  111528. * A cursor which tracks a point on a path
  111529. */
  111530. export class PathCursor {
  111531. private path;
  111532. /**
  111533. * Stores path cursor callbacks for when an onchange event is triggered
  111534. */
  111535. private _onchange;
  111536. /**
  111537. * The value of the path cursor
  111538. */
  111539. value: number;
  111540. /**
  111541. * The animation array of the path cursor
  111542. */
  111543. animations: Animation[];
  111544. /**
  111545. * Initializes the path cursor
  111546. * @param path The path to track
  111547. */
  111548. constructor(path: Path2);
  111549. /**
  111550. * Gets the cursor point on the path
  111551. * @returns A point on the path cursor at the cursor location
  111552. */
  111553. getPoint(): Vector3;
  111554. /**
  111555. * Moves the cursor ahead by the step amount
  111556. * @param step The amount to move the cursor forward
  111557. * @returns This path cursor
  111558. */
  111559. moveAhead(step?: number): PathCursor;
  111560. /**
  111561. * Moves the cursor behind by the step amount
  111562. * @param step The amount to move the cursor back
  111563. * @returns This path cursor
  111564. */
  111565. moveBack(step?: number): PathCursor;
  111566. /**
  111567. * Moves the cursor by the step amount
  111568. * If the step amount is greater than one, an exception is thrown
  111569. * @param step The amount to move the cursor
  111570. * @returns This path cursor
  111571. */
  111572. move(step: number): PathCursor;
  111573. /**
  111574. * Ensures that the value is limited between zero and one
  111575. * @returns This path cursor
  111576. */
  111577. private ensureLimits;
  111578. /**
  111579. * Runs onchange callbacks on change (used by the animation engine)
  111580. * @returns This path cursor
  111581. */
  111582. private raiseOnChange;
  111583. /**
  111584. * Executes a function on change
  111585. * @param f A path cursor onchange callback
  111586. * @returns This path cursor
  111587. */
  111588. onchange(f: (cursor: PathCursor) => void): PathCursor;
  111589. }
  111590. }
  111591. declare module BABYLON {
  111592. /** @hidden */
  111593. export var blurPixelShader: {
  111594. name: string;
  111595. shader: string;
  111596. };
  111597. }
  111598. declare module BABYLON {
  111599. /** @hidden */
  111600. export var bones300Declaration: {
  111601. name: string;
  111602. shader: string;
  111603. };
  111604. }
  111605. declare module BABYLON {
  111606. /** @hidden */
  111607. export var instances300Declaration: {
  111608. name: string;
  111609. shader: string;
  111610. };
  111611. }
  111612. declare module BABYLON {
  111613. /** @hidden */
  111614. export var pointCloudVertexDeclaration: {
  111615. name: string;
  111616. shader: string;
  111617. };
  111618. }
  111619. // Mixins
  111620. interface Window {
  111621. mozIndexedDB: IDBFactory;
  111622. webkitIndexedDB: IDBFactory;
  111623. msIndexedDB: IDBFactory;
  111624. webkitURL: typeof URL;
  111625. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  111626. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  111627. WebGLRenderingContext: WebGLRenderingContext;
  111628. MSGesture: MSGesture;
  111629. CANNON: any;
  111630. AudioContext: AudioContext;
  111631. webkitAudioContext: AudioContext;
  111632. PointerEvent: any;
  111633. Math: Math;
  111634. Uint8Array: Uint8ArrayConstructor;
  111635. Float32Array: Float32ArrayConstructor;
  111636. mozURL: typeof URL;
  111637. msURL: typeof URL;
  111638. VRFrameData: any; // WebVR, from specs 1.1
  111639. DracoDecoderModule: any;
  111640. setImmediate(handler: (...args: any[]) => void): number;
  111641. }
  111642. interface Document {
  111643. mozCancelFullScreen(): void;
  111644. msCancelFullScreen(): void;
  111645. webkitCancelFullScreen(): void;
  111646. requestPointerLock(): void;
  111647. exitPointerLock(): void;
  111648. mozFullScreen: boolean;
  111649. msIsFullScreen: boolean;
  111650. readonly webkitIsFullScreen: boolean;
  111651. readonly pointerLockElement: Element;
  111652. mozPointerLockElement: HTMLElement;
  111653. msPointerLockElement: HTMLElement;
  111654. webkitPointerLockElement: HTMLElement;
  111655. }
  111656. interface HTMLCanvasElement {
  111657. requestPointerLock(): void;
  111658. msRequestPointerLock?(): void;
  111659. mozRequestPointerLock?(): void;
  111660. webkitRequestPointerLock?(): void;
  111661. /** Track wether a record is in progress */
  111662. isRecording: boolean;
  111663. /** Capture Stream method defined by some browsers */
  111664. captureStream(fps?: number): MediaStream;
  111665. }
  111666. interface CanvasRenderingContext2D {
  111667. msImageSmoothingEnabled: boolean;
  111668. }
  111669. interface MouseEvent {
  111670. mozMovementX: number;
  111671. mozMovementY: number;
  111672. webkitMovementX: number;
  111673. webkitMovementY: number;
  111674. msMovementX: number;
  111675. msMovementY: number;
  111676. }
  111677. interface Navigator {
  111678. mozGetVRDevices: (any: any) => any;
  111679. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111680. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111681. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111682. webkitGetGamepads(): Gamepad[];
  111683. msGetGamepads(): Gamepad[];
  111684. webkitGamepads(): Gamepad[];
  111685. }
  111686. interface HTMLVideoElement {
  111687. mozSrcObject: any;
  111688. }
  111689. interface Math {
  111690. fround(x: number): number;
  111691. imul(a: number, b: number): number;
  111692. }
  111693. interface WebGLProgram {
  111694. context?: WebGLRenderingContext;
  111695. vertexShader?: WebGLShader;
  111696. fragmentShader?: WebGLShader;
  111697. isParallelCompiled: boolean;
  111698. onCompiled?: () => void;
  111699. }
  111700. interface WebGLRenderingContext {
  111701. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  111702. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  111703. vertexAttribDivisor(index: number, divisor: number): void;
  111704. createVertexArray(): any;
  111705. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  111706. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  111707. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  111708. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  111709. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  111710. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  111711. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  111712. // Queries
  111713. createQuery(): WebGLQuery;
  111714. deleteQuery(query: WebGLQuery): void;
  111715. beginQuery(target: number, query: WebGLQuery): void;
  111716. endQuery(target: number): void;
  111717. getQueryParameter(query: WebGLQuery, pname: number): any;
  111718. getQuery(target: number, pname: number): any;
  111719. MAX_SAMPLES: number;
  111720. RGBA8: number;
  111721. READ_FRAMEBUFFER: number;
  111722. DRAW_FRAMEBUFFER: number;
  111723. UNIFORM_BUFFER: number;
  111724. HALF_FLOAT_OES: number;
  111725. RGBA16F: number;
  111726. RGBA32F: number;
  111727. R32F: number;
  111728. RG32F: number;
  111729. RGB32F: number;
  111730. R16F: number;
  111731. RG16F: number;
  111732. RGB16F: number;
  111733. RED: number;
  111734. RG: number;
  111735. R8: number;
  111736. RG8: number;
  111737. UNSIGNED_INT_24_8: number;
  111738. DEPTH24_STENCIL8: number;
  111739. /* Multiple Render Targets */
  111740. drawBuffers(buffers: number[]): void;
  111741. readBuffer(src: number): void;
  111742. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  111743. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  111744. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  111745. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  111746. // Occlusion Query
  111747. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  111748. ANY_SAMPLES_PASSED: number;
  111749. QUERY_RESULT_AVAILABLE: number;
  111750. QUERY_RESULT: number;
  111751. }
  111752. interface WebGLBuffer {
  111753. references: number;
  111754. capacity: number;
  111755. is32Bits: boolean;
  111756. }
  111757. interface WebGLProgram {
  111758. transformFeedback?: WebGLTransformFeedback | null;
  111759. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  111760. }
  111761. interface EXT_disjoint_timer_query {
  111762. QUERY_COUNTER_BITS_EXT: number;
  111763. TIME_ELAPSED_EXT: number;
  111764. TIMESTAMP_EXT: number;
  111765. GPU_DISJOINT_EXT: number;
  111766. QUERY_RESULT_EXT: number;
  111767. QUERY_RESULT_AVAILABLE_EXT: number;
  111768. queryCounterEXT(query: WebGLQuery, target: number): void;
  111769. createQueryEXT(): WebGLQuery;
  111770. beginQueryEXT(target: number, query: WebGLQuery): void;
  111771. endQueryEXT(target: number): void;
  111772. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  111773. deleteQueryEXT(query: WebGLQuery): void;
  111774. }
  111775. interface WebGLUniformLocation {
  111776. _currentState: any;
  111777. }
  111778. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  111779. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  111780. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  111781. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  111782. interface WebGLRenderingContext {
  111783. readonly RASTERIZER_DISCARD: number;
  111784. readonly DEPTH_COMPONENT24: number;
  111785. readonly TEXTURE_3D: number;
  111786. readonly TEXTURE_2D_ARRAY: number;
  111787. readonly TEXTURE_COMPARE_FUNC: number;
  111788. readonly TEXTURE_COMPARE_MODE: number;
  111789. readonly COMPARE_REF_TO_TEXTURE: number;
  111790. readonly TEXTURE_WRAP_R: number;
  111791. readonly HALF_FLOAT: number;
  111792. readonly RGB8: number;
  111793. readonly RED_INTEGER: number;
  111794. readonly RG_INTEGER: number;
  111795. readonly RGB_INTEGER: number;
  111796. readonly RGBA_INTEGER: number;
  111797. readonly R8_SNORM: number;
  111798. readonly RG8_SNORM: number;
  111799. readonly RGB8_SNORM: number;
  111800. readonly RGBA8_SNORM: number;
  111801. readonly R8I: number;
  111802. readonly RG8I: number;
  111803. readonly RGB8I: number;
  111804. readonly RGBA8I: number;
  111805. readonly R8UI: number;
  111806. readonly RG8UI: number;
  111807. readonly RGB8UI: number;
  111808. readonly RGBA8UI: number;
  111809. readonly R16I: number;
  111810. readonly RG16I: number;
  111811. readonly RGB16I: number;
  111812. readonly RGBA16I: number;
  111813. readonly R16UI: number;
  111814. readonly RG16UI: number;
  111815. readonly RGB16UI: number;
  111816. readonly RGBA16UI: number;
  111817. readonly R32I: number;
  111818. readonly RG32I: number;
  111819. readonly RGB32I: number;
  111820. readonly RGBA32I: number;
  111821. readonly R32UI: number;
  111822. readonly RG32UI: number;
  111823. readonly RGB32UI: number;
  111824. readonly RGBA32UI: number;
  111825. readonly RGB10_A2UI: number;
  111826. readonly R11F_G11F_B10F: number;
  111827. readonly RGB9_E5: number;
  111828. readonly RGB10_A2: number;
  111829. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  111830. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  111831. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  111832. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  111833. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  111834. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  111835. 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;
  111836. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  111837. readonly TRANSFORM_FEEDBACK: number;
  111838. readonly INTERLEAVED_ATTRIBS: number;
  111839. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  111840. createTransformFeedback(): WebGLTransformFeedback;
  111841. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  111842. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  111843. beginTransformFeedback(primitiveMode: number): void;
  111844. endTransformFeedback(): void;
  111845. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  111846. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111847. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111848. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111849. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  111850. }
  111851. interface ImageBitmap {
  111852. readonly width: number;
  111853. readonly height: number;
  111854. close(): void;
  111855. }
  111856. interface WebGLQuery extends WebGLObject {
  111857. }
  111858. declare var WebGLQuery: {
  111859. prototype: WebGLQuery;
  111860. new(): WebGLQuery;
  111861. };
  111862. interface WebGLSampler extends WebGLObject {
  111863. }
  111864. declare var WebGLSampler: {
  111865. prototype: WebGLSampler;
  111866. new(): WebGLSampler;
  111867. };
  111868. interface WebGLSync extends WebGLObject {
  111869. }
  111870. declare var WebGLSync: {
  111871. prototype: WebGLSync;
  111872. new(): WebGLSync;
  111873. };
  111874. interface WebGLTransformFeedback extends WebGLObject {
  111875. }
  111876. declare var WebGLTransformFeedback: {
  111877. prototype: WebGLTransformFeedback;
  111878. new(): WebGLTransformFeedback;
  111879. };
  111880. interface WebGLVertexArrayObject extends WebGLObject {
  111881. }
  111882. declare var WebGLVertexArrayObject: {
  111883. prototype: WebGLVertexArrayObject;
  111884. new(): WebGLVertexArrayObject;
  111885. };
  111886. // Type definitions for WebVR API
  111887. // Project: https://w3c.github.io/webvr/
  111888. // Definitions by: six a <https://github.com/lostfictions>
  111889. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  111890. interface VRDisplay extends EventTarget {
  111891. /**
  111892. * Dictionary of capabilities describing the VRDisplay.
  111893. */
  111894. readonly capabilities: VRDisplayCapabilities;
  111895. /**
  111896. * z-depth defining the far plane of the eye view frustum
  111897. * enables mapping of values in the render target depth
  111898. * attachment to scene coordinates. Initially set to 10000.0.
  111899. */
  111900. depthFar: number;
  111901. /**
  111902. * z-depth defining the near plane of the eye view frustum
  111903. * enables mapping of values in the render target depth
  111904. * attachment to scene coordinates. Initially set to 0.01.
  111905. */
  111906. depthNear: number;
  111907. /**
  111908. * An identifier for this distinct VRDisplay. Used as an
  111909. * association point in the Gamepad API.
  111910. */
  111911. readonly displayId: number;
  111912. /**
  111913. * A display name, a user-readable name identifying it.
  111914. */
  111915. readonly displayName: string;
  111916. readonly isConnected: boolean;
  111917. readonly isPresenting: boolean;
  111918. /**
  111919. * If this VRDisplay supports room-scale experiences, the optional
  111920. * stage attribute contains details on the room-scale parameters.
  111921. */
  111922. readonly stageParameters: VRStageParameters | null;
  111923. /**
  111924. * Passing the value returned by `requestAnimationFrame` to
  111925. * `cancelAnimationFrame` will unregister the callback.
  111926. * @param handle Define the hanle of the request to cancel
  111927. */
  111928. cancelAnimationFrame(handle: number): void;
  111929. /**
  111930. * Stops presenting to the VRDisplay.
  111931. * @returns a promise to know when it stopped
  111932. */
  111933. exitPresent(): Promise<void>;
  111934. /**
  111935. * Return the current VREyeParameters for the given eye.
  111936. * @param whichEye Define the eye we want the parameter for
  111937. * @returns the eye parameters
  111938. */
  111939. getEyeParameters(whichEye: string): VREyeParameters;
  111940. /**
  111941. * Populates the passed VRFrameData with the information required to render
  111942. * the current frame.
  111943. * @param frameData Define the data structure to populate
  111944. * @returns true if ok otherwise false
  111945. */
  111946. getFrameData(frameData: VRFrameData): boolean;
  111947. /**
  111948. * Get the layers currently being presented.
  111949. * @returns the list of VR layers
  111950. */
  111951. getLayers(): VRLayer[];
  111952. /**
  111953. * Return a VRPose containing the future predicted pose of the VRDisplay
  111954. * when the current frame will be presented. The value returned will not
  111955. * change until JavaScript has returned control to the browser.
  111956. *
  111957. * The VRPose will contain the position, orientation, velocity,
  111958. * and acceleration of each of these properties.
  111959. * @returns the pose object
  111960. */
  111961. getPose(): VRPose;
  111962. /**
  111963. * Return the current instantaneous pose of the VRDisplay, with no
  111964. * prediction applied.
  111965. * @returns the current instantaneous pose
  111966. */
  111967. getImmediatePose(): VRPose;
  111968. /**
  111969. * The callback passed to `requestAnimationFrame` will be called
  111970. * any time a new frame should be rendered. When the VRDisplay is
  111971. * presenting the callback will be called at the native refresh
  111972. * rate of the HMD. When not presenting this function acts
  111973. * identically to how window.requestAnimationFrame acts. Content should
  111974. * make no assumptions of frame rate or vsync behavior as the HMD runs
  111975. * asynchronously from other displays and at differing refresh rates.
  111976. * @param callback Define the eaction to run next frame
  111977. * @returns the request handle it
  111978. */
  111979. requestAnimationFrame(callback: FrameRequestCallback): number;
  111980. /**
  111981. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  111982. * Repeat calls while already presenting will update the VRLayers being displayed.
  111983. * @param layers Define the list of layer to present
  111984. * @returns a promise to know when the request has been fulfilled
  111985. */
  111986. requestPresent(layers: VRLayer[]): Promise<void>;
  111987. /**
  111988. * Reset the pose for this display, treating its current position and
  111989. * orientation as the "origin/zero" values. VRPose.position,
  111990. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  111991. * updated when calling resetPose(). This should be called in only
  111992. * sitting-space experiences.
  111993. */
  111994. resetPose(): void;
  111995. /**
  111996. * The VRLayer provided to the VRDisplay will be captured and presented
  111997. * in the HMD. Calling this function has the same effect on the source
  111998. * canvas as any other operation that uses its source image, and canvases
  111999. * created without preserveDrawingBuffer set to true will be cleared.
  112000. * @param pose Define the pose to submit
  112001. */
  112002. submitFrame(pose?: VRPose): void;
  112003. }
  112004. declare var VRDisplay: {
  112005. prototype: VRDisplay;
  112006. new(): VRDisplay;
  112007. };
  112008. interface VRLayer {
  112009. leftBounds?: number[] | Float32Array | null;
  112010. rightBounds?: number[] | Float32Array | null;
  112011. source?: HTMLCanvasElement | null;
  112012. }
  112013. interface VRDisplayCapabilities {
  112014. readonly canPresent: boolean;
  112015. readonly hasExternalDisplay: boolean;
  112016. readonly hasOrientation: boolean;
  112017. readonly hasPosition: boolean;
  112018. readonly maxLayers: number;
  112019. }
  112020. interface VREyeParameters {
  112021. /** @deprecated */
  112022. readonly fieldOfView: VRFieldOfView;
  112023. readonly offset: Float32Array;
  112024. readonly renderHeight: number;
  112025. readonly renderWidth: number;
  112026. }
  112027. interface VRFieldOfView {
  112028. readonly downDegrees: number;
  112029. readonly leftDegrees: number;
  112030. readonly rightDegrees: number;
  112031. readonly upDegrees: number;
  112032. }
  112033. interface VRFrameData {
  112034. readonly leftProjectionMatrix: Float32Array;
  112035. readonly leftViewMatrix: Float32Array;
  112036. readonly pose: VRPose;
  112037. readonly rightProjectionMatrix: Float32Array;
  112038. readonly rightViewMatrix: Float32Array;
  112039. readonly timestamp: number;
  112040. }
  112041. interface VRPose {
  112042. readonly angularAcceleration: Float32Array | null;
  112043. readonly angularVelocity: Float32Array | null;
  112044. readonly linearAcceleration: Float32Array | null;
  112045. readonly linearVelocity: Float32Array | null;
  112046. readonly orientation: Float32Array | null;
  112047. readonly position: Float32Array | null;
  112048. readonly timestamp: number;
  112049. }
  112050. interface VRStageParameters {
  112051. sittingToStandingTransform?: Float32Array;
  112052. sizeX?: number;
  112053. sizeY?: number;
  112054. }
  112055. interface Navigator {
  112056. getVRDisplays(): Promise<VRDisplay[]>;
  112057. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  112058. }
  112059. interface Window {
  112060. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  112061. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  112062. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  112063. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112064. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112065. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  112066. }
  112067. interface Gamepad {
  112068. readonly displayId: number;
  112069. }
  112070. interface XRDevice {
  112071. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  112072. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  112073. }
  112074. interface XRSession {
  112075. getInputSources(): Array<any>;
  112076. baseLayer: XRWebGLLayer;
  112077. requestFrameOfReference(type: string): Promise<void>;
  112078. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  112079. end(): Promise<void>;
  112080. requestAnimationFrame: Function;
  112081. addEventListener: Function;
  112082. }
  112083. interface XRSessionCreationOptions {
  112084. outputContext?: WebGLRenderingContext | null;
  112085. immersive?: boolean;
  112086. environmentIntegration?: boolean;
  112087. }
  112088. interface XRLayer {
  112089. getViewport: Function;
  112090. framebufferWidth: number;
  112091. framebufferHeight: number;
  112092. }
  112093. interface XRView {
  112094. projectionMatrix: Float32Array;
  112095. }
  112096. interface XRFrame {
  112097. getDevicePose: Function;
  112098. getInputPose: Function;
  112099. views: Array<XRView>;
  112100. baseLayer: XRLayer;
  112101. }
  112102. interface XRFrameOfReference {
  112103. }
  112104. interface XRWebGLLayer extends XRLayer {
  112105. framebuffer: WebGLFramebuffer;
  112106. }
  112107. declare var XRWebGLLayer: {
  112108. prototype: XRWebGLLayer;
  112109. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  112110. };